<?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 ExportToPDF Q in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/exporttopdf-q/m-p/119516#M9405</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: arial black,avant garde;"&gt;My fellow mappers split taxparcel and part of the splitting process they have to include a pdf or jpg of the split with the new split/adjusted parcel, example &lt;SPAN style="font-family: arial black,avant garde;"&gt;attached &lt;/SPAN&gt;(Split(2).png) . I am trying automate the process to make it easier for them as it currently take multiple steps to create this split print out. They currently have driven data pages set up but they don't need the layout of the driven pages they need just a basic exported map like the one i have attached with a few items, like the north arrow and scale bar and possibly initials of the mapper ,&lt;SPAN style="font-family: arial black,avant garde;"&gt; as example &lt;SPAN style="font-family: arial black,avant garde;"&gt;&lt;SPAN style="font-family: arial black,avant garde;"&gt;attached &lt;/SPAN&gt;(Split(2).png) &lt;/SPAN&gt;&lt;/SPAN&gt;. I have currently looked through &lt;/SPAN&gt;&lt;CODE&gt;&lt;SPAN style="color: #303030;"&gt;&lt;SPAN style="font-family: arial black,avant garde;"&gt;&lt;SPAN class="n"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;mapping&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;ListLayoutElements but i am not sure if arcpy can create new features like the north arrow, scale bar and text. If so how?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="p"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN class="n"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN class="n"&gt;The current code creates a pdf of the selected parcel. I noticed that if i add "df" to the {data_frame} in &lt;CODE&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN class="n"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;mapping&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;CODE&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN class="n"&gt;ListLayoutElem&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;CODE&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN class="n"&gt;ents it exports the like the following attached Split_df.png. If a file, export map and chose pdf, it looks alot better then using arcpy.mapping.ExportToPDF, why is this?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN class="n"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN class="n"&gt;&lt;CODE&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN class="n"&gt; if i removed the "df". it will defult to PAGE_LAYOUT.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN class="n"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN class="n"&gt;code&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os

import arcpy.mapping
from arcpy import env

# Set workspace
arcpy.env.workspace = "C:/Temp"
arcpy.env.overwriteOutput = 'True'
env.qualifiedFieldNames = False

directory="C:/Temp/Split.pdf"
if os.path.exists(directory):
&amp;nbsp;&amp;nbsp;&amp;nbsp; try:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; os.remove(directory)
&amp;nbsp;&amp;nbsp;&amp;nbsp; except:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Exception: ",str(sys.exc_info())
else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'File not found at ',directory

#deletes the geodatabase prior if it exists
try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if arcpy.Exists("C:/temp/NewFeatures.shp"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management("C:/temp/NewFeatures.shp")
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; pass&amp;nbsp;&amp;nbsp;&amp;nbsp; 


mxd = arcpy.mapping.MapDocument("current")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "DSD.DBO.TaxParcels")[0]


if int(arcpy.GetCount_management("TaxParcels").getOutput(0)) &amp;gt; 0:
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.FeatureClassToFeatureClass_conversion("TaxParcels", "C:/temp", "NewFeatures.shp")

