JS API 4.15: Print template issue

7016
16
Jump to solution
04-10-2020 04:09 AM
NicolasGIS
Occasional Contributor III

Hello,

I wanted to migrate to JS API 4.15 but noticed an issue with Print Widget: it does not honor the print templates from my 'Export Web Map' GPServer anymore. 

Here is an extract from the REST API:

Print widget properly displays them just like it used:

But when Posting the job, the following message is logged:

"dojo.js:253 [esri.core.Accessor] Accessor#set 'A4_Paysage' is not a valid value for this property, only the following values are valid: 'map-only', 'a3-landscape', 'a3-portrait', 'a4-landscape', 'a4-portrait', 'letter-ansi-a-landscape', 'letter-ansi-a-portrait', 'tabloid-ansi-b-landscape', 'tabloid-ansi-b-portrait'"

And MAP

Layout_Template:
MAP_ONLY

is sent rather than "A4_Paysage".

According to the release notes, there had been somes changes in the Print widget:

Release notes for 4.15 | ArcGIS API for JavaScript 4.15 

But I don't think that it means that this workflow is unsupported anymore, doesn't it ?

In the layout property of the templateOptions, it is stated "The print service provides out-of-the-box templates listed in possible values. The server administrator can add additional templates to the print service.". So if server administrator can add additional templates, JS API should accept them specially if it has been fetched from the service configuration.

This workflow used to work fine in previous versions 4.13 and 4.14.

Did I miss anything ?

Thanks,

Best regards,

Nicolas

Tags (2)
16 Replies
Noah-Sager
Esri Regular Contributor

Gotcha. I will investigate. 

0 Kudos
NicolasGIS
Occasional Contributor III

Actually, it seems that this translation value has nothing to do with nls files as either in French or in English, "A4 Landscape" is sent to the print service rather than "a4-landscape".

Debugging a little, I found out that in "PrintTask" (task/PrintTask) "_getGpPrintParams" method, a call to tasks/support/layoutTemplate "toJSON" method is converting "a4-landscape" to "A4 Landscape" so nothing to do with nls indeed.

So one workaround is to duplicate each template:

- one to please JS API accessor ("a4-landscape")

- one for the printing ("A4 Landscape")

Noah-Sager
Esri Regular Contributor

mvolz47 wrote:

Does this bug mean that you cannot have custom page sizes in your print template or just not custom print template names?

Sorry for not replying to this sooner. I believe the issue affects custom page sizes as well, but I have not tested that to verify.

0 Kudos
Noah-Sager
Esri Regular Contributor

Ok, when you get a chance, can you please test with /next and let me know how it goes? The issue with custom template formats and layouts should be resolved, and if so, it will release at 4.16 this summer.
https://github.com/Esri/feedback-js-api-next

And yes, behind the scenes we do some name convention formatting for the Esri default templates. This formatting ensures that printing will work well across the Esri platform and with different versions of the print service, but we will look to see if we can add this information to the documentation so that people know better what to expect.

NicolasGIS
Occasional Contributor III

Thanks ! The initial issue is fixed in next.

MKY
by
New Contributor III

Hi Noah, Is there a work around that we can apply until the fix is out?

Markos

0 Kudos
Noah-Sager
Esri Regular Contributor

Hi Markos. Unfortunately, I haven't found a workaround to using the Print widget with custom print templates. The only suggestion I have right now is to use /next (https://github.com/Esri/feedback-js-api-next). I've been trying to think of a way to use RequestInterceptor (config | ArcGIS API for JavaScript 4.15 ) but haven't figured out a solution there.

0 Kudos