How to add custom text elements to custom print layout using WAB print widget?

24443
37
06-01-2016 06:05 AM
HelenWhiteley
New Contributor III

Hi,

I am trying to create print templates which enable the user to add more text to a layout than just the title and author.  I have added elements to the mxd and named them and tried to call them using CustomTextElements, but do not know how to make the text box for the user to enter the text into appear within the print widget.  I'm sure I'm missing something simple?!  I am using the Web Appbuilder in ArcGIS Portal 10.4 and also have access to WAB for Developers 2.0.

Please help,

Thanks,

Helen

37 Replies
MichaelMiller2
Occasional Contributor III

Helen,

Check out this link to Publishing Additional Services for Printing. It's a tutorial that will walk you through the steps to get set up allowing users to customize the custom text elements of their web maps.

Michael

HelenWhiteley
New Contributor III

Thanks Michael,

That's exactly the tutorial I used to publish my print services and custom templates.  However, I need more information on the custom text elements, unless I'm missing something, this tutorial doesn't cover this?

Helen

MichaelMiller2
Occasional Contributor III

At the Developer Conference this year I saw a presentation on this very subject. One of the presenters was Tanu Hoque and he was an enormous help via email. Maybe try connecting with him to sort it all out.

Question, are you running server 10.4? I believe if it's an earlier version of server there are additional steps that need to be taken.

Below is the info Tanu forwarded to me:

You need to create a script tool with following parameters

GetLayoutTemplateInfo.png

nb: the name of the first parameter shouldn't matter.

  Again, this script/task only to provide metadata information for each layout templates… which helps Web App Builder’s print widget to show those options in it.

This requires running a python file to generate the script tool and I do not see a way to attach the script (GetLayoutTemplateInfo.py).

0 Kudos
TanuHoque
Esri Regular Contributor

Thanks Michael Miller​. I'm glad i was able to help.

Helen Whiteley​, it is step# 8 in "Preparing and publishing the service" section in that help that describe how to add that additional task to the printing service in 10.4. WAB printing widget (though i'm not sure which version) looks for that GetLayoutTemplateInfo task in the printing service; if it finds it, it uses metadata from each layout and show text boxes to allow you set values for your custom text elements.

This is something new in 10.4.

Hope this helps.

HelenWhiteley
New Contributor III

Thanks Tanu Hoque​, that's great to know it is possible to easily add custom text elements.  However... I am following the steps in 'Tutorial: Publishing additional services for printing' to the letter - I am running the GetLayoutTemplateTask and adding it as a result in Service Properties.  The added in elements do show on the maps, but there is nowhere in the print widget for me to manually enter text to fill these elements, which, if I understand your explanation correctly, there should be?  I have tried both restarting the existing service as well as publishing a new one, but I still only receive the 'Author' and 'Copyright' options under Layout Metadata, under Advanced.

However - I have taken a copy of one of the default templates at Program Files\ArcGIS\Server\Templates\ExportWebMapTemplates, added a Custom Text Element to this, restarted the service - and this works as it should, with an extra text box displaying below Layout metadata, so the issues are only with print services I have published myself.

Any idea what I'm doing wrong??

Thanks,

Helen

0 Kudos
TanuHoque
Esri Regular Contributor

My bad, I misunderstood.

So, if I understand it correctly:

  • you have published your own custom printing service. the service has two tasks in it (1) Export Web Map and (2) Get Layout Template Infos
  • the layouts (or mxd) used in that printing service have custom text elements... I am pretty sure you have provided 'Name' for those custom text element in the mxd... otherwise they'd not have shown up when you used the template with the Out Of The Box Printing Service.
  • now, the problem is that when you use your custom printing service with WAB Print Widget, those custom text elements are not showing up, right?

if those are correct, i have few questions:

  • Is your printing service public? if so, can you pls share the url for me to take a look at the service resource.
  • if it is not public, can you pls share a screen-shot for the service's REST resource?
  • if you go to the 'Get Layout Templates Info' task's REST resource end point and execute it, does it return correct response i.e the name of the templates are correct and the text elements etc.?
  • when you ran Get Layout Template Info gp-script-tool in desktop, did you make sure that it pointed to the "same folder" that was specified in the Export Web Map GP tool?
  • finally, when you use or setting up the WAB Print widget, can you pls use Firebug or any other web browser developer tool to monitor what are the requests being generated by the widget and are they failing or not getting expected result?
HelenWhiteley
New Contributor III

Hi Tanu,

That is correct.  The custom text elements do show up on the output maps, but not in the WAB print widget.

Unfortunately the print service is not public.  Executing the Get Layout Templates from the REST endpoint returns the correct JSON eg

{

"results": [{

  "paramName": "Output_JSON",

  "dataType": "GPString",

  "value": [

   {

    "layoutOptions": {

     "hasAuthorText": false,

     "hasCopyrightText": false,

     "hasTitleText": true,

     "hasLegend": true,

     "customTextElements": [

      {"Test": "Text"},

      {"SubTitle": "Text"}

     ]

    },

    "pageSize": [

     296.92659385318774,

     209.97375328083996

    ],

    "layoutTemplate": "A4_Landscape",

    "activeDataFrameSize": [

     273.05060000000003,

     146.0503

    ]

   },

and the script tool was pointing to the correct folder when I ran it.

I have used Fiddler to record the requests and get a 'no entry' sign next to the request in question which apparently means Session Aborted Session was aborted by the client, Fiddler, or the Server.

#ResultProtocolHostURLBodyCachingContent-TypeProcessCommentsCustom
506200HTTPScp-gis-iis.infprod.tca/arcgis/rest/services/Geoprocessing_Services/WorkingTemplates/GPServer/Get%20Layout%20Templates%20Info/execute?f=json495private, must-revalidate, max-age=0text/plain;charset=utf-8iexplore:3740

I'm an amateur with Fiddler, so don't know how to delve deeper.

Having a look in the Chrome web traffic information it seems that the Get Layout Info task is timing out: n {message: "Timeout exceeded", response: Object, status: undefined, responseText: undefined, xhr: XMLHttpRequest…}  It does take a long time for the print widget to populate the layout information.  I have tried increased the times and pooling in the Service Properties, but to no avail.  I have tried publishing different print services, but have the same issue with them all. Have you any ideas what might be causing this and how to solve it?

Thanks,

Helen

0 Kudos
TanuHoque
Esri Regular Contributor

hmm... so you are saying if you execute it from the REST service directory, it works fine. But the same service when used with the Printing widget, it times out!!

how long does it take for it to finish when you execute it from the REST service directory?

are you templates empty or they contain some layers?

if it is all about timing out, I'm sorry I don't think i have much expertise in that area to help could you please contact Esri Support and have someone take a look at that?

0 Kudos
JarrettHandy1
New Contributor

Did you ever get this resolved i am having the same issue

0 Kudos