#Adding Labels
layer = arcpy.mapping.ListLayers(mxd, "NewFeatures")[0] 
if layer.supports("LABELCLASSES"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; for lblclass in layer.labelClasses:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lblclass.className = "DXF_TEXT" 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lblclass.expression = '"%s" &amp;amp; [DXF_TEXT] &amp;amp; VBNewLine &amp;amp; "AC" &amp;amp; " " &amp;amp; Round([ACRES],2)&amp;amp; "%s"' % ("&amp;lt;BOL&amp;gt;&amp;lt;CLR red='140'&amp;gt;&amp;lt;FNT size='12'&amp;gt;" , "&amp;lt;/FNT&amp;gt;&amp;lt;/CLR&amp;gt;&amp;lt;/BOL&amp;gt;") #WORKS!
&amp;nbsp;&amp;nbsp;&amp;nbsp; lblclass.showClassLabels = True
layer.showLabels = True
df.extent = lyr.getSelectedExtent()
df.scale = 10000
arcpy.RefreshActiveView()

arcpy.mapping.ExportToPDF(mxd,"C:/Temp/Split.pdf",df)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 06:58:22 GMT</pubDate>
    <dc:creator>CCWeedcontrol</dc:creator>
    <dc:date>2021-12-11T06:58:22Z</dc:date>
    <item>
      <title>ExportToPDF Q</title>
      <link>https://community.esri.com/t5/python-questions/exporttopdf-q/m-p/119516#M9405</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: arial black,avant garde;"&gt;My fellow mappers split taxparcel and part of the splitting process they have to include a pdf or jpg of the split with the new split/adjusted parcel, example &lt;SPAN style="font-family: arial black,avant garde;"&gt;attached &lt;/SPAN&gt;(Split(2).png) . I am trying automate the process to make it easier for them as it currently take multiple steps to create this split print out. They currently have driven data pages set up but they don't need the layout of the driven pages they need just a basic exported map like the one i have attached with a few items, like the north arrow and scale bar and possibly initials of the mapper ,&lt;SPAN style="font-family: arial black,avant garde;"&gt; as example &lt;SPAN style="font-family: arial black,avant garde;"&gt;&lt;SPAN style="font-family: arial black,avant garde;"&gt;attached &lt;/SPAN&gt;(Split(2).png) &lt;/SPAN&gt;&lt;/SPAN&gt;. I have currently looked through &lt;/SPAN&gt;&lt;CODE&gt;&lt;SPAN style="color: #303030;"&gt;&lt;SPAN style="font-family: arial black,avant garde;"&gt;&lt;SPAN class="n"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;mapping&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;ListLayoutElements but i am not sure if arcpy can create new features like the north arrow, scale bar and text. If so how?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="p"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN class="n"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN class="n"&gt;The current code creates a pdf of the selected parcel. I noticed that if i add "df" to the {data_frame} in &lt;CODE&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN class="n"&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;SPAN class="n"&gt;mapping&lt;/SPAN&gt;&lt;SPAN class="o"&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;CODE&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN class="n"&gt;ListLayoutElem&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;CODE&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN class="n"&gt;ents it exports the like the following attached Split_df.png. If a file, export map and chose pdf, it looks alot better then using arcpy.mapping.ExportToPDF, why is this?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN class="n"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN class="n"&gt;&lt;CODE&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN class="n"&gt; if i removed the "df". it will defult to PAGE_LAYOUT.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN class="n"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN style="color: #303030; font-family: arial black,avant garde;"&gt;&lt;SPAN class="n"&gt;code&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os

import arcpy.mapping
from arcpy import env

# Set workspace
arcpy.env.workspace = "C:/Temp"
arcpy.env.overwriteOutput = 'True'
env.qualifiedFieldNames = False

directory="C:/Temp/Split.pdf"
if os.path.exists(directory):
&amp;nbsp;&amp;nbsp;&amp;nbsp; try:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; os.remove(directory)
&amp;nbsp;&amp;nbsp;&amp;nbsp; except:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Exception: ",str(sys.exc_info())
else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print 'File not found at ',directory

#deletes the geodatabase prior if it exists
try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if arcpy.Exists("C:/temp/NewFeatures.shp"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Delete_management("C:/temp/NewFeatures.shp")
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; pass&amp;nbsp;&amp;nbsp;&amp;nbsp; 


mxd = arcpy.mapping.MapDocument("current")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "DSD.DBO.TaxParcels")[0]


if int(arcpy.GetCount_management("TaxParcels").getOutput(0)) &amp;gt; 0:
&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.FeatureClassToFeatureClass_conversion("TaxParcels", "C:/temp", "NewFeatures.shp")

#Adding Labels
layer = arcpy.mapping.ListLayers(mxd, "NewFeatures")[0] 
if layer.supports("LABELCLASSES"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; for lblclass in layer.labelClasses:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lblclass.className = "DXF_TEXT" 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lblclass.expression = '"%s" &amp;amp; [DXF_TEXT] &amp;amp; VBNewLine &amp;amp; "AC" &amp;amp; " " &amp;amp; Round([ACRES],2)&amp;amp; "%s"' % ("&amp;lt;BOL&amp;gt;&amp;lt;CLR red='140'&amp;gt;&amp;lt;FNT size='12'&amp;gt;" , "&amp;lt;/FNT&amp;gt;&amp;lt;/CLR&amp;gt;&amp;lt;/BOL&amp;gt;") #WORKS!
&amp;nbsp;&amp;nbsp;&amp;nbsp; lblclass.showClassLabels = True
layer.showLabels = True
df.extent = lyr.getSelectedExtent()
df.scale = 10000
arcpy.RefreshActiveView()

arcpy.mapping.ExportToPDF(mxd,"C:/Temp/Split.pdf",df)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:58:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporttopdf-q/m-p/119516#M9405</guid>
      <dc:creator>CCWeedcontrol</dc:creator>
      <dc:date>2021-12-11T06:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: ExportToPDF Q</title>
      <link>https://community.esri.com/t5/python-questions/exporttopdf-q/m-p/119517#M9406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;it is specific in the help &lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/exporttopdf.htm" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/exporttopdf.htm"&gt;ExportToPDF—Help | ArcGIS for Desktop&lt;/A&gt; &lt;/P&gt;&lt;P&gt;one way exports the dataframe and the other the layout. .... so with what looks best or what is needed&lt;/P&gt;&lt;TABLE class="arcpyclass_paramtbl" style="margin-bottom: 1.5em; font-size: 0.875em; font-family: 'Lucida Grande', 'Segoe UI', Arial, sans-serif; background-color: white; border: 1px solid #dddddd; color: #4d4d4d;"&gt;&lt;TBODY&gt;&lt;TR style="border-bottom-width: 1px; border-bottom-color: #dddddd;"&gt;&lt;TD style="border-left-width: 1px; border-left-style: solid; border-left-color: #dddddd; border-right-width: 1px; border-right-style: solid; border-right-color: #dddddd; padding: 12px;"&gt;&lt;P&gt;data_frame&lt;/P&gt;&lt;/TD&gt;&lt;TD style="border-left-width: 1px; border-left-style: solid; border-left-color: #dddddd; border-right-width: 1px; border-right-style: solid; border-right-color: #dddddd; padding: 12px;"&gt;&lt;P style="font-size: 0.875rem;"&gt;A variable that references a &lt;A class="xref" href="http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-mapping/dataframe-class.htm" style="color: #007ac2;"&gt;DataFrame&lt;/A&gt; object. Use the string/constant "PAGE_LAYOUT" to export the map document's page layout instead of an individual data frame.&lt;/P&gt;&lt;P style="font-size: 0.875rem; margin-top: 1.71429em;"&gt;(The default value is PAGE_LAYOUT)&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 04 Apr 2016 17:56:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exporttopdf-q/m-p/119517#M9406</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-04-04T17:56:43Z</dc:date>
    </item>
  </channel>
</rss>

