Export a report to PDF using Python

1286
9
04-16-2019 02:01 AM
DmitryKirianov
New Contributor

Hi all,

I'm trying to export a report to PDF via report.exportToPDF (as described into help section). The script works fine but the created PDF's size is too big (~50 Mb) because all the pages of the report are rasterized.. Comparing with the file created via UI (ArcGIS Pro -> Report -> Share as PDF) which is about ~600 kb.. cause this file is in "vector" normal PDF format (except for small pictures with logo).

So, the question: is it possible to export report into PDF via arcpy the same way like from ArcGIS Pro UI?

I'm using latest version of ArcGIS Pro 2.3.2. and default python 3 environment.

Example of the code:

import arcpy, datetime, os

      # Set parameters for the main report & create PDF
aprx = arcpy.mp.ArcGISProject(r"c:\NGM_GIS\NG_Projects_all\NG_Projects_all.aprx")
report = aprx.listReports("TenementExtract Report TEST A3")[0]
outPDF_report = r"c:\NGM_GIS\NG_Projects_all\ReportTEST\NG Tenement Report A3.pdf"
if os.path.exists(outPDF_report): os.remove(outPDF_report)
report.exportToPDF(outPDF_report)
print("PDF report is created!")

I've already tried to insert different parameters into report.exportToPDF e.g.

1) compress_vector_graphics=True,

2) embed_fonts=True

3) image_compression = "NONE"

- always receive the same result...

P.S.  in contrast exportToPDF works perfect with Layouts.

0 Kudos
9 Replies
DanPatterson_Retired
MVP Esteemed Contributor

Did you try setting 'embed_fonts' to false?  I am wondering if the defaults in

Report—ArcPy | ArcGIS Desktop 

are the same as used in the UI

0 Kudos
DmitryKirianov
New Contributor

Dan,

yes, i've tried switch "embed_fonts" to false - nothing changed..

While it's not clear why this parameter can influence and also i would like to have final PDF with all the fonts embed. 

BTW, attached are the 2 printscreens showing the properties for the 2 different PDFs. It's obvious that they've been produced by different applications but i can't see any other differences.. and as i mentioned above exportToPDF (python console...) works fine for the layouts. 

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

Dmitry... one person might know...

Kory Kramer‌ are the print engines the same in Pro from the UI vs script?

0 Kudos
KoryKramer
Esri Community Moderator

Forwarding this question to Jeremy Wright

are the print engines the same in Pro from the UI vs script?
0 Kudos
JeremyWright
Esri Regular Contributor

Let me correspond with the product team responsible for the reports functionality and get back to you all.

0 Kudos
DonMorrison1
Occasional Contributor III

Jeremy Wright , did you ever get an answer to this?  I'm about to recommend that we use the ArcGIS Pro reporting function for one of our projects but this might be a deal breaker since we will be generating a large number of documents. I'd much rather find out now than after we have invested a lot of time on it. Thanks

0 Kudos
DanPatterson
MVP Esteemed Contributor

That was a few versions ago with no report back.

If you have a test report, either try the tool

Export Report To PDF (Data Management)—ArcGIS Pro | Documentation 

or through arcpy

Report—ArcGIS Pro | Documentation 

or you could look back in time to see if it was addressed

Release notes for ArcGIS Pro 2.6—ArcGIS Pro | Documentation 

plus previous versions


... sort of retired...
0 Kudos
DmitryKirianov
New Contributor

Hi all,

 

It seems they have fixed the issue many months ago... i'm sure even in Pro 2.5 (or probably earlier) it worked fine and at the moment i'm using latest Pro 2.6.1 and it's ok. 

0 Kudos
DonMorrison1
Occasional Contributor III

I think you are correct.  I'm not seeing any problem - at least with the PDFs that I'm generating.

0 Kudos