1

I am working with data driven pages. In data driven object attributes I have one attribute column with page order (index), another with page name.

Is there a way to get file name like: %Page order%_Some-text_%Page index%.pdf?

Export Map menu

  • 2
    Have you considered creating another field for page name that combines your other fields? – Midavalo Feb 1 '17 at 18:50
  • It's kind of workaround. Page name is fixed for certain extent but index is connected to way PDF's are related between. – vldmrnnc Feb 1 '17 at 18:54
0

You will need to write a python script to do what you want. Here is a sample (I haven't tested it, but I've done these many times.) Page_order is the attribute name in the DDP index layer Page_index is the other attribute with the name.

import arcpy
strOutpath = "C:/Temp/"
try:
    mxd = arcpy.mapping.MapDocument(strPath + strMXD + ".mxd")
    for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
        mxd.dataDrivenPages.currentPageID = pageNum
        pageorder = mxd.dataDrivenPages.pageRow.Page_order
        pageindex = mxd.dataDrivenPages.pageRow.Page_index
        pdfname = pageorder + "_Some-text_" + pageindex + ".pdf"      
        arcpy.mapping.ExportToPDF(mxd, strOutpath  + pdfname)
    del mxd

except:
    print "An error has occurred"
0
  1. I have added "CURRENT" to arcpy.mapping.MapDocument because it caused error.
  2. strOutpath, FIELD1 and FIELD2 can be modified.
  3. field1 & 2 are fields from layer attribute table that is used for DDP.
  4. Both fields MUST be text field.
     import arcpy
        strOutpath = "C:/temp/"
        mxd = arcpy.mapping.MapDocument("CURRENT")
        for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
         mxd.dataDrivenPages.currentPageID = pageNum
         pageorder = mxd.dataDrivenPages.pageRow.FIELD1
         pageindex = mxd.dataDrivenPages.pageRow.FIELD2
         pdfname = pageorder + pageindex + ".pdf"     
         arcpy.mapping.ExportToPDF(mxd, strOutpath  + pdfname)
        del mxd

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.