<?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 report to PDF missing picture in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/export-report-to-pdf-missing-picture/m-p/1217784#M65719</link>
    <description>&lt;P&gt;Thank you for your answer! I had to remove some things out of privacy considerations:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

ZwolleOpdracht = xxx
ZwolleLekindicatie = xxx
Report = r"xxx.rptx"
output = xxx


arcpy.management.MakeFeatureLayer(ZwolleOpdracht, 'ZwolleOpdrachtTemp')
queryLekindicatie = """ {status} &amp;lt;&amp;gt; 'Verwerkt' """\
    .format(status=(arcpy.AddFieldDelimiters(ZwolleLekindicatie, "Status")))


with arcpy.da.SearchCursor(ZwolleLekindicatie, ["OBJECTID", "Status"], queryLekindicatie) as cursor:
    for x in cursor:
        queryLekindicatieTemp = """ {objectid} = {objectid2} """ \
            .format(objectid=(arcpy.AddFieldDelimiters(ZwolleLekindicatie, "OBJECTID")),
                    objectid2=x[0])
        print(queryLekindicatieTemp)
        arcpy.management.MakeFeatureLayer(ZwolleLekindicatie, 'ZwolleLekindicatieTemp{naam}'.format(naam=x[0]), queryLekindicatieTemp)
        SelectieWnummer = arcpy.management.SelectLayerByLocation('ZwolleOpdrachtTemp', "WITHIN_a_DISTANCE",
                                                                 "ZwolleLekindicatieTemp{naam}".format(naam=x[0]), 2, "NEW_SELECTION",
                                                                 "NOT_INVERT")
        with arcpy.da.SearchCursor(SelectieWnummer, ["OBJECTID", "Opdrachtnummer"]) as cursor2:
            for y in cursor2:
                wNummer = y[1]
                print(y[1])
        out_pdf = output + r"\{wnummer} Lekindicatie.pdf".format(wnummer=y[1])
        arcpy.management.ExportReportToPDF(Report, out_pdf, queryLekindicatieTemp, 300, "BEST", "", "", "JPEG")&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 30 Sep 2022 08:51:56 GMT</pubDate>
    <dc:creator>RoloSyuk</dc:creator>
    <dc:date>2022-09-30T08:51:56Z</dc:date>
    <item>
      <title>Export report to PDF missing picture</title>
      <link>https://community.esri.com/t5/python-questions/export-report-to-pdf-missing-picture/m-p/1217283#M65711</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having a problem with the ExportReportToPdf tool. When i export a report from ArcGis Pro it includes the attachment and company logo (PNG). However when i export via Python its missing the company logo and throws the following error:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="RoloSyuk_0-1664442080191.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/52487iEB0485A6FF2376D7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="RoloSyuk_0-1664442080191.png" alt="RoloSyuk_0-1664442080191.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried using a TIFF instead of the PNG, but the same kind of error is thrown.&lt;/P&gt;&lt;P&gt;I access the report from the exported report file (rptx file). This file seems to be ok.&lt;/P&gt;&lt;P&gt;Does anybody know why it is not exporting the full report with the PNG?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 09:10:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-report-to-pdf-missing-picture/m-p/1217283#M65711</guid>
      <dc:creator>RoloSyuk</dc:creator>
      <dc:date>2022-09-29T09:10:05Z</dc:date>
    </item>
    <item>
      <title>Re: Export report to PDF missing picture</title>
      <link>https://community.esri.com/t5/python-questions/export-report-to-pdf-missing-picture/m-p/1217361#M65713</link>
      <description>&lt;P&gt;It would help to share your code that you have.&amp;nbsp; Click the ... and then click the &amp;lt;/&amp;gt; icon to open a window where you can paste your code.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 13:30:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-report-to-pdf-missing-picture/m-p/1217361#M65713</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-09-29T13:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: Export report to PDF missing picture</title>
      <link>https://community.esri.com/t5/python-questions/export-report-to-pdf-missing-picture/m-p/1217784#M65719</link>
      <description>&lt;P&gt;Thank you for your answer! I had to remove some things out of privacy considerations:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

ZwolleOpdracht = xxx
ZwolleLekindicatie = xxx
Report = r"xxx.rptx"
output = xxx


arcpy.management.MakeFeatureLayer(ZwolleOpdracht, 'ZwolleOpdrachtTemp')
queryLekindicatie = """ {status} &amp;lt;&amp;gt; 'Verwerkt' """\
    .format(status=(arcpy.AddFieldDelimiters(ZwolleLekindicatie, "Status")))


