Select to view content in your preferred language

JSAPI 3.29 - customTextElements supported?

1651
17
08-09-2019 06:08 AM
Claire_Peterson
Occasional Contributor

First off, are customTextElements even supported in API 3.29? I have a Print dijit set up (code below) but I can't seem to get the customTextElements to show up on my layout. The customTextElements come directly from the Get Layout Templates Info Execute task. I would really like to be able to pass an array that is defined in PHP but the print keeps timing out. I swapped the arrays to just the letter "t" to see if that would work and again, it's timing out. I see that customTextElements are listed under the layoutOptions but you can't pass DynamicText? I am looking to display attribute information for the feature that is being printed by a URL parameter (ID) on the layout template.

  // print dijit
      var printer = new Print({
          map: theMap,
          url: "<server>",
          templates: [{
            label: "Map",
            format: "PDF",
            layout: "TREATMENTS",
            layoutOptions: {
              customTextElements: [
                  {"Target": "t"},
                  {"Date": "t"},
                  {"EPA": "t"},
                  {"Chemical": "t"},
                  {"Weather": "t"},
                  {"Title": "t"},
                  {"Year": "t"}
                ]
            },
            exportOptions: {
              width: 772,
              height: 772,
              dpi: 200
            }
          }]
      }, dom.byId("printButton"));
      printer.startup();
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
17 Replies
Claire_Peterson
Occasional Contributor

Robert Scheitlin, GISP

Similar to what I see as well but I am still a bit confused as to how those elements "pick up" the attribute information. Also it seems like whenever I add the customTextElements to my code, the print service times out. 

The year seems to work just fine with <dyn type="date" format="yyyy"> in the properties but as soon as I add something like this to the other text boxes, they don't show up in the Execute Task information. Though I could be typing in something incorrect.

{
 "results": [{
  "paramName": "Output_JSON",
  "dataType": "GPString",
  "value": [{
   "layoutOptions": {
    "hasAuthorText": false,
    "hasCopyrightText": false,
    "hasTitleText": false,
    "hasLegend": true,
    "customTextElements": [
     {"Weather": ""},
     {"EPA": ""},
     {"Chemical": ""},
     {"tmDate": ""},
     {"Target": ""},
     {"Site": ""},
     {"Year": ""}
    ]
   },
   "pageSize": [
    11.0,
    8.5
   ],
   "layoutTemplate": "TREATMENTS",
   "activeDataFrameSize": [
    8.7866,
    7.3068
   ]
  }]
 }],
 "messages": []
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Claire,

  So here is your layout info mixed in with my code:

var templates = [{
        label: "Map",
        format: "PDF",
        showAttribution: true,
        layout: "TREATMENTS",
        exportOptions: {
          "dpi": 96
        },
        layoutOptions: {
          copyrightText: "",
          customTextElements: [{
            Weather: "blah"
          },{
            EPA: "blah"
          },{
            Chemical: "blah"
          },{
            tmDate: "blah"
          },{
            Target: "blah"
          },{
            Site: "blah"
          },{
            Year: "blah"
          }]
        }
      }];

      // print dijit
      VAR printer = new Print({
        map: theMap,
        templates: templates,
        url: "your custom print service url"
      }, dojo.byId("printButton"));
      printer.startup();
0 Kudos
Claire_Peterson
Occasional Contributor

Robert Scheitlin, GISP‌ It still keeps timing out whenever I incorporate the customTextElements. As soon as I comment that section out - the print works.

Also - the "blah" is embedded into the code so it would print out blah in every box, correct?  How would you print out certain attributes associated with the object being printed? 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Claire,

Hmm.. So that should work just fine and print "blah" in each of the fields. I am not sure why your print service is timing out. You can check your ArcGIS Server Logs to see if there is a clue there. Getting certain attributes associated with the object being printed varies. If it is a certain feature of a certain layer that is selected/highlighted then you have to go to that layer in code and get the selected feature and then that features attributes and assign those attribute variables to the code block I provided.

Claire_Peterson
Occasional Contributor

Thank you Robert - I will look into the logs to see if I can figure out what is going on. I certainly appreciate your time helping me with this matter. 

0 Kudos
by Anonymous User
Not applicable

Hi Claire,

It seems you have multiple issues encountering for this at the moment.

I believe

1. you want to achieve multiple printing from the array variable input.

2. Currently you are encountering time out issue

3. You can't pass your variable data into print param

So lets do it one step by another

Let solve item 2 first by going to developer mode in the browser about the print task request, 

1. Check how long does it take and what is the return

If it is really timeout and if you are using arcgis server for windows with IIS web adapter. You might want to increase the request timeout by changing web.config. (executionTimeout to be increased)

Below is the sample -

<configuration>

<system.web>

<httpRuntime maxRequestLength="40000" enable = "True" requestLengthDiskThreshold="512 executionTimeout="450" />

</system.web>

</configuration>

Next step : Please solve item 3, pass the variable and test, check the parameters and print template

Last one : you might need to use deferred and promise dojo object to run print task paralleled.

Claire_Peterson
Occasional Contributor

Hi Than Aung‌, thank you for your reply! We had started to go a different direction to see if using the REST API could accomplish something similar to what we have been looking for but we have not made much progress - so we are headed back down the API for JavaScript route. I will have to dig a little deeper into the time out information, we decided to implement a simple print button that opens the generic Windows print screen to save to PDF for the time being so some sections of the code need to be uncommented to test.

I seem to still be a bit lost on passing the variables - in my php code they are $array[#] with the # representing the different columns. I could potentially capture them from the actual feature layer using something similar to graphic.attributes.<attribute name>

For the template I had published there doesn't seem to be much information on what exactly needs to be in the text box or are they kept empty? I usually only see the window that shows the spot to type in the element name.

Thank you for the information about the deferred and promise dojo object - I will have to take another look at this.

0 Kudos
by Anonymous User
Not applicable

Hi Claire,

For parameter passing issue, how about try and use the postman and manually pass the value and test first.

Best Regards,

0 Kudos