import os, arcpy, glob def combinePDFs(out_pdf, pdf_path_or_list): ''' uses arcpy mapping module to combine pdf documents out_pdf -- output pdf document (.pdf) pdf_path_or_list -- list of pdf documents or folder path containing pdf documents. ''' # Create new PDF document out_path, pdf_name = os.path.split(out_pdf) pdfDoc = arcpy.mapping.PDFDocumentCreate(out_pdf) # set workspace to get pdfs if isinstance(pdf_path_or_list, list): for pdf in pdf_path_or_list: pdfDoc.appendPages(pdf) print 'Added "%s" to "%s"' %(pdf, os.path.basename(out_pdf)) elif isinstance(pdf_path_or_list, str): if os.path.exists(pdf_path_or_list): # if path, use glob to find all pdf's in folder for pdf in sorted(glob.glob(os.path.join(pdf_path_or_list, '*.pdf'))): pdfDoc.appendPages(os.path.join(pdf_path_or_list, pdf)) print 'Added "%s" to "%s"' %(pdf, os.path.basename(out_pdf)) # Save and close pdf document pdfDoc.saveAndClose() del pdfDoc print 'Created: %s' %out_pdf return out_pdf if __name__ == '__main__': # test function with path out_pdf = r'C:\Users\calebma\Desktop\test.pdf' path = r'C:\Users\calebma\Desktop\pdfTest' combinePDFs(out_pdf, path) # test functino with list pdf2 = r'C:\Users\calebma\Desktop\test2.pdf' pdfs = [r'C:\Users\calebma\Desktop\pdfTest\Mailing_Labels5160.pdf', r'C:\Users\calebma\Desktop\pdfTest\Mailing_Taxpayer.pdf', r'C:\Users\calebma\Desktop\pdfTest\stfr.pdf'] combinePDFs(pdf2, pdfs)
Hi,
I would like use it, but I can`t just copy e value. I tried replace 5 spaces for a broke line; but its doesn`t worked yet. I appreciate a help here. I'm using ArcGIS Desktop 10.4
Best Regards
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.