<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic append pages to a pdf in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/append-pages-to-a-pdf/m-p/333443#M25981</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to figure out if I can append a bunch of pdfs into a single pdf document.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I can append the files if I spell out the path and file name of each pdf using pdfDoc.appendPages.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I can also list the pdf files that I have in a folder arcpy.ListFiles("*.pdf").&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Now if I could just combine the two functions - so that I'm listing all the pdfs in a folder and then appending them to a new single pdf.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;chad&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 11 Feb 2011 19:47:02 GMT</pubDate>
    <dc:creator>ChadKeith</dc:creator>
    <dc:date>2011-02-11T19:47:02Z</dc:date>
    <item>
      <title>append pages to a pdf</title>
      <link>https://community.esri.com/t5/python-questions/append-pages-to-a-pdf/m-p/333443#M25981</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to figure out if I can append a bunch of pdfs into a single pdf document.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I can append the files if I spell out the path and file name of each pdf using pdfDoc.appendPages.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I can also list the pdf files that I have in a folder arcpy.ListFiles("*.pdf").&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Now if I could just combine the two functions - so that I'm listing all the pdfs in a folder and then appending them to a new single pdf.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;chad&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Feb 2011 19:47:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/append-pages-to-a-pdf/m-p/333443#M25981</guid>
      <dc:creator>ChadKeith</dc:creator>
      <dc:date>2011-02-11T19:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: append pages to a pdf</title>
      <link>https://community.esri.com/t5/python-questions/append-pages-to-a-pdf/m-p/333444#M25982</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;did you try&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;out_file.appendPages(tmp_pdf)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;where out_file is an existing pdf and tmp_pdf is another one&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 11 Feb 2011 21:22:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/append-pages-to-a-pdf/m-p/333444#M25982</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2011-02-11T21:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: append pages to a pdf</title>
      <link>https://community.esri.com/t5/python-questions/append-pages-to-a-pdf/m-p/333445#M25983</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi-&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure how that would help.&amp;nbsp; I'm probably just not following your logic but here is what I'm try to do with some examples:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It is simple I think - just combine listing a bunch of pdfs from a folder and appending those pdfs in the list to a new single pdf.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is the first part:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Set the workspace.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace = r"C:\output"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# List all of the pdf files in the output folder.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# pdfList is a Python List returned from the ListFiles function.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pdfList = arcpy.ListFiles("*.pdf")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Iterate through the fields and print the name of each&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# field to the Interactive Window.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for pdf in pdfList:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print pdf&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and here is the second part:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy, os&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Set file name and remove if it already exists&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pdfPath = r"C:\output\TimeSeries.pdf"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if os.path.exists(pdfPath):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; os.remove(pdfPath)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Create the file and append pages&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pdfDoc = arcpy.mapping.PDFDocumentCreate(pdfPath)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pdfDoc.appendPages(r"C:\output\1991.pdf")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pdfDoc.appendPages(r"C:\output\1992.pdf")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pdfDoc.appendPages(r"C:\output\1993.pdf")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pdfDoc.appendPages(r"C:\output\1994.pdf")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pdfDoc.appendPages(r"C:\output\1995.pdf")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Commit changes and delete variable reference&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pdfDoc.saveAndClose()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del pdfDoc&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Feb 2011 12:49:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/append-pages-to-a-pdf/m-p/333445#M25983</guid>
      <dc:creator>ChadKeith</dc:creator>
      <dc:date>2011-02-14T12:49:33Z</dc:date>
    </item>
    <item>
      <title>Re: append pages to a pdf</title>
      <link>https://community.esri.com/t5/python-questions/append-pages-to-a-pdf/m-p/333446#M25984</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;well if the file names are just numbers like that you should sort the list and then just put the list into a for loop&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for file in pdfList:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pdfDoc.appendPages(r"C:\output\%s"%file)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Feb 2011 16:29:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/append-pages-to-a-pdf/m-p/333446#M25984</guid>
      <dc:creator>ChrisMathers</dc:creator>
      <dc:date>2011-02-14T16:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: append pages to a pdf</title>
      <link>https://community.esri.com/t5/python-questions/append-pages-to-a-pdf/m-p/333447#M25985</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;thanks this worked perfect!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Mar 2011 13:12:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/append-pages-to-a-pdf/m-p/333447#M25985</guid>
      <dc:creator>ChadKeith</dc:creator>
      <dc:date>2011-03-08T13:12:41Z</dc:date>
    </item>
  </channel>
</rss>