with arcpy.da.SearchCursor(ZwolleLekindicatie, ["OBJECTID", "Status"], queryLekindicatie) as cursor:
    for x in cursor:
        queryLekindicatieTemp = """ {objectid} = {objectid2} """ \
            .format(objectid=(arcpy.AddFieldDelimiters(ZwolleLekindicatie, "OBJECTID")),
                    objectid2=x[0])
        print(queryLekindicatieTemp)
        arcpy.management.MakeFeatureLayer(ZwolleLekindicatie, 'ZwolleLekindicatieTemp{naam}'.format(naam=x[0]), queryLekindicatieTemp)
        SelectieWnummer = arcpy.management.SelectLayerByLocation('ZwolleOpdrachtTemp', "WITHIN_a_DISTANCE",
                                                                 "ZwolleLekindicatieTemp{naam}".format(naam=x[0]), 2, "NEW_SELECTION",
                                                                 "NOT_INVERT")
        with arcpy.da.SearchCursor(SelectieWnummer, ["OBJECTID", "Opdrachtnummer"]) as cursor2:
            for y in cursor2:
                wNummer = y[1]
                print(y[1])
        out_pdf = output + r"\{wnummer} Lekindicatie.pdf".format(wnummer=y[1])
        arcpy.management.ExportReportToPDF(Report, out_pdf, queryLekindicatieTemp, 300, "BEST", "", "", "JPEG")&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 30 Sep 2022 08:51:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-report-to-pdf-missing-picture/m-p/1217784#M65719</guid>
      <dc:creator>RoloSyuk</dc:creator>
      <dc:date>2022-09-30T08:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: Export report to PDF missing picture</title>
      <link>https://community.esri.com/t5/python-questions/export-report-to-pdf-missing-picture/m-p/1217868#M65720</link>
      <description>&lt;P&gt;Nested cursors can cause a bad time.&amp;nbsp; lines 28 and 29- are they on the right indent level? As is, they are outside of the cursor 2 scope and once the for y in cursor2 loop completes, y[1] shouldn't exist.&lt;/P&gt;&lt;P&gt;I'd recommend building a dictionary of objectid's from the first cursor, and then iterate over the dictionary to perform the select by location.&lt;/P&gt;&lt;P&gt;Is that second cursor just to get the wNummer? The expression in the ExportReportToPDF is using the OBJECTID of the first cursor, so its not picking up/using the OBJECTID of the second cursor, if that is your intention.&amp;nbsp; Could need a new sql query using OBJECTIDS from the second featureclass? Maybe something like:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.management.MakeFeatureLayer(ZwolleOpdracht, 'ZwolleOpdrachtTemp')
queryLekindicatie = f"""{arcpy.AddFieldDelimiters(ZwolleLekindicatie, 'Status')} &amp;lt;&amp;gt; 'Verwerkt'"""
# create dictionary of objectids and other fields from first featureclass
feat_dict = {x[0]: {'OBJECTID': x[0], 'Status': x[1]} for x in arcpy.da.SearchCursor(ZwolleLekindicatie, ["OBJECTID", "Status"], queryLekindicatie)}

# iterate over the dictionary to select by location from other featureclass
for k, v in feat_dict.items():
    queryLekindicatieTemp = f"""{arcpy.AddFieldDelimiters(ZwolleLekindicatie, 'OBJECTID')} = {v['OBJECTID']} """
    print(f"OBJECTID: {k}\t status: {v['Status']}\t queryLekindicatieTemp: {queryLekindicatieTemp}")

    arcpy.management.MakeFeatureLayer(ZwolleLekindicatie, f"ZwolleLekindicatieTemp{v['OBJECTID']}", queryLekindicatieTemp)

    SelectieWnummer = arcpy.management.SelectLayerByLocation('ZwolleOpdrachtTemp', "WITHIN_A_DISTANCE",                                                            f"ZwolleLekindicatieTemp{v['OBJECTID']}", 2, "NEW_SELECTION")

    with arcpy.da.SearchCursor(SelectieWnummer, ["OBJECTID", "Opdrachtnummer"]) as cursor2:
        objectids = []
        out_pdf = None
        for y in cursor2:
            wNummer = y[1]
            print(y[1])
            out_pdf = output + r"\{wnummer} Lekindicatie.pdf".format(wnummer=y[1])
            objectids.append(y[0])
            
        sql = f"""{'OBJECTID'} IN ({str(objectids)[1:-1]})"""   
        arcpy.management.ExportReportToPDF(Report, out_pdf, sql, 300, "BEST", "", "", "JPEG")
    &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2022 13:20:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-report-to-pdf-missing-picture/m-p/1217868#M65720</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-09-30T13:20:04Z</dc:date>
    </item>
  </channel>
</rss>

