AnsweredAssumed Answered

Exportreport with image included in pdf

Question asked by turnerkyle on Oct 12, 2016
Latest reply on Oct 17, 2016 by turnerkyle

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 ExportReport to see to what I am referring to) with only minor edits to the script. See below:


import arcpy, os
path = os.getcwd() #a relative path allowing for easy packaging
#Create PDF and remove if it already exists
pdfPath = path + r"\States_SubRegions.pdf"
if os.path.exists(pdfPath):
pdfDoc = arcpy.mapping.PDFDocumentCreate(pdfPath)
subRegionList = ["744","760"]
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
lyr = arcpy.mapping.ListLayers(mxd, "BuildingSpace_A")[0]
pageCount = 1
for region in subRegionList:
  #Generate image for each sub region
## whereClause = "facilityID = '" + region + "'"
## lyr.definitionQuery = whereClause
## arcpy.SelectLayerByAttribute_management(lyr, "NEW_SELECTION", whereClause)
## df.extent = lyr.getSelectedExtent()
## arcpy.SelectLayerByAttribute_management(lyr, "CLEAR_SELECTION"
   arcpy.mapping.ExportToBMP(mxd, path + "\RegionalPicture.bmp", df) #single file
#Generate report
   arcpy.mapping.ExportReport(report_source=lyr, report_layout_file=path + r"\custodial_areas.rlf", output_file=path + r"\temp" + str(pageCount) + ".pdf", dataset_option="USE_RLF",starting_page_number=pageCount)
#Append pages into final output
   pdfDoc.appendPages(path + r"\temp" + str(pageCount) + ".pdf")
   #os.remove(path + r"\temp.pdf")
   pageCount = pageCount + 1
del mxd


Maybe I don't understand the purpose of the script??

Your help is greatly appreciated and thanks in advance for any help.



I'm using v. 10.3.1 for Desktop

32 bit windows with 32 bit ESRI