Saturday 21 September 2019

arcgis desktop - Data Driven Pages and exporting PDF using Python



I am able to zoom into map_index shapefile rows for a group of mxd documents in layoutview and export zoomed record as a PDF document at the same time. I tried to combine below codes to make the procedure possible but no luck.


Below code is for zooming into map_index shapefile row values in layout view.


import arcpy
mxd = arcpy.mapping.MapDocument('CURRENT')
df = arcpy.mapping.ListDataFrames(mxd, "Layers") [0]
for row in arcpy.SearchCursor("C:\Users\Desktop\Maps\map_index.shp"):

df.extent = row.SHAPE.extent
df.scale = df.scale

for df in arcpy.mapping.ListDataFrames(mxd):
mxd.activeView = df.name
mxd.title = df.name
mxd.saveACopy(r"C:\Users\Desktop\Deneme\\" + df.name + ".mxd")
arcpy.RefreshActiveView()

Below codes is the export to PDF document



import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\ParcelAtlas.mxd")
ddp = mxd.dataDrivenPages
indexLayer = ddp.indexLayer
arcpy.SelectLayerByAttribute_management(indexLayer, "NEW_SELECTION",
'"PageNumber" >= 1 AND "PageNumber" <= 10')
for indexPage in ddp.selectedPages:
ddp.currentPageID = indexPage
ddp.exportToPDF(r"C:\Project\Output\Page" + str(indexPage) + ".pdf", "CURRENT")
del mxd


Can any one help me please? I dont know if its possible but any help would be appreciated.




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...