Python Forum
ReportLab - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: ReportLab (/thread-4537.html)



ReportLab - ek5442 - Aug-24-2017

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()



RE: ReportLab - Larz60+ - Aug-24-2017

Have you seen this page: https://www.programcreek.com/python/example/64916/pyPdf.PdfFileWriter


RE: ReportLab - ek5442 - Aug-24-2017

I could not find any relevant examples from there