Skip to main content
3 of 3
replaced http://gis.stackexchange.com/ with https://gis.stackexchange.com/

I had a similar problem with this question: Creating bookmarked PDF from export script

The following script will export an MXD to PDF, and modify the PDFs properties (via output.addMetadata) using the PyPDF2 module.

import sys
sys.path.insert(0, r"H:\NetworkShared_PythonModules")
import PyPDF2, os, arcpy

mxdPath = r"C:\temp\MyMap.mxd"
mxd = arcpy.mapping.MapDocument(mxdPath)
PDFPath = r"C:\temp\MyPDF.pdf"
arcpy.mapping.ExportToPDF(mxd, PDFPath)

output = PyPDF2.PdfFileMerger()

bookMarkText = "Insert BookMark Text Here"
inputPage = PyPDF2.PdfFileReader(open(PDFPath, 'rb'))
output.addMetadata({u'/Keywords': u'Path to MXD' + mxdPath, u'/Author': u'UserName'})              
output.append(inputPage, bookMarkText)

outputStream = file(PDFPath, "wb")
output.write(outputStream)
outputStream.close()
del outputStream, output, mxd, inputPage

I haven't tried, but I'm sure this could be done in a loop with several MXDs.

Keggering
  • 1.1k
  • 1
  • 8
  • 26