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()