I want to make a Data Driven export to PDF of the layout using arcpy, and later add to that PDF extra pages from PDFs from my local computer.

My problem is that I don't actually want to make the exports of the PDFs on my computer using the arcpy.mapping.ExportToPDF , I would only want to store that page (the data driven layout) in the memory, and later on, add the extra pages.

I use this code:

mxd = arcpy.mapping.MapDocument("CURRENT")  
df = arcpy.mapping.ListDataFrames(mxd, '')[0]

for pageNum in range(1, mxd.dataDrivenPages.pageCount+1):
    pageName = mxd.dataDrivenPages.pageRow.getValue(nameField)
    arcpy.mapping.ExportToPDF(mxd, r"C:\TEST\tempExport{}.pdf".format(pageNum)) # This is the temporary export that I want to be stored in memory, not on my local machine
    pdfDoc = arcpy.mapping.PDFDocumentCreate(r"C:\TEST\FinalPDF{}.pdf".format(pageNum))

1 Answer 1


I do not believe that there is anything in ArcPy that will help you here.

Using arcpy.mapping.PDFDocumentCreate(PDF file) it is possible to copy a PDF file from disk into memory and then append pages to it in memory.

However, there is nothing to enable writing the output from arcpy.mapping.ExportToPDF to memory.

If such functionality is important to you then I recommend researching/submitting an ArcGIS Idea for it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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