rkeightley

Data driven pages - exporting multiple PNG by page name

Discussion created by rkeightley on Jun 13, 2013
Latest reply on Jul 16, 2013 by jimcousins
Hi,

It took me a long time of searching forums to work out how to export mutliple data driven pages to a format other than PDF, using the page name in the file name (instead of the page number).

My page names also included characters that file naming won't accept (e.g "/"), and I wanted to remove spaces.  I was exporting to PNG.

Here's the script if anyone else has the same problem.

mxd = arcpy.mapping.MapDocument("CURRENT")
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
  mxd.dataDrivenPages.currentPageID = pageNum
  pageName = mxd.dataDrivenPages.pageRow.Name
  pageName = pageName.replace("/", "_")
  pageName = pageName.replace(" ", "")
  arcpy.mapping.ExportToPNG(mxd, r"C:\temp\" + pageName + ".png")
del mxd

Outcomes