<?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: Python script in export pdf with fieldname in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-script-in-export-pdf-with-fieldname/m-p/572266#M44869</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;that could be it, but I you didn't post print statement to confirm&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 13 Oct 2018 11:31:24 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2018-10-13T11:31:24Z</dc:date>
    <item>
      <title>Python script in export pdf with fieldname</title>
      <link>https://community.esri.com/t5/python-questions/python-script-in-export-pdf-with-fieldname/m-p/572263#M44866</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I have the script below. I am trying to export 400 pdfs with the fieldname "Label" but it only export the last page of pdf. What goes wrong ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;import arcpy&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt;"&gt;&lt;SPAN style="font-size: 9.0pt; color: black; background: #F6F6F6;"&gt;pageNameField&amp;nbsp;=&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="border: none windowtext 1.0pt; padding: 0cm; color: blue; background: #F6F6F6; font-size: 9.0pt;"&gt;"Label"&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.0pt; color: black; border: none windowtext 1.0pt; padding: 0cm; background: #F6F6F6;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.dataDrivenPages.currentPageID = pageNum&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt; text-indent: 18.0pt;"&gt;&lt;SPAN style="font-size: 9.0pt;"&gt;pageName = mxd.dataDrivenPages.pageRow.getValue&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.0pt; color: black; background: white;"&gt;(pageNameField)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt; text-indent: 18.0pt;"&gt;&lt;SPAN style="font-size: 9.0pt;"&gt;pageName = pageName.replace("/", "_")&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt; text-indent: 18.0pt;"&gt;&lt;SPAN style="font-size: 9.0pt;"&gt;pageName = pageName.replace(" ", "")&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt; text-indent: 18.0pt;"&gt;&lt;SPAN style="border: none windowtext 1.0pt; padding: 0cm; color: #0088e1; background: white; font-size: 9.0pt;"&gt;print&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.0pt; color: black; border: none windowtext 1.0pt; padding: 0cm; background: white;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="border: none windowtext 1.0pt; padding: 0cm; color: blue; background: white; font-size: 9.0pt;"&gt;"Exporting&amp;nbsp;page&amp;nbsp;{0}&amp;nbsp;of&amp;nbsp;{1}"&lt;/SPAN&gt;&lt;SPAN style="font-size: 9.0pt; color: black; border: none windowtext 1.0pt; padding: 0cm; background: white;"&gt;.format(str(mxd.dataDrivenPages.currentPageID),&amp;nbsp;str(mxd.dataDrivenPages.pageCount))&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt; text-indent: 18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;mxd.dataDrivenPages.refresh()&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt; text-indent: 18.0pt;"&gt;&lt;SPAN style="font-size: 9.0pt;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt; text-indent: 18.0pt;"&gt;&lt;SPAN style="font-size: 9.0pt; color: black;"&gt;arcpy.mapping.ExportToPDF(mxd, r"C:\TEST\181013_test" + str(pageName) + ".pdf")&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;del mxd&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 13 Oct 2018 03:43:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-in-export-pdf-with-fieldname/m-p/572263#M44866</guid>
      <dc:creator>ChanYuk_Yu</dc:creator>
      <dc:date>2018-10-13T03:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: Python script in export pdf with fieldname</title>
      <link>https://community.esri.com/t5/python-questions/python-script-in-export-pdf-with-fieldname/m-p/572264#M44867</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting" target="_blank"&gt;/blogs/dan_patterson/2016/08/14/script-formatting&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There seem to be a few issues with code formatting that might be real or due to copying.&lt;/P&gt;&lt;P&gt;Throw in a couple of print statements to see what the page and output filename are printing as you go along.&amp;nbsp;&lt;/P&gt;&lt;P&gt;You don't have to go through all 400, just check&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"page count {}"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;dataDrivenPages&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;pageCount&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN style="-webkit-text-stroke-width: 0px; color: #3d3d3d; white-space: normal; font-weight: 400; display: inline !important; letter-spacing: normal; text-decoration: none; font-size: 13.33px; font-style: normal; float: none; background-color: transparent; text-transform: none; word-spacing: 0px; font-variant: normal; text-indent: 0px; font-family: arial,helvetica,'helvetica neue',verdana,sans-serif; orphans: 2; text-align: left;"&gt;And change this line to....&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; pageNum &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; range&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; mxd&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;dataDrivenPages&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;pageCount &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;‍&amp;nbsp; &lt;SPAN class="comment token"&gt;# ---- original&lt;/SPAN&gt;


