<?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: Exportreport with image included in pdf in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/exportreport-with-image-included-in-pdf/m-p/466959#M36495</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For anybody interested, I figured out how to complete my task.&lt;/P&gt;&lt;P&gt;First my previous response didn't quite solve my problem. It created a separate map layout page then a separate report page which&amp;nbsp;then combined into a two page document. However, I wanted the report to be on the same layout page. So my solution was the following:&lt;/P&gt;&lt;P&gt;I used ExportReport to create the report as a tif image. Then, with an existing picture element on the page layout, I simply remapped the picture source to the newly created tif source path. Then I simply exported the&amp;nbsp;page layout with the included report to a pdf document (of course this can be included in a loop for multiple areas/items...which is in fact what I did).&lt;/P&gt;&lt;P&gt;However, there is one caveat....when the code attempts to remove all the temporary tifs I get the error that the last tif is in use because, it is in fact in use. Yet, my task is complete because the pdf of the page layout with the report included was successfully created. (Poor programming I know, but I'm not a coder and it does what I need it to do.)&lt;/P&gt;&lt;P&gt;If anyone is interested in seeing the code I am more than glad to provide it.&lt;/P&gt;&lt;P&gt;Cheers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 17 Oct 2016 17:31:31 GMT</pubDate>
    <dc:creator>kyleturner</dc:creator>
    <dc:date>2016-10-17T17:31:31Z</dc:date>
    <item>
      <title>Exportreport with image included in pdf</title>
      <link>https://community.esri.com/t5/python-questions/exportreport-with-image-included-in-pdf/m-p/466954#M36490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;I'm trying to write a script to export a report that includes a map in the output pdf. While the script will create the pdf report and a separate .emf file, the script won't include the emf image in the pdf document. I have copy/pasted the example from the Desktop help (search for&amp;nbsp;ExportReport to see to what I am referring to)&amp;nbsp;with only minor edits to the script. See below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; os
