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))
pdfDoc.appendPages(r"C:\TEST\tempExport{}.pdf".format(pageNum))
pdfDoc.appendPages(r"C:\TEST\local{}.pdf".format(pageNum))
pdfDoc.saveAndClose()