AnsweredAssumed Answered

Weird Symbology Conversion with Print Task

Question asked by jopethemetalmessiah on Nov 3, 2014

Hi,

 

I am using a python GP service to run a print task to PDF with custom layouts.  This works great, except when i have any map service enabled in the map.  The layer in the resulting PDF displays jumbo sized points, and I cannot figure out why or what to change. Thanks in advance for any advice!

 

web_map_example.png

 

Javascript

printTask = new esri.tasks.PrintTask(printUrl, { //new instance of print job                     async: false //our service is set to syncronous                 });                 params = new esri.tasks.PrintParameters(); //placeholder for our parameters to put in the script                 params.map = map; //reference to the active map object                 function print(){ //action to run when submit is clicked                     dojo.style(dijit.byId("statusDialog").closeButtonNode, "display", "none");                                          document.getElementById("printStatus").innerHTML = " Converting to PDF <img src='loader.gif'>";                                          var title = dijit.byId("title").get("value") //parameter[2]                                          var subtitle = dijit.byId("subtitle").get("value") //parameter[3]                                          var agent = dijit.byId("agent").get("value") //parameter[4]                                          var legendLayer = new esri.tasks.LegendLayer();                                                               params.template = {                         layout: mxdTemplate,                         format: 'PDF',                         preserveScale: false,                         layoutOptions: {                             legendLayers: []                         }                     };                      params.outSpatialReference = map.spatialReference                                          params.extraParameters = {                         Title: title,                         Subtitle: subtitle,                         Agent: agent                     }; //the custom parameters for the python script                     printTask.execute(params, printComplete, printError); //run the task, completion triggers 'printComplete' function, any error triggers printError                 }                                  function printComplete(result){                     dojo.style(dijit.byId("statusDialog").closeButtonNode, "display", "block");                     console.log(result.url);                     document.getElementById("printStatus").innerHTML = "<a href='" + result.url + "' target='_blank'><b>Download PDF<b></a>" //link to the PDF                 }                                  function printError(error){                     dojo.style(dijit.byId("statusDialog").closeButtonNode, "display", "block");                     document.getElementById("printStatus").innerHTML = "An unexpected Error has occured <br>( " + error + " )<br> try saving again" //error warning popup                 }

 

Python GP service

import arcpy import os import uuid   # Param 0 = INPUT JSON STRING # Param 1 = OUTPUT FILE # Param 2 = Layout Template # Param 3 = Title # Param 4 = Subtitle # Param 5 = Agent   # Input WebMap json Web_Map_as_JSON = arcpy.GetParameterAsText(0)  # The template location in the server data store templateMxd = arcpy.GetParameterAsText(2)    title = arcpy.GetParameterAsText(3)   subtitle = arcpy.GetParameterAsText(4)     agent = arcpy.GetParameterAsText(5) # 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]   for elem in arcpy.mapping.ListLayoutElements(mxd,"TEXT_ELEMENT"):                 if elem.name == "Title":                     elem.text = title                                      elif elem.name == "Subtitle":                     elem.text = subtitle                                      elif elem.name == "Agent":                     elem.text = agent  # Use the uuid module to generate a GUID as part of the output name # This will ensure a unique output name output = 'WebMap_{}.pdf'.format(str(uuid.uuid1())) Output_File = os.path.join(arcpy.env.scratchFolder, output)   # Export the WebMap arcpy.mapping.ExportToPDF(mxd, Output_File)    # Set the output parameter to be the output file of the server job arcpy.SetParameterAsText(1, Output_File)   # Clean up - delete the map document reference filePath = mxd.filePath del mxd, result os.remove(filePath)

Outcomes