I try to export a webmap in using arcpy into a pdf. This works fine, if there is a Layout available using:
aprx = arcpy.mp.ConvertWebMapToArcGISProject(webmap, None, None, notes_gdb)
aprx.importDocument("C:\\path\\to\\the\\layout.pagx")
layout = aprx.listLayouts()[0]
layout.exportToPDF("C:\\temp\\export.pdf")
Is there a posibility to export the webmap without layout?
There are resolution, scale and extent given in the webmap, so it should be possible. But I have nothing found to export a map directly like what is possible in arcpy.mapping.
-
Have you tried just exporting a MapFrame rather than the Layout? That has an exportToPDF method too.PolyGeo– PolyGeo ♦2019年12月05日 09:24:13 +00:00Commented Dec 5, 2019 at 9:24
-
How do I get the map frame without a layout?scher– scher2019年12月05日 10:28:26 +00:00Commented Dec 5, 2019 at 10:28
-
I think you would add the MapFrame to a Layout, but then there is no need to export the Layout just the MapFrame.PolyGeo– PolyGeo ♦2019年12月05日 10:43:28 +00:00Commented Dec 5, 2019 at 10:43
-
thanks for the hint. I loaded a dummy layout with one map frame, choose the frame and called exportToPDF. The result was a crash of arcgis proscher– scher2019年12月05日 11:15:31 +00:00Commented Dec 5, 2019 at 11:15
1 Answer 1
I got a hint from the default esri server printing tool box. This tool box has been in general a source of inspiration, how to handle printing issues.
result = arcpy.mp.ConvertWebMapToArcGISProject(webmap)
mapView = result.ArcGISProject.listMaps()[0].defaultView
dpi = int(result.DPI) #a workaround for now for a bug
mapView.exportToPDF("C:\\temp\\export.pdf", result.outputSizeWidth, result.outputSizeHeight, dpi)