How do you create an interactive map title with the JavaScript Print Widget?

527
3
05-11-2018 02:54 PM
NilsBabel
Occasional Contributor II

Can anyone suggest a technique to create an interactive title with the esri print widget?

  Print | API Reference | ArcGIS API for JavaScript 3.24 

I would like to provide a text box for the user to type in a map title for the printout.  However, it seems like the way the print widget works is you have to create your print templates before you startup the print widget.  The templates contain the Title Text.  So I'm not sure how to inject feedback from the user into the print template.  Any ideas or other methods for doing this?

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus

Nils,

   You do that using the PrintTemplate class and the the layoutOptions.titleText:

https://developers.arcgis.com/javascript/3/jsapi/printtemplate-amd.html#layoutoptions 

and the PrintTemplate is feed to the PrintParameters.template and the PrintTask is executed using the PrintParameters.

var printparams =  new PrintParameters();
printparams.map = map;
...
var template = new PrintTemplate();
template.label = "blah blah";
...
template.layoutOptions = {
  titleText: "My Title"
};
printparams.template = template;
printTask.execute(printparams)
0 Kudos
NilsBabel
Occasional Contributor II

Thanks Robert, that's essentially what I'm doing.  But I'm using the print widget.  Seems like the templates have to be defined at the time that you startup the widget.  I'd like to have a user type in a title to be used in the template.   I might have to ditch the widget and use the printTask to accomplish this. 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Nils,

   In this sample

https://developers.arcgis.com/javascript/3/sandbox/sandbox.html?sample=widget_print_esri_request 

The templates title is replaced with "Pool Permits". So you could use this sample as a starting point.

0 Kudos