In this way we can merge pdf from terminal import PyPDF2 import sys inputs=sys.argv[1:] def pdfmerger(pdflist): merger=PyPDF2.PdfFileMerger() for pdf in pdflist: print(pdf) merger.append(pdf) merger.write("superpdf.pdf") pdfmerger(inputs)
we can edit this to complete the assignment merger = PdfFileMerger() fin = file(originalFile, 'rb') merger.append(PdfFileReader(fin)) fin.close() os.remove(originalFile) or with open(originalFile,'rb') as pdf: merger.append(PdfFileReader(pdf)) os.remove(originalFile)