What's the easiest way to print the contents of an InfoWindow or Popup? I would think that ESRI would add a "print" link as an option (similar to the "Zoom to" link that's provided in the Popup). Am I missing something easy or do I have to code this myself somehow?
Thanks!
var printLink = dojo.create("a", { "class": "action", "innerHTML": "Print", "href": "javascript:void(0);" }, dojo.query(".actionList", map.infoWindow.domNode)[0] );
dojo.connect(printLink, "onclick", printPopupContents);
function printPopupContents(){ var feature = map.infoWindow.getSelectedFeature(); var popupContent = feature.getContent(); //write contents to new page for printing var newWindow = window.open("", "PopupContents"); console.log(popupContent); newWindow.document.write(popupContent); }
function printPopupContents(){ console.log("-->inside printPopupContents"); var popupTable = dojo.query(".attrTable"); console.log("popupTable.length: " + popupTable.length); console.log("popupTable[0].innerHTML: " + popupTable[0].innerHTML); popupTableContent = "<table>" + popupTable[0].innerHTML + "</table>"; popupContent = '<html><head><title>Rezoning Print Window</title>'; /*optional stylesheet*/ //popupContent += '<link rel="stylesheet" type="text/css" href="css/rezoning.css" />'; popupContent +='</head><body>'; popupContent += popupTableContent popupContent +='</br><div>'; popupContent += configOptions.owner; popupContent +='</div>'; popupContent +='</body></html>'; //write contents to new page for printing var newWindow = window.open("", "PopupContents"); console.log(popupContent); newWindow.document.write(popupContent); }
Does anyone know the 4x equivalent for this code? It looks like what I need to grab the pop-up contains and populate a new page for printing
function printPopupContents(){
var feature = map.infoWindow.getSelectedFeature();
var popupContent = feature.getContent();
//write contents to new page for printing
var newWindow = window.open("", "PopupContents");
console.log(popupContent);
newWindow.document.write(popupContent);