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
Can you show what the input parameters are and what does pdflist show?
(add some print statements perhaps)
Dan Patterson the input parameters are just the input\output file paths and the output pdf name. pdflist is a list of all the pdf file paths in the pdfFolder
# Import Modules
import arcpy, os, glob
# Folder where PDFs will be stored
pdfFolder = r'C:\Users\bakhtiariz\Desktop\Test'
# Folder where final merged PDF will be stored
pdfname = "C:\Users\bakhtiariz\Desktop\Test"
# Name of the finale merged PDF
mergedpdf = "Test"
# 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)
#%%
for pdf in pdflist:
pdfDoc = arcpy.mapping.PDFDocumentCreate(finalpdf)
pdfDoc.appendPages(pdflist)
print "Done"
The error is specific to the conversion tool, which is why I wondered what was printed out for pdflist
Could be a number of things, including spaces in path names (which I notice the source location uses)
changes in the pdf files, etc.
Did you try it with files that worked before?
If it is the same version of everything, and you can get it to work with files that produced a pdf before, then that leaves something about the files.