import arcpy, sys, os arcpy.env.overwriteOutput = True mxd = arcpy.mapping.MapDocument("CURRENT") print "Enter save as pdf location:" pdfDir = arcpy.GetParameterAsText(0) outputFolder = pdfDir + r"\PDFs" df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] maskLayer = arcpy.mapping.ListLayers(mxd, "state_bnd110", df)[0] maskField = "STATE_NAME" for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1): mxd.dataDrivenPages.currentPageID = pageNum pageName = mxd.dataDrivenPages.pageRow.STATE_NAME for lyr in arcpy.mapping.ListLayers(mxd): if lyr.name == maskLayer: lyr.definitionQuery = '"STATE_NAME" <> %s' % pageName arcpy.RefreshActiveView() arcpy.mapping.ExportToPDF(mxd, os.path.dirname(outputFolder)+ os.sep + pageName + ".pdf") del mxd arcpy.GetMessages()
I realize this is an old post, but not a whole lot on the internet on this topic besides this post. Has the ability to "Clip Output to Graphics Extent" via arcpy been added to recent version of ArcMap (I have 10.4)? I have hundreds of map documents I'd like to export as JPEGs to insert into Word documents and this would be so helpful. I don't want the white space around the map document, just the graphic. Based on my research, I have a sinking feeling it has not been added...
Jeff. Would it be possible for you to explain in more detail how to duplicate this function using arcpy in combination with mask layers/definition queries? I'm struggling to understand that idea at a conceptual level, let alone a scripting level. Thank you!!
- Josh
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.