AnsweredAssumed Answered

Export APRX files to PDF

Question asked by jpilbeam Champion on Jan 25, 2019
Latest reply on Feb 4, 2019 by jpilbeam

I'm not sure why this isn't working correctly. I want to export the layouts of the APRX files I have in a folder as PDFs and save them in the same place. It will run with no errors but there is no PDF saved in the outfolder. There is, however, one PDF saved one place back in the path. 

 

import arcpy, os

rootDir = r"path\to\TestFolder"
outfolder = r"path\to\TestFolder"

for dirName, subdirList, fileList in os.walk(rootDir):
    for file in fileList:
        if file.endswith(".aprx"):
            current_aprx = arcpy.mp.ArcGISProject(os.path.join(rootDir, file))
            pdf_name = os.path.join(outfolder, file[:-4])+".pdf"
            for lyts in current_aprx.listLayouts():
                lyts.exportToPDF(outfolder)
                print("exporting APRX to PDF: {}".format(pdf_name))

del file

 

Here's the print statements in the Interpreter window:

exporting APRX to PDF: path\to\TestFolder2\MUNICIPAL_LIMITS_A - Copy..pdf
exporting APRX to PDF: path\to\TestFolder2\MUNICIPAL_LIMITS_A..pdf

Outcomes