Using Arc 10.2.2
I have a script that I am using in a geoprocessing service (exposed through a print widget). As the script currently sits, it has a user defined parameter that allows the user to define what pages from the DDP.mxd to print to pdf. There is a date field in the feature class called "created_date", format: 4/24/2015 4:56:22 PM. Is there a way to pass in a date range for the DDP to print instead of using a page range? I may going about it this all wrong...if so then please at least leave a comment just say I'm an idiot and I'll try to develop this a little more
Here is the script (mainly from ESRI's help site):
import arcpy import os import uuid # The template location in the registered folder templatePath = '//gis/sharedmaps/Reports/Templates' # Input WebMap json Web_Map_as_JSON = arcpy.GetParameterAsText(0) # Data Driven Page numbers as comma delimited string DDP_Pages = arcpy.GetParameterAsText(1) if DDP_Pages == '#' or not DDP_Pages: DDP_Pages = "1-4" # Get the template map document templateMxd = os.path.join(templatePath, 'Reports.mxd') # Convert the WebMap to a map document result = arcpy.mapping.ConvertWebMapToMapDocument(Web_Map_as_JSON, templateMxd) mxd = result.mapDocument # Use the uuid module to generate a GUID as part of the output name # This will ensure a unique output name Output_File = os.path.join(arcpy.env.scratchFolder, 'WebMap_{}.pdf'.format(str(uuid.uuid1()))) # Export the WebMap Data Driven Pages to PDF mxd.dataDrivenPages.exportToPDF(Output_File, "RANGE", DDP_Pages) # Set the output parameter to be the output PDF arcpy.SetParameterAsText(2, Output_File) # Clean up - delete the map document reference filePath = mxd.filePath del mxd, result os.remove(filePath)
I don't know how to implement this with python, but if you do a selection first you can then print just the selected pages. This works whether the selection was made through select by location or select by attribute. So you could select by attribute on your date field, then use that to print the selected pages. I hope that helps point you in a useful direction towards a solution.