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")
maskLayer = arcpy.mapping.ListLayers(mxd, "state_bnd110", df)
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.mapping.ExportToPDF(mxd, os.path.dirname(outputFolder)+ os.sep + pageName + ".pdf")
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!!
Retrieving data ...