AnsweredAssumed Answered

pdfDoc.saveAndClose syntax error

Question asked by DaveJordan on Sep 7, 2012
Latest reply on Sep 7, 2012 by DaveJordan
I am testing a script that will append PDF files together into a sngle document.  The script performs as exspected until it hits the line pdfDoc.saveAndClose and then it throws a syntax error.  It actually creates the combined PDF on disk even though it is throwing the error. 

What is wrong ith this syntax?

import arcpy import os  from os.path import isdir, join, normpath, split   mxd = arcpy.mapping.MapDocument("Current")  wPath = r"Y:\Notification Radius Pkgs\dave500\\" RequestID = "Dave Jordan"  try:  pdfPath = wPath+RequestID+".pdf"  arcpy.AddMessage(pdfPath)  if os.path.exists(pdfPath):   os.remove(pdfPath) #Create the file and append pages  pdfDoc = arcpy.mapping.PDFDocumentCreate(pdfPath)  for file in os.listdir(wPath):   if file.endswith(".pdf"):    arcpy.AddMessage("Adding "+file)    pdfDoc.appendPages(wPath+file)  #Commit changes and delete variable reference  pdfDoc.saveAndClose()  del pdfDoc   except Exception, e:   import traceback   map(arcpy.AddError, traceback.format_exc().split("\n"))   arcpy.AddError(str(e))   

Outcomes