<?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: Help with Script Tool for Creating PDFs from MXDs in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/help-with-script-tool-for-creating-pdfs-from-mxds/m-p/3979#M350</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Does your script create a script tool to input several mxds to export as several PDFs. One PDF for each mxd. Or actually, I guess it would be easier to do one mxd at a time right!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 26 Feb 2013 14:57:22 GMT</pubDate>
    <dc:creator>MichelleCouden1</dc:creator>
    <dc:date>2013-02-26T14:57:22Z</dc:date>
    <item>
      <title>Help with Script Tool for Creating PDFs from MXDs</title>
      <link>https://community.esri.com/t5/python-questions/help-with-script-tool-for-creating-pdfs-from-mxds/m-p/3976#M347</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I need a little help. I have made a script tool to use to export my mxds into a pdf. It would be a single mxd into a single pdf. I am getting an error that the mxd path is incorrect. I have included my script below. Any help would be great!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# Necessary modules&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy, os, string, sys&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# For less complicated scripts -&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# these 2 imports are necessary to utilize a simpler method of debugging outher than traceback &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import win32ui, win32con&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# example debug message to screen ......&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# arcpy.AddMessage("mxd_file = " + str(mxd_file))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# val = win32ui.MessageBox("mxd_file = " + str(mxd_file), "title",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&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;&amp;nbsp;&amp;nbsp; #win32con.MB_OKCANCEL)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Paramaters...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;mxdList = string.split(arcpy.GetParameterAsText(0), ";")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;dir = arcpy.GetParameterAsText(1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#Loop thru &amp;amp; take the base name of each MXD selected and append all map pages to a single pdf &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# and save to chosen directory......&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for mxdPath in mxdList:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; mxd = arcpy.mapping.MapDocument(mxdPath)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; name = mxdPath[:-4] + ".pdf"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; file = dir + os.sep + os.path.basename(name)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; ddp = mxd&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; ddp.exportToPDF(file, "ALL")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;del mxd, file&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 22 Feb 2013 19:19:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-with-script-tool-for-creating-pdfs-from-mxds/m-p/3976#M347</guid>
      <dc:creator>MichelleCouden1</dc:creator>
      <dc:date>2013-02-22T19:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Script Tool for Creating PDFs from MXDs</title>
      <link>https://community.esri.com/t5/python-questions/help-with-script-tool-for-creating-pdfs-from-mxds/m-p/3977#M348</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;not much help, but doesn't a list need to be surrounded by brackets?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 23 Feb 2013 16:23:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-with-script-tool-for-creating-pdfs-from-mxds/m-p/3977#M348</guid>
      <dc:creator>ChristiNelson1</dc:creator>
      <dc:date>2013-02-23T16:23:50Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Script Tool for Creating PDFs from MXDs</title>
      <link>https://community.esri.com/t5/python-questions/help-with-script-tool-for-creating-pdfs-from-mxds/m-p/3978#M349</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What specifically is the error you are getting? Have you tried printing out the values of mxdPath and mxdList to see if they are indeed what you want? You can give this a try.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for mxdPath in mxdList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(mxdPath)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if os.path.exists(mxdPath):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument(mxdPath)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #name = mxdPath[:-4] + ".pdf"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; name = mxdPath.replace('.mxd', '.pdf', -1)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; file = dir + os.sep + os.path.basename(name)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ddp = mxd
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ddp.exportToPDF(file, "ALL")&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Also remember to use &lt;PRE class="lia-code-sample line-numbers language-none"&gt; tags when posting code to retain indentation.&lt;/PRE&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:09:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-with-script-tool-for-creating-pdfs-from-mxds/m-p/3978#M349</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2021-12-10T20:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Script Tool for Creating PDFs from MXDs</title>
      <link>https://community.esri.com/t5/python-questions/help-with-script-tool-for-creating-pdfs-from-mxds/m-p/3979#M350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Does your script create a script tool to input several mxds to export as several PDFs. One PDF for each mxd. Or actually, I guess it would be easier to do one mxd at a time right!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2013 14:57:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-with-script-tool-for-creating-pdfs-from-mxds/m-p/3979#M350</guid>
      <dc:creator>MichelleCouden1</dc:creator>
      <dc:date>2013-02-26T14:57:22Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Script Tool for Creating PDFs from MXDs</title>
      <link>https://community.esri.com/t5/python-questions/help-with-script-tool-for-creating-pdfs-from-mxds/m-p/3980#M351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It should be able to handle a list of mxd paths to process on. As long as they all have DDP enabled.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2013 15:02:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-with-script-tool-for-creating-pdfs-from-mxds/m-p/3980#M351</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-02-26T15:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Script Tool for Creating PDFs from MXDs</title>
      <link>https://community.esri.com/t5/python-questions/help-with-script-tool-for-creating-pdfs-from-mxds/m-p/3981#M352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is it alright to add data driven pages when all I have is one page\layout\dataframe per mxd? Meaning, I only have one page not multiple pages per mxd.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2013 18:26:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-with-script-tool-for-creating-pdfs-from-mxds/m-p/3981#M352</guid>
      <dc:creator>MichelleCouden1</dc:creator>
      <dc:date>2013-02-26T18:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Script Tool for Creating PDFs from MXDs</title>
      <link>https://community.esri.com/t5/python-questions/help-with-script-tool-for-creating-pdfs-from-mxds/m-p/3982#M353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm afraid I don't follow. What are you using data driven pages for if not for multiple page exports? Could you not just use the default &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//00s300000027000000"&gt;ExportToPDF &lt;/A&gt;&lt;SPAN&gt;function in that case?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2013 18:50:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-with-script-tool-for-creating-pdfs-from-mxds/m-p/3982#M353</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-02-26T18:50:19Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Script Tool for Creating PDFs from MXDs</title>
      <link>https://community.esri.com/t5/python-questions/help-with-script-tool-for-creating-pdfs-from-mxds/m-p/3983#M354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'll try to explain better. Sorry! I am trying to make a script tool that will make my job a little faster. Here: I have 25 mxds (all have single pages) and I want the script tool to export all those mxds into a PDF for each mxd. For Example: Abilene.mxd into Abilene.pdf and Austin.mxd into Austin.pdf on and on ... I hope this explains where I'm going.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2013 18:56:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-with-script-tool-for-creating-pdfs-from-mxds/m-p/3983#M354</guid>
      <dc:creator>MichelleCouden1</dc:creator>
      <dc:date>2013-02-26T18:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Script Tool for Creating PDFs from MXDs</title>
      <link>https://community.esri.com/t5/python-questions/help-with-script-tool-for-creating-pdfs-from-mxds/m-p/3984#M355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is there some particular functionality of DDP you need? Are you getting any errors with the new code you were running?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Feb 2013 20:13:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-with-script-tool-for-creating-pdfs-from-mxds/m-p/3984#M355</guid>
      <dc:creator>MathewCoyle</dc:creator>
      <dc:date>2013-02-26T20:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Script Tool for Creating PDFs from MXDs</title>
      <link>https://community.esri.com/t5/python-questions/help-with-script-tool-for-creating-pdfs-from-mxds/m-p/3985#M356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Judging from your comment: &lt;/SPAN&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;all I have is one page\layout\dataframe per mxd&lt;/BLOCKQUOTE&gt;&lt;SPAN&gt;...you may not even need data driven pages. Here is a simple export from a list of mxd names:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os
