Jim,
I did eliminate the loop and the run the script from my tool. It still didn't give me the subset of pages I wanted. It still gave me all pages. I changed the code by putting in a line to get the value of the page range input parameter and referred to that value in the DataDrivenPages.exportToPDF line. See the code below. I ran the script from my tool, this time it gave me a subset of pages. I am not sure if the changes I made is a most appropriate way to do it.
Kind regards,
George
import arcpy, os, string, sys
#There are two parameters:
# 1) Output directory
# 2) Input page range
#
outDir = arcpy.GetParameterAsText(0)
pageRange = str(arcpy.GetParameterAsText(1))
folderNam = os.path.basename(outDir)
range = os.path.basename(pageRange)
# Create a new, empty pdf document in the specified output directory
#
finalpdf_filename = folderNam + r"\ASF_MapBook.pdf"
if os.path.exists(finalpdf_filename):
os.remove(finalpdf_filename)
finalPdf = arcpy.mapping.PDFDocumentCreate(finalpdf_filename)
# Add the title page to the pdf
#
finalPdf.appendPages(r"C:\ArcGIS Tutor\DataDrivenPages\TitleOverview\TitlePage.pdf")
# Add the index map to the pdf
#
finalPdf.appendPages(r"C:\ArcGIS Tutor\DataDrivenPages\TitleOverview\OverviewPage.pdf")
# Export the Data Driven Pages to a temporary pdf and then add it to the
# final pdf. Alternately, if your Data Driven Pages have already been
# exported, simply append that document to the final pdf.
mxdPath = r"C:\ArcGIS Tutor\DataDrivenPages\DataDrivenPages_MapBook.mxd"
tempMap = arcpy.mapping.MapDocument(mxdPath)
temp_filename = r"C:\temp\tempDDP.pdf"
if os.path.exists(temp_filename):
os.remove(temp_filename)
tempDDP = tempMap.dataDrivenPages
tempDDP.exportToPDF(temp_filename, "RANGE", range)
finalPdf.appendPages(temp_filename)
# Update the properties of the final pdf
#
finalPdf.updateDocProperties(pdf_open_view="USE_THUMBS",
pdf_layout="SINGLE_PAGE")
# Save your result
#
finalPdf.saveAndClose()
# Delete variables
#
del finalPdf, tempMap, tempDDP