Python Forum

Full Version: ReportLab
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have 7 pages pdf file and I am trying to write on existing pdf file . I can write on the first page however I cannot write on the rest of pages  

self.canvas.save() 
            output = PdfFileWriter()
            self.packet.seek(0)

            new_pdf = PdfFileReader(self.packet)
          
            existing_pdf = PdfFileReader(open(filename,"rb"))
            for i in range(0,existing_pdf.getNumPages()):
                page = existing_pdf.getPage(0)
                page.mergePage(new_pdf.getPage(0))
                output.addPage(page)
            outputStream = open('/home/egor/destination.pdf',"wb")
            output.write(outputStream)
            outputStream.close()
I could not find any relevant examples from there