<?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 Merge DDP PDF Outputs into one file in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/merge-ddp-pdf-outputs-into-one-file/m-p/76648#M6218</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a folder of PDFs that are a 1:1 relationship with an MXD. Each plan is a floor of a building. In the screenshot below, WHBFD325 is only one floor, so no modifications need to be done to that. In the 4 files for WHBFD364, I would like to merge the 4 PDFs into one PDF with _1 being the first page, _4 being the last page. The merged file name would be WHBFD364. After the merge is complete, I would like the 4 files that end with _1, _2, _3, _4 to be deleted. I am not sure where to start, but any advice or links would really help me out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/432287_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am looking at the PDFDoc ArpPy commands, but nothing looks promising so far.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-mapping/pdfdocument-class.htm" title="http://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-mapping/pdfdocument-class.htm"&gt;PDFDocument—Help | ArcGIS for Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 27 Dec 2018 18:57:05 GMT</pubDate>
    <dc:creator>Brian_McLeer</dc:creator>
    <dc:date>2018-12-27T18:57:05Z</dc:date>
    <item>
      <title>Merge DDP PDF Outputs into one file</title>
      <link>https://community.esri.com/t5/python-questions/merge-ddp-pdf-outputs-into-one-file/m-p/76648#M6218</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a folder of PDFs that are a 1:1 relationship with an MXD. Each plan is a floor of a building. In the screenshot below, WHBFD325 is only one floor, so no modifications need to be done to that. In the 4 files for WHBFD364, I would like to merge the 4 PDFs into one PDF with _1 being the first page, _4 being the last page. The merged file name would be WHBFD364. After the merge is complete, I would like the 4 files that end with _1, _2, _3, _4 to be deleted. I am not sure where to start, but any advice or links would really help me out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/432287_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am looking at the PDFDoc ArpPy commands, but nothing looks promising so far.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="http://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-mapping/pdfdocument-class.htm" title="http://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-mapping/pdfdocument-class.htm"&gt;PDFDocument—Help | ArcGIS for Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Dec 2018 18:57:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/merge-ddp-pdf-outputs-into-one-file/m-p/76648#M6218</guid>
      <dc:creator>Brian_McLeer</dc:creator>
      <dc:date>2018-12-27T18:57:05Z</dc:date>
    </item>
    <item>
      <title>Re: Merge DDP PDF Outputs into one file</title>
      <link>https://community.esri.com/t5/python-questions/merge-ddp-pdf-outputs-into-one-file/m-p/76649#M6219</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Brian,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You should be able to use ArcPy to do this. In the documentation you linked Esri has a code snippet:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; os

&lt;SPAN class="comment token"&gt;#Set file name and remove if it already exists&lt;/SPAN&gt;
pdfPath &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"C:\Project\ParcelAtlasMapBook.pdf"&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;exists&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;pdfPath&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;remove&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;pdfPath&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;#Create the file and append pages&lt;/SPAN&gt;
pdfDoc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;PDFDocumentCreate&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;pdfPath&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
pdfDoc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;appendPages&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;"C:\Project\Title.pdf"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
pdfDoc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;appendPages&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;"C:\Project\ParcelAtlas.pdf"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
pdfDoc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;appendPages&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;"C:\Project\ContactInfo.pdf"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="comment token"&gt;#Commit changes and delete variable reference&lt;/SPAN&gt;
pdfDoc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;saveAndClose&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;del&lt;/SPAN&gt; pdfDoc&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Line 9 will create a new PDF (folder\&lt;SPAN style="background-color: #ffffff;"&gt;WHBFD364.pdf would be the path passed here), then use the appendPages function in subsequent lines to append the other PDF's into the newly created one. Make sure to append them in the order you would like them to appear in the new PDF. Then, save and close the new PDF in line 15.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Once the appends are done, you could remove the old PDF files using&amp;nbsp;&lt;A class="link-titled" href="http://pro.arcgis.com/en/pro-app/tool-reference/data-management/delete.htm" title="http://pro.arcgis.com/en/pro-app/tool-reference/data-management/delete.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Delete—Data Management toolbox | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;or using the os python package's remove method like in line 6.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;If the ArcPy method doesn't work, there is also the &lt;A href="https://pythonhosted.org/PyPDF2/" rel="nofollow noopener noreferrer" target="_blank"&gt;PyPDF2&lt;/A&gt; Python package. That package has a PdfFileMerger class that can be used to merge multiple PDF's into one. Here is a stack overflow post with some examples:&amp;nbsp;&lt;A class="link-titled" href="https://stackoverflow.com/questions/3444645/merge-pdf-files" title="https://stackoverflow.com/questions/3444645/merge-pdf-files" rel="nofollow noopener noreferrer" target="_blank"&gt;python - Merge PDF files - Stack Overflow&lt;/A&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Hope this helps!&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 22:57:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/merge-ddp-pdf-outputs-into-one-file/m-p/76649#M6219</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-10T22:57:49Z</dc:date>
    </item>
  </channel>
</rss>

