High Quality Printing with ArcPy

Jan 24, 2012   //   by admin   //   How to, Other  //  No Comments
Not UsefulUseful (No Ratings Yet)
Loading ... Loading ...

With some minor tweaks to the existing ArcPy print sample for Dekho, you can point the script at your source data as opposed to the map services that have references to the source data.

This not only improves the quality (as the map services ‘rasterise’ the raw data), but also dramatically speeds up the process.

 

For a 600DPI print at A1 using the standard ArcPy print sample for Dekho (via map services) = 1 minute

 

Same again, but the ArcPy pointing to the data in a local File-GDB = 20s

Please see this screen-cast on how to make the necessary changes:

Another plus point, is that the output PDFs will also allow the end-user to turn layers on/off via the PDF.  You can also tweak the script to allow users to identify attributes and get coordinates from the PDFs.

The code snippet you need to change within the existing ArcPy Sample for Dekho printing is this.  Watch the video for details on the changes.

# --------------------------------------------------------------------------------
# Create a temporary print layout based on the map document given for printing,
# the layout mxd and the visible layers selected for printing.
# --------------------------------------------------------------------------------
def createPrintMap(sourcMxdPath, layoutMxdPath, visibleLayers):
 arcpy.AddMessage("Creating print layout")
 arcpy.AddMessage("Jerome Test")

 # Load source MXD
 #sourceMxd = arcpy.mapping.MapDocument(sourcMxdPath)
 #sourceDf = arcpy.mapping.ListDataFrames(sourceMxd, "Layers")[0]

 # Load print layout MXD
 layoutMxd = arcpy.mapping.MapDocument(layoutMxdPath)
 layoutDf = arcpy.mapping.ListDataFrames(layoutMxd, "Layers")[0]

 lyrCount = 1
 for lyr in arcpy.mapping.ListLayers(layoutMxd, "", layoutDf):
 try:
 visibleLayers.index(repr(lyrCount))
 # Layer is in the visible layers list.
 lyr.visible = True
 except Exception:
 lyr.visible = False
 pass
 #arcpy.mapping.AddLayer(layoutDf, lyr, "BOTTOM") # values could be AUTO_ARRANGE, BOTTOM, TOP
 lyrCount += 1

 # Get random filename to save the temporay print file.
 printTemplate = getTempFile("DekhoPrint_","mxd")

 # Save the template file in the scratch workspace.
 layoutMxd.saveACopy(printTemplate)

 return printTemplate

Leave a comment


five + = 14