サマリー
Creates a new PDFDocument object in memory.
説明
A common scenario for using this function is the creation of a PDF map book. The steps typically involve creating a new PDFDocument object, appending content from existing PDF files, and saving the PDFDocument object to disk.
A file will not be created until you either appendPages or insertPages to the PDFDocument object and execute saveAndClose.
構文
PDFDocumentCreate (pdf_path)
パラメーター | 説明 | データ タイプ |
pdf_path | A string that specifies the path and file name for the resulting PDF file when the saveAndClose method is called. | String |
データ タイプ | 説明 |
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. |
コードのサンプル
This script will create a new PDF document, append the contents of three separate PDF documents, and save the resulting PDF file.
import arcpy, os
#Set file name and remove if it already exists
pdfPath = r"C:\Projects\YosemiteNP\AttractionsMapBook.pdf"
if os.path.exists(pdfPath):
os.remove(pdfPath)
#Create the file and append pages
pdfDoc = arcpy.mp.PDFDocumentCreate(pdfPath)
pdfDoc.appendPages(r"C:\Projects\YosemiteNP\Title.pdf")
pdfDoc.appendPages(r"C:\Projects\YosemiteNP\MapPages.pdf")
pdfDoc.appendPages(r"C:\Projects\YosemiteNP\ContactInfo.pdf")
#Commit changes and delete variable reference
pdfDoc.saveAndClose()
del pdfDoc