Export to PDF Report using Python shows OSError: Report: Unable to write PDF to location in ArcGIS Pro 2.6.1

1896
3
09-25-2020 07:30 AM
ManishPatel
Esri Contributor

Hello Experts,

I have been trying to use the python script as below to export a report to PDF document. The code seems to be working fine for ArcGIS Pro 2.3 however the same code shows error unable to write to location with ArcGIS Pro 2.6.1

Steps to reproduce:

1. Create a report in ArcGIS Pro 2.6.1

2. In the Python console, try the below code:

arpx = arcpy.mp.ArcGISProject(r"C:\Users\Administrator\Documents\ArcGIS\Projects\PrintTemplate\PrintTemplate.aprx")

report = arpx.listReports()[0]

report.exportToPDF(r"c:\test.pdf")

Error as shown in the below screenshot:

Error

I have tried with different systems, and even tried granting full access but no success.

Appreciate if anyone has faced this issue and can provide some workaround.

Cheers,
Manish

Cheers,
Manish
0 Kudos
3 Replies
Arne_Gelfert
Occasional Contributor III

Try this before trying to export:

pdfPath = r"c:\test.pdf"
pdfDoc = arcpy.mp.PDFDocumentCreate(pdfPath)

Then run your export as:

report.exportToPDF(pdfDoc)
ManishPatel
Esri Contributor

Hi Arne Gelfert,

Thanks for the suggestion, it seems there environment issue, when I tried to use a different location it seems to be working fine.

Cheers,

Manish

Cheers,
Manish
atrunkl
New Contributor

Hallo,

I found this thread because I have the same problem as described above.

The script for printing on the server that I found and modified from:

https://www.esri.com/arcgis-blog/products/arcgis-enterprise/mapping/print-reports-from-arcgis-enterp...

works on my Pro machine but when I publish a WebTool on portal it dies out with the above error:

OSError: Report: Unable to write PDF to location. I have tried modifying the script and running it standalone on the server with the same result.

The only thing is that it actually produces the report with only one blank page (my report is a little bit clumsy made since is only a POC).

Arcgis Pro is 2.8.2

Arcgis Portal and Server are 10.8.1 and are federated.

 

Any help would be appreciated.

Thanks.

Bye Andrej

0 Kudos