Select to view content in your preferred language

Exporting DDP to field based named PDF

3539
0
03-13-2015 06:51 AM
BartonGriesenauer
Emerging Contributor

First let me say I am not versed in python....with that being said I have tried many sample codes of python and have not had any luck.

I am trying to create roughly 127,000 cover pages.  I want the pdf name to come from our PARCELNO field, for example  0101010000001000.pdf.

We are having no luck.  Is there not a simple way to have python choose the parcel number from the PARCELNO field and export that to a pdf? I apologize in advance if this a simplistic question.

>>> mxd = arcpy.mapping.MapDocument("CURRENT")

... for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):

...   mxd.dataDrivenPages.currentPageID = pageNum

...   arcpy.mapping.ExportToPDF(mxd, r"C:\Users\bpg\Desktop\\" + str(pageNum) + ".pdf")

... del mxd

So the code exports but as 1.pdf, 2.pdf and so on.

In the Set Up Data Driven Pages window I have choose PARCELNO as my Page Number from the drop down.

I feel like we are close any suggestions.

Update

Below is the script that correctly exported our pdf files.

>>>

... import arcpy

... mxd = arcpy.mapping.MapDocument("CURRENT")

... ddp = mxd.dataDrivenPages

... for pageNum in range(1, ddp.pageCount + 1):

...     mxd = arcpy.mapping.MapDocument("CURRENT")

...     ddp = mxd.dataDrivenPages

...     ddp.currentPageID = pageNum

... arcpy.mapping.ExportToPDF(mxd, r"U:\Bart\test\\" + ddp.pageRow.getValue(ddp.pageNameField.name) + ".pdf")

...     del mxd

Just posting this in case anyone else needs the same script.

Tags (1)
0 Kudos
0 Replies