Extending the Print Widget

7279
6
Jump to solution
05-20-2015 02:04 PM
DamonMyers
New Contributor II

A user has requested the ability to type notes into the print widget before the call is made to the Print service that generates the map documents for printing. I understand the majority of how to implement this, except for how to pass form data to the Print service.

Can anyone tell me where, in the Esri Print Widget, passing form data (such as Map Title, Format, Layout, and Author) to the Print service is handled?

Thanks,

Damon

Tags (2)
1 Solution

Accepted Solutions
DamonMyers
New Contributor II

Answered my own question pretty shortly after posting:

Passing data to the PrintTemplate object is handled on lines 262-273 of the Print.js file of the Print widget. I was having trouble as I was trying to update the description text of the print template, which does not seem to be supported. I instead need to use the customTextElements object of the layoutOptions attribute of PrintTemplate.

API reference: PrintTemplate | API Reference | ArcGIS API for JavaScript


Thanks,

Damon

View solution in original post

6 Replies
DamonMyers
New Contributor II

Answered my own question pretty shortly after posting:

Passing data to the PrintTemplate object is handled on lines 262-273 of the Print.js file of the Print widget. I was having trouble as I was trying to update the description text of the print template, which does not seem to be supported. I instead need to use the customTextElements object of the layoutOptions attribute of PrintTemplate.

API reference: PrintTemplate | API Reference | ArcGIS API for JavaScript


Thanks,

Damon

DrewSwayne
New Contributor II

Damon,

How did you actually implement this? I tried adding a subtitle to the map title but I am unable to modify the text size, etc. I added it as a new line in the current Map Title when printed, but then it bleeds into the map frame. Are you able to use the customTextElements to place text anywhere you want within the printed map?

Capture.PNG

RobertScheitlin__GISP
MVP Emeritus

Drew,

  1. Add a new text element to your print template in ArcMap using the menu Insert > Text, place and format it as desired.
  2. switch to the Size and Position Tab and in the Element Name enter "SubTitle".
  3. Save your print template.
  4. In the WAB print widgets' Print.js file find line 267 "template.layoutOptions = {"
  5. Add a new line under 267 and paste this

customTextElements: [{SubTitle: form.subtitle}], (assuming your Dam Id field on the from is called "subtitle").

HelenWhiteley
New Contributor III

Hi Robert,

I managed to use your above code to use customTextElements to add in a free text box, as Drew has above, into the print widget in WAB.  However, following further customisations (which also were working), I am now no longer getting any free text boxes within the widget, despite (I'm sure) not changing anything.

Do you have any suggestions as to what might have changed / what I am doing wrong?

Thanks,

Helen

0 Kudos
JayHalligan
New Contributor III

Can anyone provide more detailed information on how to modify the form, to add the input, to pass the custom text element into the layout.  I have modified the template "Element" and added the new line under Line 267, but I cant seem to get past this point.  I just want the option to input a few new lines of text to pass to my custom text elements in the layout.  Any help would be appreciated.  Thanks.

0 Kudos
StanMcShinsky
Occasional Contributor III

Jay,

You need to add code to your form in the \widgets\Print\templates\Print.html file

It depends on where you want the user to enter the information. Visible from the top of accessible through the advanced button. For example I wanted mine to show up in the advanced section so I just added this between the Author and copyright table rows.

<tr>
    <td>
        Additional Text:
    </td>
    <td>
        <input type="text" data-dojo-attach-point="BOXTEXTNode" data-dojo-type="dijit/form/ValidationTextBox" data-dojo-props="name:'BOXTEXT',trim:true,required:false,style:'width:100%;'" data-dojo-attach-point="BOXTEXTTB"/>
    </td>
</tr>

In line 6 above replace the 3 instances of BOXTEXT with the value you made in the Print.js file as mentioned previously.

-Stan