<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Print task causes severe ArcGIS for Server log messages in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-causes-severe-arcgis-for-server-log/m-p/621857#M58065</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe it has something to do with the setup of your proxy. &amp;nbsp;In my application that was started from an ESRI sample the proxy was:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;esriConfig.defaults.io.proxyUrl = /proxy (Shorthand for ESRI's proxy)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which I changed to:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://tgarcgis00/Proxy/proxy.ashx" title="http://tgarcgis00/Proxy/proxy.ashx"&gt;http://"MyServerName"/Proxy/proxy.ashx&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your sample has a proxy:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="background-color: #ffffff; border: 0px;"&gt;"http://ourwebserver/Java/proxy.jsp";&lt;/PRE&gt;&lt;P&gt;Did you use that same proxy when the application was using the out of the box print widget?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 17 Jan 2017 19:43:44 GMT</pubDate>
    <dc:creator>MichaelVolz</dc:creator>
    <dc:date>2017-01-17T19:43:44Z</dc:date>
    <item>
      <title>Print task causes severe ArcGIS for Server log messages</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-causes-severe-arcgis-for-server-log/m-p/621854#M58062</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've tried to implement a print widget using the print task very closely following this &lt;A href="http://server.arcgis.com/fr/server/latest/publish-services/linux/gp-service-example-advanced-high-quality-webmap-printing.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;tutorial&lt;/A&gt;. However, it is very slow (~60 seconds to export an A3 pdf with default dpi) and I notice the following severe ArcGIS for Server logs:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="304111" alt="" class="image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/304111_severe_log.png" style="width: 620px; height: 169px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Has anyone seen this type of vague log?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;The python script used:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

import arcpy
import os
import uuid

# The template location in the registered folder (as UNC path)
templatePath = '//ourserver/ourtemplatepath

# Input WebMap json
Web_Map_as_JSON = arcpy.GetParameterAsText(0)

# Format for output
Format = arcpy.GetParameterAsText(1)
if Format == '#' or not Format:
 Format = "PDF"

# Input Layout template
Layout_Template = arcpy.GetParameterAsText(2)
if Layout_Template == '#' or not Layout_Template:
 Layout_Template = "A3 Paysage"

# Extra parameter - georef_info
Georef_info = arcpy.GetParameterAsText(3)
if Georef_info == '#' or not Georef_info:
 Georef_info = "False"

# Convert Georef_info string to boolean
if Georef_info.lower() == 'false':
 Georef_info_bol = False
elif Georef_info.lower() == 'true':
 Georef_info_bol = True

# Get the requested map document
templateMxd = os.path.join(templatePath, Layout_Template + '.mxd')

# Convert the WebMap to a map document
result = arcpy.mapping.ConvertWebMapToMapDocument(Web_Map_as_JSON, templateMxd)
mxd = result.mapDocument

# Reference the data frame that contains the webmap
# Note: ConvertWebMapToMapDocument renames the active dataframe in the template_mxd to "Webmap"
df = arcpy.mapping.ListDataFrames(mxd, 'Webmap')[0]

# ConvertWebMapToMapDocument renames the active dataframe in the template_mxd to "Webmap".
# Lets rename it to something more meaningful.
df.name = Layout_Template




# Use the uuid module to generate a GUID as part of the output name
# This will ensure a unique output name
output = 'WebMap_{}.{}'.format(str(uuid.uuid1()), Format)
Output_File = os.path.join(arcpy.env.scratchFolder, output)




# Export the WebMap
if Format.lower() == 'pdf':
 arcpy.mapping.ExportToPDF(mxd, Output_File, georef_info=Georef_info_bol)
elif Format.lower() == 'png':
 arcpy.mapping.ExportToPNG(mxd, Output_File)




# Set the output parameter to be the output file of the server job
arcpy.SetParameterAsText(4, Output_File)




# Clean up - delete the map document reference
filePath = mxd.filePath
del mxd, result
os.remove(filePath)&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;The javascript used to export the maps:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