&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; pageNum &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; range&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;1&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;5&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN class="comment token"&gt;# ---- or some small number for testing&lt;/SPAN&gt;&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;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:38:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-in-export-pdf-with-fieldname/m-p/572264#M44867</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-12T00:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: Python script in export pdf with fieldname</title>
      <link>https://community.esri.com/t5/python-questions/python-script-in-export-pdf-with-fieldname/m-p/572265#M44868</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Dan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am new in python, so I am copying and combined the sample or code posted&amp;nbsp;to try to get a workaround.&lt;/P&gt;&lt;P&gt;Thank you for your suggestion. I tried range (1,5), the small test shows it only process the last page. I wonder if the problem comes from pageName because the code works all right when the second last script ExportToPdf&amp;nbsp;is pageNum.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 13 Oct 2018 05:10:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-in-export-pdf-with-fieldname/m-p/572265#M44868</guid>
      <dc:creator>ChanYuk_Yu</dc:creator>
      <dc:date>2018-10-13T05:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: Python script in export pdf with fieldname</title>
      <link>https://community.esri.com/t5/python-questions/python-script-in-export-pdf-with-fieldname/m-p/572266#M44869</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;that could be it, but I you didn't post print statement to confirm&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 13 Oct 2018 11:31:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-in-export-pdf-with-fieldname/m-p/572266#M44869</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-10-13T11:31:24Z</dc:date>
    </item>
    <item>
      <title>Re: Python script in export pdf with fieldname</title>
      <link>https://community.esri.com/t5/python-questions/python-script-in-export-pdf-with-fieldname/m-p/572267#M44870</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="margin-left: 18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: #8064a2;"&gt;I inserted the print code you recommended and another error comes up..&amp;nbsp; What goes wrong at Line 11 ?&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: #8064a2;"&gt;Parsing error SyntaxError: EOL while scanning string literal (line 11)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt;"&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: #8064a2;"&gt;Here's the code&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: #8064a2;"&gt;import arcpy&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: #8064a2;"&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: #8064a2;"&gt;pageNameField&amp;nbsp;=&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt;"&gt;"Label"&lt;SPAN style="color: #8064a2;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: #8064a2;"&gt;for pageNum in range(1, 5):&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: #8064a2;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxd.dataDrivenPages.currentPageID = pageNum&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt; text-indent: 18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: #8064a2;"&gt;pageName = mxd.dataDrivenPages.pageRow.getValue(pageNameField)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt; text-indent: 18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: #8064a2;"&gt;pageName = pageName.replace("/", "_")&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt; text-indent: 18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: #8064a2;"&gt;pageName = pageName.replace(" ", "")&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt; text-indent: 18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: #8064a2;"&gt;print("page count {}".format(mxd.dataDrivenPages.pageCount))&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt; text-indent: 18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: #8064a2;"&gt;mxd.dataDrivenPages.refresh()&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-left: 18.0pt; text-indent: 18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: #8064a2;"&gt;arcpy.mapping.ExportToPDF(mxd, r"D:\TEMP\"&lt;/SPAN&gt; + str(pageName) + ".pdf")&lt;/P&gt;&lt;P style="margin-left: 18.0pt;"&gt;&lt;SPAN style="font-size: 10.0pt; color: #8064a2;"&gt;del mxd&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 15 Oct 2018 03:15:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-in-export-pdf-with-fieldname/m-p/572267#M44870</guid>
      <dc:creator>ChanYuk_Yu</dc:creator>
      <dc:date>2018-10-15T03:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: Python script in export pdf with fieldname</title>
      <link>https://community.esri.com/t5/python-questions/python-script-in-export-pdf-with-fieldname/m-p/572268#M44871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You shouldn't use backslashes to end a path.&lt;/P&gt;&lt;P&gt;Also, check the link I sent on Code Formatting, especially if you want to refer to line numbers&lt;/P&gt;&lt;DIV&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;a = r"D:\TEMP\"
&amp;nbsp; File "&amp;lt;ipython-input-1-c1bcefbc921d&amp;gt;", line 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; a = r"D:\TEMP\"
&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; ^
SyntaxError: EOL while scanning string literal


a = r"D:\TEMP" + "\\somefile" +".pdf"&amp;nbsp; # ---- or

"{}\\{}{}".format(r"D:\temp", "somefile", ".pdf")
'D:\\temp\\somefile.pdf'&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;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:38:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-script-in-export-pdf-with-fieldname/m-p/572268#M44871</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-12T00:38:35Z</dc:date>
    </item>
  </channel>
</rss>

