Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Naming a created PDF with the DDP title

$
0
0
Good Day,

Ok so first I'm a very fresh beginner to Python and using it to help automate my map book creation.

Here is what I am looking to do.

I have several mxd files (one for left page, one for right page). I can currently use python to export each page in the map book, using DataDriven pages, to a pdf for each page.

I'm looking for a way to tell my stand alone script to name each page dependent on the name being used to sort the data driven pages.

Code:

mxdPathLeft = r"C:\MappingTemp\NorthFAC.mxd"
tempMapLeft = arcpy.mapping.MapDocument(mxdPathLeft)
tempDDPLeft = tempMapLeft.dataDrivenPages

# Loop creates individual pdf's for odd numbered pages
#
for pgNumLeft in range(1, tempDDPLeft.pageCount + 1):
  temp_filename = r"C:\MappingTemp\temp_pdfs\North_" + \
                            str(pgNumLeft) + "_FAC.pdf"
  if os.path.exists(temp_filename):
    os.remove(temp_filename)
  tempDDPLeft.exportToPDF(temp_filename, "RANGE", pgNumLeft)

Is what I have for naming the files currently. I though I could just change the str(pgNumLeft) to str(tempMapLeft.title) but it just causes the script to hang and not do anything.

Viewing all articles
Browse latest Browse all 2485

Trending Articles