AnsweredAssumed Answered

Is there a way to select a date range instead of a page range when printing Data Driven Pages?

Question asked by kjdowdy4026 on Apr 24, 2015
Latest reply on Apr 27, 2015 by dbarnes-esristaff

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)

Outcomes