PDFDocumentOpen append lose PDF layer list

680
2
Jump to solution
01-21-2024 01:23 PM
StefanoBassetti
New Contributor

Hello to everyone,

I'm having a big problem with the development of a toolbox that create a series of pdf (from different aprx files) and merge them with the PDFDocument append method.

I made the same script for ArcMap 10.8 and it works correclty, but now (on ArcGIS PRO v.3.2.1), when the script merge the pdf files together the resulting PDF file lack of the layers list.

is possible that this is a bug on ArcGIS PRO? As i said, the same procedure on ArcMap works correctly giving as output a merged pdf with all pdfs layer list preserved.

here below the code I'm using, thank you in advance for any suggestion!

FinalName = 'OutputFile'
outPDF_path = os.path.join(outDir, FinalName + '.pdf')

# iter in the temporary pdf exported, and assemble in a unique pdf in the correct order.
# tempOut is the temporary folder where the PDF exported individually are stored before the merge step

for numb in range(x):
     prefix = '{}_'.format(numb + 1)
     pdf = [file for file in pdfs if file.startswith(prefix)][0]
     if numb == 0:
          startPdf = os.path.join(tempOut, pdf)
          outPDF = arcpy.mp.PDFDocumentOpen(startPdf)
     else:
          outPDF.appendPages(os.path.join(tempOut, pdf))

outPDF.updateDocProperties(pdf_open_view="LAYERS")
outPDF.saveAndClose()

 

0 Kudos
1 Solution

Accepted Solutions
JeffBarrette
Esri Regular Contributor

This is unfortunately a known limitation (BUG-000121293).  The pdf libraries available in ArcMap were outdated and we needed to adopt a newer solution - we chose Py2PDF2.  The community is aware of the limitation and we are hopeful the developers will address it.

In the meantime, you would  need to append the pages using an Adobe product.

Jeff - Layout and arcpy.mp teams

View solution in original post

2 Replies
JeffBarrette
Esri Regular Contributor

This is unfortunately a known limitation (BUG-000121293).  The pdf libraries available in ArcMap were outdated and we needed to adopt a newer solution - we chose Py2PDF2.  The community is aware of the limitation and we are hopeful the developers will address it.

In the meantime, you would  need to append the pages using an Adobe product.

Jeff - Layout and arcpy.mp teams

StefanoBassetti
New Contributor

Thank you very much for the info. I know that maybe is possible to use ilovePDF API but I'm not so sure.

best regards.


Stefano

0 Kudos