1 # check to see if there is already a pdf file created for this county 2 pdfFile = outputFolder + '\\' + name + '.pdf' 3 if os.path.exists(pdfFile): 4 print 'Existing pdf found. Appending...' 5 6 # open PDF document 7 pdf = arcpy.mapping.PDFDocumentOpen(pdfFile) 8 9 # output to temporary file 10 tempFile = outputFolder + '\\temp.pdf' 11 ddp.exportToPDF(tempFile, 'CURRENT') 12 13 # append to existing file 14 pdf.appendPages(tempFile) 15 16 # delete temp file 17 os.remove(tempFile) 18 19 # clean up variables 20 del pdf 21 22 else: # file does not exist, export to new file 23 print 'No existing pdf found. Exporting to new pdf.' 24 ddp.exportToPDF(pdfFile, 'CURRENT') 25 26 # increment page number 27 pg = pg + 1