def __init__(self): """ >>> PdfFileMerger() Initializes a PdfFileMerger, no parameters required """ self.inputs = [] self.pages = [] self.output = PdfFileWriter() self.bookmarks = [] self.named_dests = [] self.id_count = 0
def writePDFPage(path, page): """ Writes a new PDF consisting of the given single page to the given destination. """ print "[INFO] --> ... writing new PDF page to file", path, "... " pdfWriter = PdfFileWriter() pdfWriter.addPage(page) outputStream = file(path, "wb") pdfWriter.write(outputStream) outputStream.close()
parser.add_option("-p", "--path", dest="path",help="Enter the ENTIRE path to the folder which contains the 2 pdfs to be merged ") parser.add_option("-m", "--mod", dest="module",help="Enter the module name ") (options, args) = parser.parse_args() path=options.path design=options.module #Combine the 2 reports doc = SimpleDocTemplate("%s/taxonomy_report_all_%s.pdf" %(path,design), pagesize=letter) #####################Merge the gate and FF pdfs into one final pdf################## output = PdfFileWriter() if (os.path.isdir('%s' %path)): #print "Inside if" input1 = PdfFileReader(file("%s/taxonomy_report_gates_%s.pdf" %(path,design), "rb")) # print how many pages input1 has: print "\n%s/taxonomy_report_gates_%s.pdf has %s pages." % (path,design,input1.getNumPages()) # add page 1 from input1 to output document, unchanged. Each pdf has only one page output.addPage(input1.getPage(0)) input2 = PdfFileReader(file("%s/taxonomy_report_FFs_%s.pdf" %(path,design), "rb")) # print how many pages input1 has: print "\n%s/taxonomy_report_FFs_%s.pdf has %s pages." % (path,design,input1.getNumPages()) # add page 1 from input1 to output document, unchanged. Each pdf has only one page output.addPage(input2.getPage(0))