require([
 "esri/layers/FeatureLayer",
 "esri/dijit/Print",
 "esri/tasks/PrintTemplate",
 "esri/tasks/PrintTask",
 "esri/tasks/PrintParameters",
 "esri/tasks/GeometryService",
 "esri/tasks/ProjectParameters",
 "esri/geometry/Point",
 "esri/SpatialReference",
 "esri/request",
 "esri/config",
 "dijit/registry",
 "dijit/form/ComboBox",
 "dijit/form/Button",
 "dijit/form/CheckBox",
 "dojox/form/BusyButton",
 "dojo/store/Memory",
 "dojo/_base/array",
 "dojo/dom",
 "dojo/on"
], function(
 FeatureLayer,
 Print, PrintTemplate,
 PrintTask, PrintParameters,
 GeometryService,
 ProjectParameters,
 Point, SpatialReference,
 esriRequest, esriConfig, registry,
 ComboBox, Button, CheckBox, BusyButton, Memory,
 arrayUtils, dom, on
) {
 
 //var printUrl = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task";
 var printUrl = "http://ouragsserver/arcgis/rest/services/SPE_Tools/SPE_Print_Tool_Adv/GPServer/Script";
 
 esriConfig.defaults.io.proxyUrl = "http://ourwebserver/Java/proxy.jsp";
 esri.config.defaults.io.timeout = 300000; //60 seconds = 60000
 
 setScalesCombo();
 
 var scaleCheckBox = new CheckBox({
 checked: false,
 onChange: function (val) {
 //dom.byId('one').innerHTML = val ? 'checked' : 'unchecked';
 if (scaleCheckBox.checked) {
 //params.template.preserveScale = true;
 dijit.byId("scale_select").attr("disabled",false);
 console.log("checked");
 }
 else {
 //params.template.preserveScale = false;
 dijit.byId("scale_select").attr("disabled",true);
 console.log("unchecked");
 }
 }
 }, 'scale_check');
 
 
 var printButton = new BusyButton({
 busyLabel: "Impression...",
 label: "Imprimer",
 timeout: 50000,
 onClick: printMap
 }, "print_button_bis").startup();
 
 
 function printMap(){
 var printMap = new esri.tasks.PrintTask(printUrl);
 var params = new esri.tasks.PrintParameters();
 var template = new esri.tasks.PrintTemplate();
 document.getElementById("print_status").innerHTML = "Impression en cours...";
 document.getElementById("output_url").innerHTML = "";
 
 var layout = dojo.byId("printLayoutId");
 var index = layout.selectedIndex;
 var selectedValue_layout = layout.options[index].value;
 var format = dojo.byId("format");
 var index = format.selectedIndex;
 var selectedValue_format = format.options[index].value;
 
 
 var lat = window.myMap.extent.getCenter().getLatitude().toFixed(2);
 var long = window.myMap.extent.getCenter().getLongitude().toFixed(2);
 
 var latLong = "Latitude : " + lat + " - Longitude : " + long;
 
 var X;
 var Y;
 
 var rgpfSixSudSR = new SpatialReference ({
 wkid : 3297
 });
 
 var wgsGCSEightFourSR = new SpatialReference ({
 wkid : 4326
 });
 
 var geometryService = new GeometryService("http://ourserver/arcgis/rest/services/Utilities/Geometry/GeometryServer");
 var inputPoint = new Point(lat, long, wgsGCSEightFourSR);
 var prjParams = new ProjectParameters ();
 prjParams.geometries = [inputPoint];
 prjParams.outSR = rgpfSixSudSR;
 
 geometryService.project(prjParams, function (outputpoint) {
 console.log('Conversion completed');
 X = outputpoint[0].x;
 Y = outputpoint[0].y;
 //console.log('X : ' + X ' and Y : ' + Y);
 
 });
 
 var center = "X : " + X + " - Y : " + Y;
 
 //params.template.layoutOptions.customTextElements.centerLatLong = latLong;
 //params.template.layoutOptions.customTextElements.centerXY = center;
 
 console.log(latLong);
 console.log(center);
 
 
 params.map = window.myMap;
 
 if (scaleCheckBox.checked) {
 params.template = {
 layout: selectedValue_layout,
 format: selectedValue_format,
 preserveScale: true,
 layoutOptions: {
 customTextElements : [
 {
 centerLatLong: latLong
 }
 // {
 // centerXY: center
 // }
 ]
 // legendLayer: [legendLayer]
 }
 }
 console.log("checked");
 }
 else {
 params.template = {
 layout: selectedValue_layout,
 format: selectedValue_format,
 preserveScale: false,
 layoutOptions: {
 customTextElements : [
 {
 centerLatLong: latLong
 }
 // {
 // centerXY: center
 // }
 ]
 // legendLayer: [legendLayer]
 }
 }
 console.log("unchecked");
 }
 
 
 
 //window.myMap.on('extent-change', showExtent());
 
 
 
 printMap.execute(params, printResult);
 
 // dojo.connect(printMap,'onComplete',function(result){
 // window.open(result.url);
 // })
 
 
 function printResult(result){
 console.log(result.url);
 document.getElementById("print_status").innerHTML = "";
 document.getElementById("output_url").href = result.url;
 document.getElementById("output_url").innerHTML = "Impression";
 var printWindow = window.open(result.url);
 
 
 };
 };
 
 function setScalesCombo() {
 var scaleStore = new Memory({
 data: [
 {name:"100", id:"100"},
 {name:"200", id:"200"},
 {name:"500", id:"500"},
 {name:"1000", id:"1000"},
 ]
 });
 
 var scaleSelect = new ComboBox({
 id: "scale_select",
 style: {width: "150px"},
 name: "scale_select",
 placeHolder: "Choisir une échelle",
 store: scaleStore,
 disabled: true,
 onChange: function(value){
 //document.getElementById("value").innerHTML = value;
 mapScale = value;
 window.myMap.setScale(mapScale);
 }
 }, "scale_select");
 scaleSelect.startup();
 }
 
});&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;Added to html body like this:&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="title:'Impressions'"&amp;gt;

