<?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: Is there a way to ExportToPDF to a single PDF in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/is-there-a-way-to-exporttopdf-to-a-single-pdf/m-p/513888#M40341</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Neil seems to have a much 'lighter' answer, but this is the code I used to produce the result I was looking for. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your reply Neil, much better answer than mine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os, arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
#Create final output PDF file 
finalFile = r"C:\temp\BensMap.pdf"
if os.path.isfile(finalFile) 
&amp;nbsp; os.remove(finalFile)
&amp;nbsp; print 'Removed existing output file'
finalPDF = arcpy.mapping.PDFDocumentCreate(finalFile)
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
&amp;nbsp; mxd.dataDrivenPages.currentPageID = pageNum
&amp;nbsp; currentPage = str(mxd.dataDrivenPages.currentPageID)
&amp;nbsp; pageCount = str(mxd.dataDrivenPages.pageCount)
&amp;nbsp; print 'Exporting page %s of %s' % (currentPage, pageCount)
&amp;nbsp; tmpPDF = r"C:\temp\MAP_" + str(pageNum) + ".pdf"
&amp;nbsp; arcpy.mapping.ExportToPDF(mxd, tmpPDF)
&amp;nbsp; print tmpPDF
&amp;nbsp; finalPDF.appendPages(tmpPDF)
&amp;nbsp; del tmpPDF
del mxd&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 22:28:06 GMT</pubDate>
    <dc:creator>BenVan_Kesteren1</dc:creator>
    <dc:date>2021-12-11T22:28:06Z</dc:date>
    <item>
      <title>Is there a way to ExportToPDF to a single PDF</title>
      <link>https://community.esri.com/t5/python-questions/is-there-a-way-to-exporttopdf-to-a-single-pdf/m-p/513885#M40338</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am currently using this code to export my data driven pages to PDF, but the export seems to only export individual pages, I would like a singular output PDF with several pages instead. Does anyone know if this is possible with this tool, or do I need to use an external module to achieve this one??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;mxd = arcpy.mapping.MapDocument("CURRENT")
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
&amp;nbsp; mxd.dataDrivenPages.currentPageID = pageNum
&amp;nbsp; arcpy.mapping.ExportToPDF(mxd, r"C:\temp\MAP_" + str(pageNum) + ".pdf")
del mxd&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the help file for the &lt;A href="http://http//help.arcgis.com/en%20/ArcGISDesktop/10.0/Help/index.html#//00s300000027000000" rel="nofollow noopener noreferrer" target="_blank"&gt;ExportToPDF tool&lt;/A&gt;​&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:28:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-a-way-to-exporttopdf-to-a-single-pdf/m-p/513885#M40338</guid>
      <dc:creator>BenVan_Kesteren1</dc:creator>
      <dc:date>2021-12-11T22:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to ExportToPDF to a single PDF</title>
      <link>https://community.esri.com/t5/python-questions/is-there-a-way-to-exporttopdf-to-a-single-pdf/m-p/513886#M40339</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Export to pdf seems to default to making a multipage pdf.&lt;/P&gt;&lt;P&gt;So, don't change the filename in the loop.&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/197835_pastedImage_0.png" style="max-height: 900px; max-width: 1200px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 May 2016 06:42:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-a-way-to-exporttopdf-to-a-single-pdf/m-p/513886#M40339</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2016-05-02T06:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to ExportToPDF to a single PDF</title>
      <link>https://community.esri.com/t5/python-questions/is-there-a-way-to-exporttopdf-to-a-single-pdf/m-p/513887#M40340</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks &lt;A href="https://community.esri.com/migrated-users/5327"&gt;Neil Ayres&lt;/A&gt;​, it seems I was looking for a harder way of doing things than necessary... &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 May 2016 06:57:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-a-way-to-exporttopdf-to-a-single-pdf/m-p/513887#M40340</guid>
      <dc:creator>BenVan_Kesteren1</dc:creator>
      <dc:date>2016-05-02T06:57:56Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to ExportToPDF to a single PDF</title>
      <link>https://community.esri.com/t5/python-questions/is-there-a-way-to-exporttopdf-to-a-single-pdf/m-p/513888#M40341</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Neil seems to have a much 'lighter' answer, but this is the code I used to produce the result I was looking for. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your reply Neil, much better answer than mine.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os, arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
#Create final output PDF file 
finalFile = r"C:\temp\BensMap.pdf"
if os.path.isfile(finalFile) 
&amp;nbsp; os.remove(finalFile)
&amp;nbsp; print 'Removed existing output file'
finalPDF = arcpy.mapping.PDFDocumentCreate(finalFile)
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
&amp;nbsp; mxd.dataDrivenPages.currentPageID = pageNum
&amp;nbsp; currentPage = str(mxd.dataDrivenPages.currentPageID)
&amp;nbsp; pageCount = str(mxd.dataDrivenPages.pageCount)
&amp;nbsp; print 'Exporting page %s of %s' % (currentPage, pageCount)
&amp;nbsp; tmpPDF = r"C:\temp\MAP_" + str(pageNum) + ".pdf"
&amp;nbsp; arcpy.mapping.ExportToPDF(mxd, tmpPDF)
&amp;nbsp; print tmpPDF
&amp;nbsp; finalPDF.appendPages(tmpPDF)
&amp;nbsp; del tmpPDF
del mxd&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:28:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-a-way-to-exporttopdf-to-a-single-pdf/m-p/513888#M40341</guid>
      <dc:creator>BenVan_Kesteren1</dc:creator>
      <dc:date>2021-12-11T22:28:06Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to ExportToPDF to a single PDF</title>
      <link>https://community.esri.com/t5/python-questions/is-there-a-way-to-exporttopdf-to-a-single-pdf/m-p/513889#M40342</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you leverage the ExportToPDF method of the mapping class you'll have to export each page one at a time and then append them into a single document. If you're using data driven pages and you want to export all of the pages to a single pdf in one go use the exportToPDF method of the data driven pages class instead of the ExportToPDF method of the mapping class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Data Driven Pages&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/datadrivenpages-class.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/datadrivenpages-class.htm"&gt;http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/datadrivenpages-class.htm&lt;/A&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've highlighted the property you're looking for below.&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="197887" alt="exportTopdf.png" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/197887_exportTopdf.png" style="width: 620px; height: 662px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 May 2016 12:30:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/is-there-a-way-to-exporttopdf-to-a-single-pdf/m-p/513889#M40342</guid>
      <dc:creator>FreddieGibson</dc:creator>
      <dc:date>2016-05-02T12:30:26Z</dc:date>
    </item>
  </channel>
</rss>