mxdList = ['C:/temp/Counties.mxd','C:/temp/Counties2.mxd']
for mxdPath in mxdList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print mxdPath
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument(mxdPath)
&amp;nbsp;&amp;nbsp;&amp;nbsp; output = mxdPath.replace('.mxd', '.pdf', -1)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print output
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ExportToPDF(mxd, output)
print 'done'&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is another sample, that exports all MXDs in a folder to PDF:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os
folderPath = r"C:\Temp\Forum"
for filename in os.listdir(folderPath):
&amp;nbsp;&amp;nbsp;&amp;nbsp; fullpath = os.path.join(folderPath, filename)
&amp;nbsp;&amp;nbsp;&amp;nbsp; if os.path.isfile(fullpath):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; basename, extension = os.path.splitext(fullpath)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if extension.lower() == ".mxd":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd = arcpy.mapping.MapDocument(fullpath)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ExportToPDF(mxd, basename + '.pdf')&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And if you do indeed need to export Data Driven Pages, than this line from your script is wrong:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;ddp = mxd&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It needs to be:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;ddp = mxd.dataDrivenPages&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For more info on DDP export, see &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/#/DataDrivenPages/00s300000030000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;here&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In your case, putting in print statements for the input mxd and output pdf file path for debugging purposes would be a good idea to make sure you got that right.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 20:10:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-with-script-tool-for-creating-pdfs-from-mxds/m-p/3985#M356</guid>
      <dc:creator>JeffMoulds</dc:creator>
      <dc:date>2021-12-10T20:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Script Tool for Creating PDFs from MXDs</title>
      <link>https://community.esri.com/t5/python-questions/help-with-script-tool-for-creating-pdfs-from-mxds/m-p/3986#M357</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank You so much Jeff! It works great!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 27 Feb 2013 19:36:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-with-script-tool-for-creating-pdfs-from-mxds/m-p/3986#M357</guid>
      <dc:creator>MichelleCouden1</dc:creator>
      <dc:date>2013-02-27T19:36:35Z</dc:date>
    </item>
  </channel>
</rss>

