layer.exportToPDF(filePath) OSError on _arc_object.exportToPDF

813
3
01-07-2021 08:00 AM
VictorTey
Esri Contributor

Hi, I have a piece of code that ran fine as a user however once it runs as a service account, I get the following error.  Can anyone kindly assist?

 File "E:\GeoprocessingWorkforce\PROD2_WORKSPACE\dev_phase2\report_handler.py", line 67, in PrintReport
    lyt.exportToPDF(filePath)
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\utils.py", line 191, in fn_
    return fn(*args, **kw)
  File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 1161, in exportToPDF
    return convertArcObjectToPythonObject(self.c(*gp_fixargs((out_pdf, resolution, image_quality, compress_vector_graphics, image_compression, embed_fonts, layers_attributes, georef_info, jpeg_compression_quality, clip_to_elements, output_as_image, embed_color_profile), True)))
OSError: E:\pdfs\abc.pdf

 

3 Replies
DanPatterson
MVP Esteemed Contributor

Just wondering if that is the actual output file name, because if python is involved, the lack of raw encoding of the name will cause issues

p ="E:\pdfs\abc.pdf"   # you should use r"E:\pdfs\abc.pdf"
print(p)
E:\pdfsbc.pdf

... sort of retired...
VictorTey
Esri Contributor

nope 😞 i use os path join to join up filepath. Furthermore it works with my user account. Just not a service account 

I also see this post by Igor that had the exact same error. 

https://community.esri.com/t5/arcgis-web-appbuilder-questions/cannot-print-very-frustrating-problem/...

 

0 Kudos
MehdiPira1
Esri Contributor

Hi @VictorTey 

This has been logged as a bug in ArcGIS Enterprise 10.8.1:

https://support.esri.com/en/bugs/nimbus/QlVHLTAwMDEzMzMxNw==

Alternate Solution

Find the patch in the following link, https://support.esri.com/en/download/7834.

Cheers

Mehdi