Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Parent folder
- - printPDFfolder.py
- - pdf_to_merge
- -- cat.pdf
- -- dog.pdf
- - other_cool_pdfs
- -- a wrinkle in time.pdf
- -- baseball.pdf
- fileDir = os.path.dirname(os.path.realpath(__file__))
- print "Your file directory is: " + fileDir
- for root, dirs, files in os.walk(fileDir):
- merger = PdfFileMerger()
- print "The files to merge are:"
- print files
- for filename in files:
- print "file name is: " + filename
- if filename.endswith(".pdf"):
- print "file names: " + filename
- filepath = os.path.join(root, filename)
- print "Your file path to append to is: " + filepath
- # with open(filepath)
- merger.append(PdfFileReader(open(filepath, 'rb')))
- print "merger is: "
- print merger
- #merger.write(str(filename))
- # write file path of the sub folder
- # test folder name is: pdf_to_merge
- print "what is dirs"
- print dirs
- merger.write(os.path.join(fileDir, dirs + '.pdf'))
- C:Python27ArcGISx6410.5python.exe C:/Workspace-TT/GeneratePdfBinderPython/test/combinePDFFolder.py
- Traceback (most recent call last):
- Your file directory is: C:Workspace-TTGeneratePdfBinderPythontest
- File "C:/Workspace-TT/GeneratePdfBinderPython/test/combinePDFFolder.py", line 45, in <module>
- The files to merge are:
- merger.append(PdfFileReader(open(filepath, 'rb')))
- ['combinePDFFolder.py']
- file name is: combinePDFFolder.py
- The files to merge are:
- File "C:Python27ArcGISx6410.5libsite-packagesPyPDF2pdf.py", line 1084, in __init__
- ['WV__FRI-AY-28-07-CUT.pdf', 'WV__FRI-AY-29-06-CUT.pdf', 'WV__FRI-AY-29-07-CUT.pdf', 'WV__FRI-AY-30-05-CUT.pdf', 'WV__FRI-AY-30-07-CUT.pdf', 'WV__FRI-AY-31-04-CUT.pdf', 'WV__FRI-AY-31-05-CUT.pdf', 'WV__FRI-AY-31-06-CUT.pdf']
- self.read(stream)
- file name is: WV__FRI-AY-28-07-CUT.pdf
- File "C:Python27ArcGISx6410.5libsite-packagesPyPDF2pdf.py", line 1689, in read
- file names: WV__FRI-AY-28-07-CUT.pdf
- Your file path to append to is: C:Workspace-TTGeneratePdfBinderPythontestpdf_to_mergeWV__FRI-AY-28-07-CUT.pdf
- stream.seek(-1, 2)
- IOError: [Errno 22] Invalid argument
Add Comment
Please, Sign In to add comment