create a report with images with python

1396
2
12-05-2017 06:57 AM
MichaelKohler
Occasional Contributor II

Creating a report for a holiday lights system. Residents submit pictures, comments and address to the communications department. We run scripts to create a point FC from addresses and manage the publishing of the service on a nightly basis. We have a web app that lets users see the pictures, download pdfs showing the pictures with a map of the location and provide routing if they wish. We have maps generated with Data Driven Pages to create these pdfs. We want to add a report that shows the homes in a more condensed format. See the attached image for the report that was created within ArcMap. I want to export that with python but I get an error:

    print 'exporting summary report...'
    report_MapDoc = "\\\\netapp02\\data\\vol4\\mis\\GIS\\Enterprise\\MapDocs\\misgis0290\\HolidayLights.mxd"
    report_Layout = "\\\\netapp02\\data\\vol4\\mis\\GIS\\Enterprise\\MapDocs\\misgis0290\\HolidayLights.rlf"
    report_Output = "\\\\pslgis-vm\\webapp\\com\\HolidayLights\\images\\LightsReport.pdf"
    reportMxd =  arcpy.mapping.MapDocument(report_MapDoc)
    df = arcpy.mapping.ListDataFrames(reportMxd)[0]
    lyr = arcpy.mapping.ListLayers(df)[0]
    arcpy.Delete_management(report_Output)
    print lyr
    arcpy.mapping.ExportReport(lyr, report_Layout, report_Output)

and I get this error

Traceback (most recent call last):
  File "C:\PythonUpdateScripts\UpdateHolidayLights.py", line 279, in <module>
    main()
  File "C:\PythonUpdateScripts\UpdateHolidayLights.py", line 255, in main
    arcpy.mapping.ExportReport(lyr, report_Layout, report_Output)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\utils.py", line 182, in fn_
    return fn(*args, **kw)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\mapping.py", line 532, in ExportReport
    return report_source._arc_object.ExportReport(*gp_fixargs((report_layout_file, output_file, dataset_option, report_title, starting_page_number, page_range, report_definition_query, extent, field_map), True))
RuntimeError: Error in generating report

 If I remove the picture on the right for each record, the report runs as expected. Is this a limitation of using arcpy.mapping and reporting? 

Tags (1)
0 Kudos
2 Replies
DanPatterson_Retired
MVP Emeritus

why are you deleting  report_Output

before you are done with it

0 Kudos
MichaelKohler
Occasional Contributor II

I'm deleting the old copy from last night. the process is run nightly. This is just part of a much larger python script.

0 Kudos