I regularly use an export script to create multi-page PDFs from Data-Driven-Pages based Map-books. I am able to export and append each individual page to the PDF, and save the PDF in the single-page layout with the "Page Thumbnails" pane opened. I need to be able to (Pythonically) set the Bookmark text for each page within the PDF. I can do this manually from Adobe, but it would save a lot of time and headache if it could be automated.
Here is the script I use, at its most basic level without any bells or whistles. At the bottom of the script is where I set the page-layout (pdf_open_view="USE_THUMBS"
). I can use "USE_BOOKMARKS"
but this doesn't actually apply any bookmark text to the individual pages.
import arcpy, os
mxdPath = r"C:\temp\MyMapBook.mxd"
tempMap = arcpy.mapping.MapDocument(mxdPath)
tempDDP = tempMap.dataDrivenPages
outDir = r"C:\temp" #PDF Folder where the individual pages and Combo are created
comboPDF = r"\MultiPage_PDF.pdf" #Name of Combo PDF
finalpdf_filename = os.path.join(outDir + comboPDF)
finalPdf = arcpy.mapping.PDFDocumentCreate(finalpdf_filename)
for pgIndex in range(1, tempDDP.pageCount + 1):
tempDDP.currentPageID = pgIndex
figName = str(tempDDP.pageRow.sdsFeatureName)
figNumber = str(tempDDP.pageRow.Fig_Num_2015FSP)
pageName = "Page-" + figNumber + "_" + figName + ".pdf"
individualPagePDF = os.path.join(outDir + "\\" + pageName)
#do something to the page before exporting. e.g. add inset map, add table etc.
###################################################################
tempDDP.exportToPDF(individualPagePDF, "CURRENT") # export to signle page PDF
finalPdf.appendPages(individualPagePDF) # append the page to the "combo" PDF
print pageName + " added to final mapbook pdf"
###################################################################
#undo whatever page modifications you just did before the export
##### Delete Objects
del tempMap, tempDDP
finalPdf.updateDocProperties(pdf_open_view="USE_THUMBS",pdf_layout="SINGLE_PAGE")
finalPdf.saveAndClose()