Printing Popup Contents

Jump to solution
10-26-2016 12:42 AM
New Contributor III

I have a Web Mapping Application with a standard Print Widget. I would like to include the contents of the popup window in the printout.

Here is an example:

GIS Portal for the City of Abilene, TX

Standard printout:

Standard printout

Popup window:

Popup window

Desired printout:

Desired printout

My research so far:

There is a BLOG POST by esri explaining how to do this. This post shows 2 methods. The first method is not suitable for my purposes cause it requires manual data entries for each printout. The second method seems incomplete, Format & Layout_Template parameters are missing. Print does not work even if I add those parameters manually before publishing the service. If the second method worked properly, I would have modified it to match my needs, unfortunately it doesn't.

dojoOn(map.infoWindow, "selection-change", function(){ //build custom text here }

My knowledge on JavaScript is limited, so I couldn't manage what he explained here. Where am I supposed to add this and what should I include in the function?

We have the print button generating an html page that pulls data from the database and formats it in pretty much an exact replica of the .mxd we were using. For the map it uses a function on the rest endpoint to generate an image from the map service.

This seems even more complicated than the others.

Either one the above solutions works for me.

  1. add popup contents at the bottom of the print layout
  2. make use of "selection-change" event
  3. generate a new html page
  4. any other suggestion

TL;DR I want to include popup window or it's contents in the printout.

Thanks in advance.

75 Replies
New Contributor III

Thank you for the quick reply, I appreciate it. 

I put the code in the print.js file of the Print widget, I believe in the correct spots, however, the print widget does not do anything now, just shows a blank panel (see code below).  If this is of any help, this information is going to a custom print service and the map window in the printout is small, 2.5in x 3.5in.  Am I missing something else?

Thanks again.

print: function() {
//DT edit
var myExtent =;, true);
//DT end edit
setTimeout(function(){ //DT edit
if (this.printSettingsFormDijit.isValid()) {
var form = this.printSettingsFormDijit.get('value');
lang.mixin(form, this.layoutMetadataDijit.get('value'));
lang.mixin(form, this.forceAttributesFormDijit.get('value'));
lang.mixin(form, this.labelsFormDijit.get('value'));
this.preserve = this.preserveFormDijit.get('value');
lang.mixin(form, this.preserve);
this.layoutForm = this.layoutFormDijit.get('value');
var mapQualityForm = this.mapQualityFormDijit.get('value');
var mapOnlyForm = this.mapOnlyFormDijit.get('value');
lang.mixin(mapOnlyForm, mapQualityForm);

var elementsObj = this.customTextElementsDijit.get('value');
var cteArray = [], hasDate = false, locale = dojoConfig.locale || 'en';
for (var p in elementsObj) {
var cte = {};
if (p === 'Date') {
hasDate = true;
cte[p] = elementsObj[p];
if(!hasDate) {
cteArray.push({ Date: new Date().toLocaleString(locale) });

var templateInfo = this._currentTemplateInfo;
var hasAuthorText = lang.getObject('layoutOptions.hasAuthorText', false, templateInfo);
var hasCopyrightText = lang.getObject('layoutOptions.hasCopyrightText',
false, templateInfo);
var hasTitleText = lang.getObject('layoutOptions.hasTitleText', false, templateInfo);

var template = new PrintTemplate();
template.format = form.format;
template.layout = form.layout;
template.preserveScale = (form.preserveScale === 'true' || form.preserveScale === 'force');
template.forceFeatureAttributes = form.forceFeatureAttributes && form.forceFeatureAttributes[0];
template.label = form.title;
template.exportOptions = mapOnlyForm;
template.showLabels = form.showLabels && form.showLabels[0];
template.layoutOptions = {
authorText: hasAuthorText ? : "",
copyrightText: hasCopyrightText ? (form.copyright || this._getMapAttribution()) : "",
legendLayers: this._getLegendLayers(), // fix issue 7744
titleText: hasTitleText ? form.title : "",
customTextElements: cteArray,
scalebarUnit: this.layoutForm.scalebarUnit

// DT print attribute information of the selected feature
var cTextElements = [];
var gra =;

var obj1 = { val_ADDRESS: gra.attributes.ADDRESS };
var obj2 = { val_NEIGHBORHOOD: gra.attributes.NEIGHBORHOOD };
var obj3 = { val_POLLING_PLACE_ZIP: gra.attributes.POLLING_PLACE_ZIP };
var obj3 = { val_ZONING: gra.attributes.ZONING };
var obj4 = { val_ZONEDESC: gra.attributes.ZONEDESC };
var obj5 = { val_SCHOOL_DIST: gra.attributes.SCHOOL_DIST };
var obj6 = { val_ELEM_SCHOOL: gra.attributes.ELEM_SCHOOL };
var obj7 = { val_MIDDLE_SCHOOL: gra.attributes.MIDDLE_SCHOOL };
var obj8 = { val_HIGH_SCHOOL: gra.attributes.HIGH_SCHOOL };
var obj9 = { val_FEMA_FLDZN: gra.attributes.FEMA_FLDZN };
var obj10 = { val_PARK_COUNT: gra.attributes.PARK_COUNT };
var obj11 = { val_NEAREST_PARK: gra.attributes.NEAREST_PARK };
var obj12 = { val_ELECTION_DISTRICT: gra.attributes.ELECTION_DISTRICT };
var obj13 = { val_POLLING_PLACE: gra.attributes.POLLING_PLACE };
var obj14 = { val_POLLING_PLACE_ADD: gra.attributes.POLLING_PLACE_ADD };
var obj15 = { val_RECYCLEDAY: gra.attributes.RECYCLEDAY };
var obj16 = { val_ELEC_COMP: gra.attributes.ELEC_COMP };
var obj17 = { val_ELEC_LINK: gra.attributes.ELEC_LINK };
var obj18 = { val_MNSENATE: gra.attributes.MNSENATE };
var obj19 = { val_MNHOUSE: gra.attributes.MNHOUSE };
var obj20 = { val_CP_OFFICER: gra.attributes.CP_OFFICER };
var obj21 = { val_MAYOR: gra.attributes.MAYOR };
var obj22 = { val_COUNCIL1: gra.attributes.COUNCIL1 };
var obj23 = { val_COUNCIL2: gra.attributes.COUNCIL2 };
var obj24 = { val_COUNCIL3: gra.attributes.COUNCIL3 };
var obj25 = { val_COUNCIL4: gra.attributes.COUNCIL4 };
var obj26 = { val_CITYCLEANUP: gra.attributes.CITYCLEANUP };
var obj27 = { val_GAS_COMP: gra.attributes.GAS_COMP };
var obj28 = { val_GAS_LINK: gra.attributes.GAS_LINK };
var obj29 = { val_ASSESS_PHOTO: gra.attributes.ASSESS_PHOTO };
var obj30 = { val_BUS_ROUTE: gra.attributes.BUS_ROUTE };
var obj31 = { val_UTILITYBILLING: gra.attributes.UTILITYBILLING };
var obj32 = { val_FEMA_FLDZN_DESC: gra.attributes.FEMA_FLDZN_DESC };

template.layoutOptions.customTextElements = cTextElements;
// DT end print attribute of selected feature

this.printparams.template = template;
this.printparams.extraParameters = { // come from source code of jsapi
printFlag: true
// reset outSpatialReference
this.printparams.outSpatialReference = undefined;
var outWkid = +this.wkidInput.get('value');
if (srUtils.isValidWkid(outWkid) && outWkid !== {
this.printparams.outSpatialReference = new SpatialReference(outWkid);
var fileHandel = this.printTask.execute(this.printparams);

var result = new printResultDijit({
count: this.count.toString(),
icon: (form.format === "PDF") ? this.pdfIcon : this.imageIcon,
docName: form.title,
title: form.format + ', ' + form.layout,
fileHandle: fileHandel,
nls: this.nls
}).placeAt(this.printResultsNode, 'last');
domStyle.set(this.clearActionBarNode, 'display', 'block');
} else {
}.bind(this, 1000); //DT edit
0 Kudos
New Contributor III

Did it work before the final modification to the code? 

Please post screenshots of the problem areas.

0 Kudos
New Contributor III

Yes, the print worked before.  When I comment out the following lines

   }.bind(this, 1000);
the print widget works and it centers on the parcel and does the expand to 25% extent around the
selected parcel, within the application, but does not carry over to the printout. The printout keeps the zoom level set in the search
widget or if I happen to zoom in/out on the map.

extent of search widget


extent after clicking the print button


extent on printout, keeps the same scale that is set in the search function or if I zoom in/out on the map

0 Kudos
New Contributor III

Sorry Denise, I made a typo in the earlier post.

print: function () {
   var myExtent =;, true);

          if (this.printSettingsFormDijit.isValid()) {
          } else {
       }.bind(this), 1000); // should be like this

This should work.

New Contributor III

Thank you so much.  I appreciate all of your help.  It seems to be working now the way I would like it to.  I did have to adjust the expand factor to 4.5 from 1.25 and so far any size selected parcels are fulling shown in the printout.

0 Kudos
New Contributor III

Glad to be of help.

0 Kudos