Export Report To PDF (Data Management)

Summary

Exports an ArcGIS Pro report to a PDF file.

Learn more about reports and how to add, modify and share them.

Usage

  • This tool creates a PDF report from a report in an ArcGIS Pro project or a report file (.rptx)

  • If a query exists in the report or report file definition, additional expressions are appended to the existing query.

  • This tool supports page range settings to export certain pages in addition to the entire report.

  • This tool supports custom page numbering options to modify start and total page numbers.

Syntax

ExportReportToPDF(in_report, out_pdf_file, {expression}, {resolution}, {image_quality}, {embed_font}, {compress_vector_graphics}, {image_compression}, {password_protect}, {pdf_password}, {page_range_type}, {custom_page_range}, {initial_page_number}, {final_page_number})
ParameterExplanationData Type
in_report

The input report or .rptx file.

Report; File
out_pdf_file

The output PDF file.

File
expression
(Optional)

An SQL expression used to select a subset of records. This expression is applied in addition to any existing expressions. For more information on SQL syntax, see SQL reference for query expressions used in ArcGIS.

SQL Expression
resolution
(Optional)

The resolution of the exported PDF in dots per inch (dpi).

Long
image_quality
(Optional)

Defines the output image quality of the PDF. The image quality option controls the quality of rasterized data going into the export.

  • BESTThe highest available image quality. This is the default.
  • BETTERHigh image quality.
  • NORMALA compromise between image quality and speed.
  • FASTERLower image quality to generate the report faster.
  • FASTESTThe lowest image quality to create the report the fastest.
String
embed_font
(Optional)

Specify if fonts are embedded in the output report. Font embedding allows text and markers built from font glyphs to be displayed correctly when the PDF is viewed on a computer that does not have the necessary fonts installed.

  • EMBED_FONTSFonts will be embedded in the output report. This is the default.
  • NO_EMBED_FONTSFonts will not be embedded in the output report.
Boolean
compress_vector_graphics
(Optional)

Compress the vector content streams in the PDF.

  • COMPRESS_GRAPHICSVector graphics will be compressed. This option should be set unless clear text is desired for troubleshooting. This is the default.
  • NO_COMPRESS_GRAPHICSVector graphics will not be compressed.
Boolean
image_compression
(Optional)

Defines the compression scheme used to compress image or raster data in the output PDF file.

  • NONEDo not compress image or raster data.
  • RLEUses Run-length encoded compression.
  • DEFLATEUses Deflate, a lossless data compression.
  • LZWUses Lempel-Ziv-Welch, a lossless data compression.
  • JPEGUses JPEG, a lossy data compression.
  • ADAPTIVEUses Adaptive, which automatically selects the best compression type for each image on the page. JPEG will be used for large images with many unique colors. Deflate will be used for all other images. This is the default.
String
password_protect
(Optional)

Specify if password protection is needed to view the output PDF report.

  • PASSWORD_PROTECTThe output PDF report document will require a password to open.
  • NO_PASSWORD_PROTECTThe output PDF report document can be opened without providing a password. This is the default.
Boolean
pdf_password
(Optional)

Provide a password to restrict opening the PDF.

Encrypted String
page_range_type
(Optional)

Specify the page range of the report to export.

  • ALLExport all pages. This is the default.
  • LASTExport the last page only.
  • ODDExport the odd numbered pages.
  • EVENExport the even numbered pages.
  • CUSTOMExport a custom page range.
String
custom_page_range
(Optional)

Specify the pages to be exported when the page_range_type parameter is set to CUSTOM. You can set individual pages, ranges, or a combination of both separated by commas, such as 1, 3-5, 10.

String
initial_page_number
(Optional)

Specify the initial page number of the report to create a page numbering offset to add additional pages to the beginning of the report.

Long
final_page_number
(Optional)

Specify the total number of pages to display on the last page of the exported PDF.

Long

Code sample

ExportReportToPDF example 1 (Python window)

The following Python window script demonstrates how to use the ExportReportToPDF tool.

import arcpy
arcpy.ExportReportToPDF_management("C:/data/sample.rptx", "C:/data/samplePDF.pdf"", "STATEFIPS = 42", 96, 'BETTER', 'EMBED_FONTS', 'COMPRESS_GRAPHICS', 'ADAPTIVE',
		'PASSWORD_PROTECT', "password", 'CUSTOM', "1-10")
ExportReportToPDF example 2 (stand-alone script)

Use the ExportReportToPDF tool to export a report after performing a selection on the data source.

# ExportReportToPDF.py
# Simple example of the Export Report to PDF tool

# Import system variables
import arcpy
from arcpy import env

# Set the workspace
env.workspace = "C:/data/cities.gdb"

# Set local variables
in_layer = 'cities'
in_report = 'US Cities Report'
out_PDF = 'C/data/cities.pdf'

# Modify the report data source by selecting only the records where POP1990 < 50000
arcpy.SelectLayerByAttribute_management(in_layer, 'NEW_SELECTION', 'POP1990 < 50000')

# Export the report with the layer selection set
arcpy.ExportReportToPDF_management(in_report, out_PDF)
ExportReportToPDF example 3 (stand-alone script)

Use the Python API in addition to the ExportReportToPDF tool.

# ExportReporttoPDFAPI.py
# Simple example of exporting a report using Python

# Import system variables
import arcpy

# Identify all parcel reports in a project
aprx = arcpy.mp.ArcGISProject("C:/data/parcels/Parcels.aprx")
report = aprx.listReports("Parcels Report")[0]

# Export the report with a definition query
arcpy.ExportReportToPDF_management(report.name, "C:/data/parcels/ParcelsPDF.pdf", 
                                   ' "LotSize" > 325 ')

Environments

This tool does not use any geoprocessing environments.

Licensing information

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes

Related topics