Exporting Data Driven Pages to EPS using Python

3414
12
10-20-2010 02:18 PM
TomFlahive
New Contributor III
Currently in ArcGIS 10 you can export all of the pages of a data driven pages map book to .pdf format.  Unfortunately, you cannot do the same thing when exporting to .eps format or any of the other export formats (not sure why).  Is there a way to us python to iterate through the individual pages of a data driven pages map book so that each page can be exported to .eps one by one?
0 Kudos
12 Replies
malcolmgreer
New Contributor
I have this running but wondering if anyone has it running for selected pages ?


@Kay:  He's referring to the option to set jpeg quality when scripting the export in Python.  My colleagues have had success running this one, with no negative image results:

mxd = arcpy.mapping.MapDocument("CURRENT")
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
  mxd.dataDrivenPages.currentPageID = pageNum
  arcpy.mapping.ExportToEPS(mxd, r"C:\Temp\Map_Page" + str(pageNum) + ".eps", image_quality="BETTER", image_compression="DEFLATE", picture_symbol="RASTERIZE_PICTURE", convert_markers=True, embed_fonts=False, jpeg_compression_quality=1)
del mxd

However, when I run the ExportToEPS code with the "jpeg_compression_quality=1" option, I get the following error message: 

Runtime error <type 'exceptions.TypeError'>: ExportToEPS() got an unexpected keyword argument 'jpeg_compression_quality'

My colleagues are running Adobe Acrobat Standard 8 and I am running Adobe Acrobat Standard 9, so that may be where the disparity lies.  I modified the script to be built into a tool with output variables, and omitted the "jpeg_compression_quality" option and it works very well for me (no negative images):

# Import ArcPy site-package and os modules
#
import arcpy
import os
# Set the output workspace
#
outWorkspace = arcpy.GetParameterAsText(0)
# Set the output map name
#
mapname = arcpy.GetParameterAsText(1)
# Tell ArcMap to use the current MXD
#
mxd = arcpy.mapping.MapDocument("CURRENT")
# Execute dataDrivenPages
#
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
  mxd.dataDrivenPages.currentPageID = pageNum
  arcpy.mapping.ExportToEPS(mxd, outWorkspace + str(mapname) + str(pageNum) + ".eps", image_quality="BETTER", image_compression="DEFLATE", picture_symbol="RASTERIZE_PICTURE", convert_markers=True)
del mxd

Search on "ExportToEPS" in ArcGIS 10 Help to get the breakdown of the syntax and all output options.  You'll notice that the "jpeg_compression_quality" option is not mentioned in there...
0 Kudos
JeffBarrette
Esri Regular Contributor
At 10.0 you will have to manage the selection yourself.  You will need to run a loop on your rows, create a list of pagenames or numbers and step through each DDP page using that list.  Similar to the help sample provided in this thread.

At 10.1, we added a DDP.selectedPages property that will return a list of index numbers automatically.

Jeff
0 Kudos
malcolmgreer
New Contributor
Thanks Jeff,

What I am doing now is just selecting the pages from the attribute table I have and then exporting them as pdfs. Then I use the reduce pdf size utlity in adobe once I have all my maps exported. 

Guess this will work for now...
0 Kudos