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

24641
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
TanuHoque
Esri Regular Contributor

Hello,

Could you please contact Esri Support? Someone needs to take a look at this... it should work.

thanks.

0 Kudos
SarahHeld1
New Contributor II

Helen and Jarrett - did you ever find a soulution for this? I am having the same Problem here...

0 Kudos
CaseyRagain
New Contributor II

Helen,

Were you able to resolve this? I am having the exact same problems as you were! Thanks.

0 Kudos
JonMorris2
Occasional Contributor II

An alternative is to publish a print service on your own server - then you can add custom templates with your company logo and all the elements you like.

The script can be a simple wrapper for the ExportWebMap tool, like this:


  import arcpy


  Web_Map_as_JSON = arcpy.GetParameterAsText(0)
  Format = arcpy.GetParameterAsText(1)
  Layout_Template = arcpy.GetParameterAsText(2)
  Layout_Templates_Folder = r'd:\maps\exportwebmaptemplates'
  Output_File = None


  result = arcpy.ExportWebMap_server(
  Web_Map_as_JSON,
  Output_File,
  Format,
  Layout_Templates_Folder,
  Layout_Template
  )

Then just add the mxd templates to the folder on the server you've named above (in our case d:\maps\exportwebmaptemplates). When you publish the tool to the server, add all the template names to a choice list so users can just pick the one they want.

Parameter: Layout_Template

Data Type: GPString

Display Name Layout Template

Description: TODO

Direction: esriGPParameterDirectionInput

Default Value: MAP_ONLY

Parameter Type: esriGPParameterTypeOptional

Category:

Choice List: [ MAP_ONLY, A3 Landscape, A3 Landscape Legend Only, A3 Landscape No Legend, A3 Portrait, A3 Portrait Legend Only, A3 Portrait No Legend, A4 Landscape, A4 Landscape Legend Only, A4 Landscape No Legend, A4 Portrait, A4 Portrait Legend Only, A4 Portrait No Legend, Letter ANSI A Landscape, Letter ANSI A Landscape Legend Only, Letter ANSI A Landscape No Legend, Letter ANSI A Portrait, Letter ANSI A Portrait Legend Only, Letter ANSI A Portrait No Legend, Tabloid ANSI B Landscape, Tabloid ANSI B Landscape Legend Only, Tabloid ANSI B Landscape No Legend, Tabloid ANSI B Portrait, Tabloid ANSI B Portrait Legend Only, Tabloid ANSI B Portrait No Legend ]

TanuHoque
Esri Regular Contributor

Jon,

we don't recommend using arcpy.ExportWebMap_server() in scripting environment to create your own arcpy based printing service...

most of the cases you should be fine by creating your printing service from Export Web Map GP tool. In fact, these two approaches would be functionally equivalent. embedding it inside a script is not a good idea.

for some advanced use cases, when you need to create an arcpy based printing service, you should use arcpy.mapping.ConvertWebMapToMapDocument() function... which gives you more control over the output.

JonMorris2
Occasional Contributor II

Ok. Can we still use our custom map templates if just publishing the Export Web Map tool to our server? Sounds like we'd have to manually edit the template path after publishing. Or set up an equivalent path on the desktop machine so we can get a GP result that can be published.

The script wrapper is needed anyway as a workaround to a bug where the export image filename is not returned. I've raised an issue with Esri UK support - CAS-17137-N6H0T4: Arcpy.ExportWebMap_server returns incorrect output file name.

0 Kudos
TanuHoque
Esri Regular Contributor

Jon,

My apologies, I'm afraid I'm not quite clear on your first issue...

to publish a printing service with custom templates, steps are:

- open the Export Web Map tool in Desktop,

- choose the folder with your custom templates

- execute the tool

- publish the result

  the service will use templates from the folder you chose in step#2.

is this not working for you?

Or set up an equivalent path on the desktop machine so we can get a GP result that can be published.

sorry, i can't follow this..

The script wrapper is needed anyway as a workaround to a bug where the export image filename is not returned. I've raised an issue with Esri UK support - CAS-17137-N6H0T4: Arcpy.ExportWebMap_server returns incorrect output file name.

do you happen to have a NIM or BUG id for the above issue? can you pls share that with me. i'm not currently aware of any bug with output file name.

Thanks.

JonMorris2
Occasional Contributor II

the service will use templates from the folder you chose in step#2.

Does it copy all the templates in the folder? I didn't know that.

Or set up an equivalent path on the desktop machine so we can get a GP result that can be published.

I've put the templates on the server at d:\maps\exportwebmaptemplates, so I thought I'd need to create a d:\maps\exportwebmaptemplates folder on my desktop to put the templates in. Either that or edit the script after publishing.

do you happen to have a NIM or BUG id for the above issue? can you pls share that with me. i'm not currently aware of any bug with output file name.

I don't think Esri UK have entered it into Nimbus yet. I've asked for a status update, so I'll let you know when they get back to me.

0 Kudos
TanuHoque
Esri Regular Contributor

Does it copy all the templates in the folder? I didn't know that.

seems like you are publishing from your machine to a separate server machine, right?

like any other gp or map service, if you don't have the folder registered on the server, you templates will be copied to the server in a managed folder inside \arcgiserver folder.

for some reasons, if you don't want it to be auto-copied in the managed folder, you would need to register the folder from your local machine in ArcGIS Manager to point to a separate folder on the server.

ags_manager_data_store.png

once you do that and publish a print service off ExportWebMap tool from your local machine, you should be just fine.

please give it a try and let me know how it works.

0 Kudos
TanuHoque
Esri Regular Contributor

FYI: for those who want to use GeLayouttTemplatesInfo tool but haven't been able to move to 10.4, you can download the script from https://github.com/arcpy/sample-gp-tools/tree/master/GetLayoutTemplatesInfo

once you copy it on your local machine, follow the steps from Tutorial: Publishing additional services for printing—Documentation | ArcGIS for Server --- only thing is that instead of using the GetLayoutTemplatesInfo from the system toolset, use the one you downloaded.