I am trying to export a project to pdf.
With arcpy.mapping i had the following and worked
import arcpy, os, sys
mxd = arcpy.mapping.MapDocument("CURRENT")
folder = os.path.dirname(mxd.filePath) # H:/GIS_Data
fullfilename = os.path.basename(mxd.filePath) # junk.mxd
filename = os.path.splitext(fullfilename) # [junk, mxd]
name = filename[0] # junk
pdfname = name + '.pdf' # junk.pdf
outpdf = folder + "/" + pdfname # H:/GIS_Data/junk.pdf
arcpy.mapping.ExportToPDF(mxd, pdfname, "PAGE_LAYOUT",0 ,0 ,"210")
I am attempting to do this with ArcGIS Pro arcpy.mp and have the following but having a hard time getting it started.
I get AttributeError: 'str' object has no attribute 'listLayouts' with the following.
import arcpy, os, sys
p = arcpy.mp.ArcGISProject("CURRENT").filePath
l = p.listLayouts()[0]
l.exportToPDF(R"C:\temp\Ex1_WA.pdf", 'CURRENT',0 ,0 ,"210")
So it should work unless you are not running it from with a toolbox in an open session of Pro or from Pro's python window.
To test, just throw the actual path in there, because 'CURRENT' doesn't seem to be returning anything other than a string (perhaps None)