<?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: Export Dataframe to PDF - extent problems in Transportation Questions</title>
    <link>https://community.esri.com/t5/transportation-questions/export-dataframe-to-pdf-extent-problems/m-p/664860#M2201</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You might want to check this out:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Bug NIM-052429&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Layer.getSelectedExtent() returns a different (bigger) extent than Geometry.extent and DataFrame.zoomToSelectedFeatures().&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://support.esri.com/en/bugs/nimbus/TklNMDUyNDI5"&gt;http://support.esri.com/en/bugs/nimbus/TklNMDUyNDI5&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have just come across a similar issue today in a while exporting maps to PDF. My python script was working fine with file geodatabase data but as soon as I switched to using SDE data sources this problem emerged.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 13 May 2014 05:50:30 GMT</pubDate>
    <dc:creator>OwenEarley</dc:creator>
    <dc:date>2014-05-13T05:50:30Z</dc:date>
    <item>
      <title>Export Dataframe to PDF - extent problems</title>
      <link>https://community.esri.com/t5/transportation-questions/export-dataframe-to-pdf-extent-problems/m-p/664859#M2200</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: Mannin&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;We are trying to create a new PDF for each polygon in our feature class.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The scale must stay the same, so the page size needs to change.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This also means that DataDrivenPages isn't a workable option for us for these products.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;We are exporting the dataframe, not the page_layout so that we can manipulate the page sizes programatically.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My current problem is that the resulting PDF does not have the same extent as what I see in ArcMap.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've attached images of the ArcMap dataframe (inside layout view) and the pdf export. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The exported PDF page size seems to be correct, so I believe we are converting from inches to pixels properly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But, I don't know why the extent does appear as expected.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any suggestions are greatly appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's my test code that I run from the Python window in the mxd:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os, math, time
arcpy.env.overwriteOutput = True
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]

df.scale = 31680 # set and keep dataframe scale at 1 inch = 1/2 mile

BULayer = arcpy.mapping.ListLayers(mxd,"BidUnits",df)[0]

arcpy.SelectLayerByAttribute_management(BULayer,"NEW_SELECTION","BID_UNIT = 8") #run on just one feature for testing

df.panToExtent(BULayer.getSelectedExtent()) # center dataframe on selected feature centroid

#get real world distance of selected feature - ArcMap 10.1 and later returns dataframe CS units on .getSelectedExtent call
#current dataframe CS is Web Mercator
y_dist_meters = BULayer.getSelectedExtent().YMax - BULayer.getSelectedExtent().YMin
x_dist_meters = BULayer.getSelectedExtent().XMax - BULayer.getSelectedExtent().XMin

#buffer the extent by a mile on each side
y_dist_meters += (1609*2)
x_dist_meters += (1609*2)
#convert distances to inches from meters
y_dist_inches = math.ceil(y_dist_meters * 39.3701)
x_dist_inches = math.ceil(x_dist_meters * 39.3701)

#calculate page size
y_inches = math.ceil(y_dist_inches / df.scale)
x_inches = math.ceil(x_dist_inches / df.scale)
print str(x_inches) + " x " + str(y_inches)

#set dataframe height and width
df.elementHeight = y_inches
df.elementWidth = x_inches

arcpy.RefreshActiveView()
#time.sleep(30) #test to see if a complete redraw affects results

#calculate page size in pixels based on pdf export resolution
pdfRes = 300
dfew = int(x_inches * pdfRes)
dfeh = int(y_inches * pdfRes)
PDF = "C:/gm_sts/bidunitmobilemaps/pdf/testing2.pdf"
#mxd.save() #test if mxd save affects results
arcpy.mapping.ExportToPDF(mxd,PDF,df,df_export_width=dfew,df_export_height=dfeh,resolution=pdfRes,image_quality="NORMAL",layers_attributes="NONE")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 04:06:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/export-dataframe-to-pdf-extent-problems/m-p/664859#M2200</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-12T04:06:18Z</dc:date>
    </item>
    <item>
      <title>Re: Export Dataframe to PDF - extent problems</title>
      <link>https://community.esri.com/t5/transportation-questions/export-dataframe-to-pdf-extent-problems/m-p/664860#M2201</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You might want to check this out:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Bug NIM-052429&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Layer.getSelectedExtent() returns a different (bigger) extent than Geometry.extent and DataFrame.zoomToSelectedFeatures().&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://support.esri.com/en/bugs/nimbus/TklNMDUyNDI5"&gt;http://support.esri.com/en/bugs/nimbus/TklNMDUyNDI5&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have just come across a similar issue today in a while exporting maps to PDF. My python script was working fine with file geodatabase data but as soon as I switched to using SDE data sources this problem emerged.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 13 May 2014 05:50:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/export-dataframe-to-pdf-extent-problems/m-p/664860#M2201</guid>
      <dc:creator>OwenEarley</dc:creator>
      <dc:date>2014-05-13T05:50:30Z</dc:date>
    </item>
  </channel>
</rss>

