I noticed it was just a folder location listed, I set the tool parameter wrong. But when I do specify a file name, the tool won't run because it says the file doesn't exist. I don't have the problem when I won't run a multi-page pdf export, but it doesn't create documents either. I don't know what changed to keep it from the file creation, but it says it completes the script on single page PDFs.import arcpy, os, sys
#set map doc and the layer to be used
mxd = arcpy.mapping.MapDocument("Current")
mapLyr = arcpy.mapping.ListLayers(mxd, "Detail_2013")[0]
#Get input parameters
pageNumList = arcpy.GetParameterAsText(0).split(";")
multiPage = arcpy.GetParameterAsText(1)
outputPDF = arcpy.GetParameterAsText(2)
if multiPage == "true":
if os.path.exists(outputPDF):
os.remove(outputPDF)
#Create new FinalMapBook that results will be appeneded into
finalMapBook = arcpy.mapping.PDFDocumentCreate(outputPDF)
#Listing the text elements on the page
concatElem1 = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "concat1")[0]
concatElem2 = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "concat2")[0]
#Get page number from data driven page - specified in the tool parameter dialogue box
ddp = mxd.dataDrivenPages
for pageNum in pageNumList:
arcpy.AddMessage(pageNum)
pageID = mxd.dataDrivenPages.getPageIDFromName(str(pageNum))
mxd.dataDrivenPages.currentPageID = pageID
#Set layer definition query, this contols the rowcount variable
pageFieldValue = pageNum
mapLyr.definitionQuery = '"pageNum" = %s' % pageNum
#Finds the number of features in the map and sets up the lists to evenly distribute into the two text elements/columns
rowcount = int(arcpy.GetCount_management("Detail_2013").getOutput(0))
percolumn = round(rowcount / 2.0)
count1 = 1
count2 = rowcount
#Specifies the features being used for the SearchCursor
rows = arcpy.SearchCursor(mapLyr, "", "", "CONCAT")
fieldrow = arcpy.SearchCursor(mapLyr, "", "", "pageNum")
currentpage = ""
text_var1 = str()
text_var2 = str()
for row in fieldrow:
if currentpage != row.pageNum:
currentpage = row.pageNum
for row in rows:
if count1 <= percolumn:
text_var1 += '{0}{1}'.format(row.getValue("CONCAT"), os.linesep)
concatElem1.text = text_var1
count1 += 1
elif count2 > percolumn:
text_var2 += '{0}{1}'.format(row.getValue("CONCAT"), os.linesep)
concatElem2.text = text_var2
count2 - 1
else:
pass
else:
pass
#Generate multi-page PDF file or single PDF files
if multiPage == "true": #Appends all PDFs into single, multi-page PDF
arcpy.mapping.ExportToPDF(mxd, outputPDF[:-4] + pageNum + ".pdf") #strip away .pdf, add platnum value and add ".pdf"
finalMapBook.appendPages(outputPDF[:-4] + pageNum + ".pdf") #append page to final PDF
os.remove(outputPDF[:-4] + pageNum + ".pdf") #no longer needed once appended
else: #Create individual PDFs for each page
arcpy.mapping.ExportToPDF(mxd, outputPDF[:-4] + pageNum + ".pdf")
#Add PDF properties for multi-page PDF
if multiPage == "true":
finalMapBook.updateDocProperties("2010-2011 Crash Report", "2010-2011 Crash Report", "map sheets, map book", "USE_THUMBS")
finalMapBook.saveAndClose()
arcpy.RefreshActiveView()
arcpy.AddMessage("PROCESS COMPLETED")
#Removed the definition query so all page numbers appear when the script is run next and refresh he layout view
mapLyr.definitionQuery = ""
arcpy.RefreshActiveView()
del mxd, row, rows, rowcount, percolumn, count1, count2