Select to view content in your preferred language

Printing in ArcPy??

671
2
12-16-2010 03:11 AM
JoshV
by
Regular Contributor
I saw the blog post below suggesting that a Geoprocessing Service could be created to utilize ArcPy and the Printer Settings but I still have many questions.  Is a PDF produced or is the print sent straight to the printer?  Some of the parameters seem to want to point to the actual MXD and actual printer so could I use a URL to the MXD and printer?  What would help me the most is if anyone has one complete sample of what this script should look like? I would just need one print size in the example code not all of them for simplisity sake.

http://blogs.esri.com/Dev/blogs/arcgisdesktop/archive/2010/02/01/ArcPy-and-Geoprocessing_2620_-it_19...
0 Kudos
2 Replies
ChrisMathers
Deactivated User
If a parameter wants the MXD you need to create an MXD object with the "CURRENT" path so that the print functions know that you want to use the MXD that is open at the moment. The print could be sent to either a printer or to PDF depending on what you want to happen. I havnt written anything like this for a service but it isnt complicated to do from the desktop environment.
0 Kudos
JoshV
by
Regular Contributor
If a parameter wants the MXD you need to create an MXD object with the "CURRENT" path so that the print functions know that you want to use the MXD that is open at the moment. The print could be sent to either a printer or to PDF depending on what you want to happen. I havnt written anything like this for a service but it isnt complicated to do from the desktop environment.


Do you see any problems with my below code??

import sys, arcpy

arcpy.env.overWriteOutput = True

mxdTemplate = "CURRENT" #or a different mxd

outWs = "D:\\GIS Data\\arcgisserver\\arcgisoutput" #can really be any directory

outFileName = "print_service_output.pdf"

ext = arcpy.Extent(-96.597, 34.742, -96.225, 35.055)

outFilePath = outWs + "\\" + outFileName

mxdTemplateObject = arcpy.mapping.MapDocument(mxdTemplate)

df = arcpy.mapping.ListDataFrames(mxdTemplateObject)[0]

df.extent = ext

arcpy.mapping.ExportToPDF(mxdTemplateObject, outFilePath)
0 Kudos