What's the overall workflow? Is the user interacting with the map or are you just printing each mxd?
import arcpy import pythonaddins import os import time class ExtensionClass1(object): """Implementation for PrintToPDF_AddIn_addin.extension2 (Extension)""" def __init__(self): # For performance considerations, please remove all unused methods in this class. self.enabled = True def beforeCloseDocument(self): #this works but runs before file fully opens mxd = arcpy.mapping.MapDocument("CURRENT") if mxd.description == 'Print to PDF': arcpy.mapping.PrintMap(mxd, r"Adobe PDF", "PAGE_LAYOUT") time.sleep(25) os.system('taskkill /IM Arcmap*')
import arcpy import pythonaddins import os import time class ExtensionClass1(object): """Implementation for PrintToPDF_AddIn_addin.extension2 (Extension)""" def __init__(self): # For performance considerations, please remove all unused methods in this class. self.enabled = True def openDocument(self): mxd = arcpy.mapping.MapDocument("CURRENT") mxd.activeView = "PAGE_LAYOUT" #Make sure Layout View is active arcpy.RefreshActiveView() #Refresh the view if mxd.description == 'Print to PDF': arcpy.mapping.PrintMap(mxd, r"Adobe PDF", "PAGE_LAYOUT") pass
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.