Summary
Returns a reference to an existing PDFDocument file on disk.
Discussion
A common scenario for using this function is to modify existing PDF file contents or properties. Once a is referenced, you can appendPages, insertPages, or deletePages, as well as use the updateDocProperties and updateDocSecurity methods to modify PDF file settings.
For your changes to be committed to disk, be sure to call saveAndClose after performing the PDFDocument operations.
Syntax
PDFDocumentOpen (pdf_path, {user_password}, {master_password})
Parameter | Explanation | Data Type |
pdf_path | A string that specifies the path and file name of the PDF file to open. | String |
user_password | A string that specifies the user password. The user password, if set, is what you need to provide in order to open a PDF. | String |
master_password | A string that specifies the master password. The master password, if set, controls permissions, such as printing, editing, extracting, commenting, and so on. | String |
Data Type | Explanation |
PDFDocument | The PDFDocument object allows for the management of PDF documents, including facilities for merging and deleting pages, setting document open behavior, and creating or changing document security settings. |
Code sample
The following script modifies the PDF document metadata properties and sets the style in which the document will open.
import arcpy
pdfDoc = arcpy.mp.PDFDocumentOpen(r"C:\Projects\YosemiteNP\AttractionsMapBook.pdf")
pdfDoc.updateDocProperties(pdf_title="Yosemite Main Attrations Map Book",
pdf_author="Esri",
pdf_subject="Main Attractions Map Book",
pdf_keywords="Yosemite; Map Books; Attractions",
pdf_open_view="USE_THUMBS",
pdf_layout="SINGLE_PAGE")
pdfDoc.saveAndClose()
del pdfDoc