AnsweredAssumed Answered

pdfdoc.appendPages

Question asked by bakhtiariz_nngov on Oct 26, 2018
Latest reply on Oct 26, 2018 by Dan_Patterson

I created a python script toolbox a while back that will take individual .pdf in a folder and merge them into one .pdf.  2 years later I run the tool box and of course it doesn't work.  I have attache a picture of the error I am getting.

# Import Modules
import arcpy, os, glob

# Folder where PDFs will be stored
pdfFolder = arcpy.GetParameterAsText(0)
# Folder where final merged PDF will be stored
pdfname = arcpy.GetParameterAsText(1)
# Name of the finale merged PDF
mergedpdf = arcpy.GetParameterAsText(2)
# Creates a list of the PDF file paths
pdflist = glob.glob(pdfFolder + os.sep + '*.pdf')
# Creates a file path for the final PDF document 
finalpdf = pdfname + os.sep + mergedpdf + '.pdf'


pdfPath = finalpdf
if os.path.exists(pdfPath):
    os.remove(pdfPath)


pdfdoc = arcpy.mapping.PDFDocumentCreate(finalpdf)

i = 0
for pdf in pdflist:
    pdfdoc.appendPages(pdflist[i])
    i+=1
   
   

Attachments

Outcomes