<?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 Re: Combining several PDFs into a single one in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/combining-several-pdfs-into-a-single-one/m-p/170801#M13131</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I don't know for sure about after the fact, however if you created a new ranking field and your data was such that you could cycle through the field for each new pdf, then you can combine them all in the end.&amp;nbsp; This method, at least how I am using it, would require the ranking field prior to the creation of the pdfs.&amp;nbsp; The new pdfs would have a page count associated with them and can then be compiled via python.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you easily rebuild these pdfs or at least rename them in the order you want by adding a page count at the end?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You might also be able to build a custom dictionary and use that to compile the pdf based upon the order you designated.&amp;nbsp; I haven't tried this method as of yet.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 13 May 2014 18:16:07 GMT</pubDate>
    <dc:creator>GeorgeHaskett</dc:creator>
    <dc:date>2014-05-13T18:16:07Z</dc:date>
    <item>
      <title>Combining several PDFs into a single one</title>
      <link>https://community.esri.com/t5/python-questions/combining-several-pdfs-into-a-single-one/m-p/170799#M13129</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have created some pdfs through a stand alone script, but would like to be able to create one single pdf file and not 100+ single page pdf files.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My naming convention has a different name for Left and Right pages.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Left: North_x_FAC&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Right: North _x_SLD&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a way to get python to combine the files so that the single pdf file would have to correct ordering. North_1_FAC would come before North_1_SLD, and so on down to like 50+ pages of both left and right pages.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 May 2014 16:36:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/combining-several-pdfs-into-a-single-one/m-p/170799#M13129</guid>
      <dc:creator>ThomasKendall</dc:creator>
      <dc:date>2014-05-08T16:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: Combining several PDFs into a single one</title>
      <link>https://community.esri.com/t5/python-questions/combining-several-pdfs-into-a-single-one/m-p/170800#M13130</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I don't think arcpy has any sort of built in functionality for this.&amp;nbsp; My suggestion would be to post this question on Stack Overflow, since this is more of a broad Python question than specific to ArcMap.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A couple possible solutions I can think of off the top of my head is using a cloud pdf combiner.&amp;nbsp; You could use the Requests module to pass your pdfs to the cloud service via a post request.&amp;nbsp; Though I'm not sure how well this would work with 100+ pdfs.&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Another solution would be a custom python module that is built to do exactly this sort of thing.&amp;nbsp; I'm not sure it one exists, but a post to a more general forum may bring up some answers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good hunting!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;UPDATE:&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A quick Google search turned up a Python module called &lt;/SPAN&gt;&lt;A href="https://pypi.python.org/pypi/pyPdf"&gt;pyPDF&lt;/A&gt;&lt;SPAN&gt;, which has the functionality you're looking for.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Check &lt;/SPAN&gt;&lt;A href="http://mygisblog.wordpress.com/2011/08/26/merging-pdf-files-with-python/"&gt;here&lt;/A&gt;&lt;SPAN&gt; for an example of it's usage.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 May 2014 23:03:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/combining-several-pdfs-into-a-single-one/m-p/170800#M13130</guid>
      <dc:creator>MattEiben</dc:creator>
      <dc:date>2014-05-08T23:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: Combining several PDFs into a single one</title>
      <link>https://community.esri.com/t5/python-questions/combining-several-pdfs-into-a-single-one/m-p/170801#M13131</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I don't know for sure about after the fact, however if you created a new ranking field and your data was such that you could cycle through the field for each new pdf, then you can combine them all in the end.&amp;nbsp; This method, at least how I am using it, would require the ranking field prior to the creation of the pdfs.&amp;nbsp; The new pdfs would have a page count associated with them and can then be compiled via python.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you easily rebuild these pdfs or at least rename them in the order you want by adding a page count at the end?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You might also be able to build a custom dictionary and use that to compile the pdf based upon the order you designated.&amp;nbsp; I haven't tried this method as of yet.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2014 18:16:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/combining-several-pdfs-into-a-single-one/m-p/170801#M13131</guid>
      <dc:creator>GeorgeHaskett</dc:creator>
      <dc:date>2014-05-13T18:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: Combining several PDFs into a single one</title>
      <link>https://community.esri.com/t5/python-questions/combining-several-pdfs-into-a-single-one/m-p/170802#M13132</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;At 10.1, you can actually combine pdf's using the arcpy mapping module.&amp;nbsp; I use this script all the time to combine pdfs:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import os, arcpy, glob&amp;nbsp; def combinePDFs(out_pdf, pdf_path_or_list): &amp;nbsp;&amp;nbsp;&amp;nbsp; ''' &amp;nbsp;&amp;nbsp;&amp;nbsp; uses arcpy mapping&amp;nbsp; module to combine pdf documents&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; out_pdf -- output pdf document (.pdf) &amp;nbsp;&amp;nbsp;&amp;nbsp; pdf_path_or_list -- list of pdf documents or folder &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; path containing pdf documents. &amp;nbsp;&amp;nbsp;&amp;nbsp; ''' &amp;nbsp;&amp;nbsp;&amp;nbsp; # Create new PDF document &amp;nbsp;&amp;nbsp;&amp;nbsp; out_path, pdf_name = os.path.split(out_pdf) &amp;nbsp;&amp;nbsp;&amp;nbsp; pdfDoc = arcpy.mapping.PDFDocumentCreate(out_pdf)&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # set workspace to get pdfs &amp;nbsp;&amp;nbsp;&amp;nbsp; if isinstance(pdf_path_or_list, list): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for pdf in pdf_path_or_list: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pdfDoc.appendPages(pdf) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'Added "%s" to "%s"' %(pdf, os.path.basename(out_pdf)) &amp;nbsp;&amp;nbsp;&amp;nbsp; elif isinstance(pdf_path_or_list, str): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if os.path.exists(pdf_path_or_list): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # if path, use glob to find all pdf's in folder &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for pdf in sorted(glob.glob(os.path.join(pdf_path_or_list, '*.pdf'))): &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pdfDoc.appendPages(os.path.join(pdf_path_or_list, pdf)) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'Added "%s" to "%s"' %(pdf, os.path.basename(out_pdf)) &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # Save and close pdf document&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; pdfDoc.saveAndClose() &amp;nbsp;&amp;nbsp;&amp;nbsp; del pdfDoc &amp;nbsp;&amp;nbsp;&amp;nbsp; print 'Created: %s' %out_pdf &amp;nbsp;&amp;nbsp;&amp;nbsp; return out_pdf&amp;nbsp; if __name__ == '__main__':&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # test function with path &amp;nbsp;&amp;nbsp;&amp;nbsp; out_pdf = r'C:\Users\calebma\Desktop\test.pdf' &amp;nbsp;&amp;nbsp;&amp;nbsp; path = r'C:\Users\calebma\Desktop\pdfTest' &amp;nbsp;&amp;nbsp;&amp;nbsp; combinePDFs(out_pdf, path)&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; # test functino with list &amp;nbsp;&amp;nbsp;&amp;nbsp; pdf2 = r'C:\Users\calebma\Desktop\test2.pdf' &amp;nbsp;&amp;nbsp;&amp;nbsp; pdfs = [r'C:\Users\calebma\Desktop\pdfTest\Mailing_Labels5160.pdf', &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r'C:\Users\calebma\Desktop\pdfTest\Mailing_Taxpayer.pdf', &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r'C:\Users\calebma\Desktop\pdfTest\stfr.pdf'] &amp;nbsp;&amp;nbsp;&amp;nbsp; combinePDFs(pdf2, pdfs)&amp;nbsp; &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2014 18:57:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/combining-several-pdfs-into-a-single-one/m-p/170802#M13132</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2014-05-13T18:57:37Z</dc:date>
    </item>
    <item>
      <title>Re: Combining several PDFs into a single one</title>
      <link>https://community.esri.com/t5/python-questions/combining-several-pdfs-into-a-single-one/m-p/1151007#M63963</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;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&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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)&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 05 Mar 2022 17:38:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/combining-several-pdfs-into-a-single-one/m-p/1151007#M63963</guid>
      <dc:creator>BrunoDeus</dc:creator>
      <dc:date>2022-03-05T17:38:10Z</dc:date>
    </item>
  </channel>
</rss>