path &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;getcwd&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#a relative path allowing for easy packaging&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;#Create PDF and remove if it already exists&lt;/SPAN&gt;
pdfPath &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; path &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"\States_SubRegions.pdf"&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;path&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;exists&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;pdfPath&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; os&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;remove&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;pdfPath&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
pdfDoc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;PDFDocumentCreate&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;pdfPath&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
subRegionList &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"744"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"760"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
mxd &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapDocument&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"CURRENT"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
df &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListDataFrames&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
lyr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListLayers&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"BuildingSpace_A"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&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="keyword token"&gt;for&lt;/SPAN&gt; region &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; subRegionList&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="comment token"&gt;#Generate image for each sub region&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;## whereClause = "facilityID = '" + region + "'"&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;## lyr.definitionQuery = whereClause&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;## arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", whereClause)&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;## df.extent = lyr.getSelectedExtent()&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;## arcpy.SelectLayerByAttribute_management(lyr, "CLEAR_SELECTION"&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ExportToBMP&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; path &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"\RegionalPicture.bmp"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; df&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;#single file&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;#Generate report&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ExportReport&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;report_source&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;lyr&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; report_layout_file&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;path &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"\custodial_areas.rlf"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; output_file&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;path &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"\temp"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;pageCount&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;".pdf"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; dataset_option&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"USE_RLF"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;starting_page_number&lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;pageCount&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;#Append pages into final output&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp; pdfDoc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;appendPages&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;path &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; r&lt;SPAN class="string token"&gt;"\temp"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; str&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;pageCount&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;".pdf"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp; &lt;SPAN class="comment token"&gt;#os.remove(path + r"\temp.pdf")&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp; pageCount &lt;SPAN class="operator 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;
pdfDoc&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;saveAndClose&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;del&lt;/SPAN&gt; mxd &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;/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;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;P&gt;&lt;/P&gt;&lt;P&gt;Maybe I don't understand the purpose of the script??&lt;/P&gt;&lt;P&gt;Your help is greatly appreciated and thanks in advance for any help.&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I'm using v. 10.3.1 for Desktop&lt;/P&gt;&lt;P&gt;32 bit windows with 32 bit ESRI&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:43:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exportreport-with-image-included-in-pdf/m-p/466954#M36490</guid>
      <dc:creator>kyleturner</dc:creator>
      <dc:date>2021-12-11T20:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: Exportreport with image included in pdf</title>
      <link>https://community.esri.com/t5/python-questions/exportreport-with-image-included-in-pdf/m-p/466955#M36491</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;could you please format the code so it is readable Kyle&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting"&gt;/blogs/dan_patterson/2016/08/14/script-formatting&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Oct 2016 14:56:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exportreport-with-image-included-in-pdf/m-p/466955#M36491</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2016-10-12T14:56:09Z</dc:date>
    </item>
    <item>
      <title>Re: Exportreport with image included in pdf</title>
      <link>https://community.esri.com/t5/python-questions/exportreport-with-image-included-in-pdf/m-p/466956#M36492</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry about the formatting. I couldn't figure it out....I thought that was what the &amp;lt;code&amp;gt;&amp;lt;/code&amp;gt; tags were for.&lt;/P&gt;&lt;P&gt;Thanks for the link.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Oct 2016 15:05:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exportreport-with-image-included-in-pdf/m-p/466956#M36492</guid>
      <dc:creator>kyleturner</dc:creator>
      <dc:date>2016-10-12T15:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: Exportreport with image included in pdf</title>
      <link>https://community.esri.com/t5/python-questions/exportreport-with-image-included-in-pdf/m-p/466957#M36493</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Correction:&lt;/P&gt;&lt;P&gt;I'm using 64 bit windows 7&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Oct 2016 15:07:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exportreport-with-image-included-in-pdf/m-p/466957#M36493</guid>
      <dc:creator>kyleturner</dc:creator>
      <dc:date>2016-10-12T15:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: Exportreport with image included in pdf</title>
      <link>https://community.esri.com/t5/python-questions/exportreport-with-image-included-in-pdf/m-p/466958#M36494</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For whatever unknown reason I got a more complex script to work. However, instead of exporting to emf, I exported the page layout to pdf and then combined that with the report pdf.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Oct 2016 18:31:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exportreport-with-image-included-in-pdf/m-p/466958#M36494</guid>
      <dc:creator>kyleturner</dc:creator>
      <dc:date>2016-10-12T18:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: Exportreport with image included in pdf</title>
      <link>https://community.esri.com/t5/python-questions/exportreport-with-image-included-in-pdf/m-p/466959#M36495</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For anybody interested, I figured out how to complete my task.&lt;/P&gt;&lt;P&gt;First my previous response didn't quite solve my problem. It created a separate map layout page then a separate report page which&amp;nbsp;then combined into a two page document. However, I wanted the report to be on the same layout page. So my solution was the following:&lt;/P&gt;&lt;P&gt;I used ExportReport to create the report as a tif image. Then, with an existing picture element on the page layout, I simply remapped the picture source to the newly created tif source path. Then I simply exported the&amp;nbsp;page layout with the included report to a pdf document (of course this can be included in a loop for multiple areas/items...which is in fact what I did).&lt;/P&gt;&lt;P&gt;However, there is one caveat....when the code attempts to remove all the temporary tifs I get the error that the last tif is in use because, it is in fact in use. Yet, my task is complete because the pdf of the page layout with the report included was successfully created. (Poor programming I know, but I'm not a coder and it does what I need it to do.)&lt;/P&gt;&lt;P&gt;If anyone is interested in seeing the code I am more than glad to provide it.&lt;/P&gt;&lt;P&gt;Cheers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Oct 2016 17:31:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/exportreport-with-image-included-in-pdf/m-p/466959#M36495</guid>
      <dc:creator>kyleturner</dc:creator>
      <dc:date>2016-10-17T17:31:31Z</dc:date>
    </item>
  </channel>
</rss>