&amp;lt;select name="printLayout" id="printLayoutId"&amp;gt;
 &amp;lt;option value="A3_paysage"&amp;gt;A3 Paysage&amp;lt;/option&amp;gt;
 &amp;lt;option value="A3_portrait"&amp;gt;A3 Portrait&amp;lt;/option&amp;gt;
 &amp;lt;option value="A4_paysage"&amp;gt;A4 Paysage&amp;lt;/option&amp;gt;
 &amp;lt;option value="A4_portrait"&amp;gt;A4 Portrait&amp;lt;/option&amp;gt;
 &amp;lt;!-- &amp;lt;option value="Letter ANSI A Landscape" selected&amp;gt;Letter ANSI A Landscape&amp;lt;/option&amp;gt;
 &amp;lt;option value="Letter ANSI A Portrait"&amp;gt;Letter ANSI A Portrait&amp;lt;/option&amp;gt;
 &amp;lt;option value="Tabloid ANSI B Landscape"&amp;gt;Tabloid ANSI B Landscape&amp;lt;/option&amp;gt;
 &amp;lt;option value="Tabloid ANSI B Portrait"&amp;gt;Tabloid ANSI B Portrait&amp;lt;/option&amp;gt; --&amp;gt;
 &amp;lt;/select&amp;gt;
 &amp;lt;br&amp;gt;
 &amp;lt;select id="format"&amp;gt;
 &amp;lt;OPTION value="PDF"&amp;gt;PDF&amp;lt;/OPTION&amp;gt;
 &amp;lt;OPTION value="PNG"&amp;gt;PNG&amp;lt;/OPTION&amp;gt;
 &amp;lt;/select&amp;gt;
 &amp;lt;br&amp;gt;
 &amp;lt;br&amp;gt;
 &amp;lt;!-- &amp;lt;input type="checkbox" id="check_scales" checked
 data-dojo-type="dijit/form/CheckBox"
 data-dojo-props="checked: true"&amp;gt; --&amp;gt;
 &amp;lt;div id="scale_check"&amp;gt;&amp;lt;/div&amp;gt;
 &amp;lt;label for="scale_check"&amp;gt;Imprimer à l'échelle&amp;lt;/label&amp;gt;

&amp;lt;div id="scale_select" class="comboClass"&amp;gt;&amp;lt;/div&amp;gt;

&amp;lt;button id="print_button_bis" type="button"&amp;gt;&amp;lt;/button&amp;gt;
 &amp;lt;p id="print_status"&amp;gt;&amp;lt;/p&amp;gt;
 &amp;lt;a id="output_url" href="#"&amp;gt;&amp;lt;/a&amp;gt;
 &amp;lt;!--&amp;lt;input type="button" id="print" value = "Print" onclick="printMap();"/&amp;gt;--&amp;gt;


 &amp;lt;/div&amp;gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:42:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-causes-severe-arcgis-for-server-log/m-p/621854#M58062</guid>
      <dc:creator>NhuMai</dc:creator>
      <dc:date>2021-12-12T16:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: Print task causes severe ArcGIS for Server log messages</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-causes-severe-arcgis-for-server-log/m-p/621855#M58063</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you trying to print complex data (vector data with many vertices or imagery)? &amp;nbsp;If so, you might want to try testing on a simpler data set and see how long it takes to print that out in comparison?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jan 2017 18:49:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-causes-severe-arcgis-for-server-log/m-p/621855#M58063</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2017-01-17T18:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: Print task causes severe ArcGIS for Server log messages</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-causes-severe-arcgis-for-server-log/m-p/621856#M58064</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It does seem to take less time when removing layers--understandable. However, the end user will need to print about as much as I'm testing, plus, I hadn't noticed this slowness when using the out of the box print widget on the same amount of layers. I think there's something wrong with the gp script, but I'm not sure where to start looking considering the vague error message.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jan 2017 19:24:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-causes-severe-arcgis-for-server-log/m-p/621856#M58064</guid>
      <dc:creator>NhuMai</dc:creator>
      <dc:date>2017-01-17T19:24:58Z</dc:date>
    </item>
    <item>
      <title>Re: Print task causes severe ArcGIS for Server log messages</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-causes-severe-arcgis-for-server-log/m-p/621857#M58065</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe it has something to do with the setup of your proxy. &amp;nbsp;In my application that was started from an ESRI sample the proxy was:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;esriConfig.defaults.io.proxyUrl = /proxy (Shorthand for ESRI's proxy)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;which I changed to:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://tgarcgis00/Proxy/proxy.ashx" title="http://tgarcgis00/Proxy/proxy.ashx"&gt;http://"MyServerName"/Proxy/proxy.ashx&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your sample has a proxy:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="background-color: #ffffff; border: 0px;"&gt;"http://ourwebserver/Java/proxy.jsp";&lt;/PRE&gt;&lt;P&gt;Did you use that same proxy when the application was using the out of the box print widget?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Jan 2017 19:43:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/print-task-causes-severe-arcgis-for-server-log/m-p/621857#M58065</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2017-01-17T19:43:44Z</dc:date>
    </item>
  </channel>
</rss>

