How to append content to a PDF using PyPDF2 and preserve the past versions

試著忘記壹切 提交于 2019-12-08 04:27:58

问题


PDF Supports document versions. That means that the current document can be kept intact, and we can change the content and presentation of the document just adding info. That feature is specially useful to verify the look and integrity of the document in the past digital signatures.

For a better understanding of what I mean, check this document Digital Signatures in a PDF - Adobe, in the Figure #5.

I have seen a lot of documentation and samples from PyPDF2 and other python libraries that add content to a PDF file. However, as long as I have seen all the examples with pyPDF2 take content from one file and rebuild the content into another one. Can we do that without loosing or breaking the digital signatures for the last versions ?

Do you know a way of raw copying of past versions and just build new document version reusing objects of the past ones ?

Or there is a way to directly modify a document ? I mean, load a document for read and write.

Other PyPDF2 examples can be found:

  • Examples from the PyPDF2 source
  • Manipulating PDFs with Python and pyPdf
  • Python PDF 2: Writing and Manipulating a PDF with PyPDF2 and ReportLab

As you'll see all of them rebuild the PDF reading from PdfFileReader and writing with PdfFileWriter. What I mean is that they need something like this PdfStamper java class, with an optional boolean append parameter that would respect previous content and update the existent PDF incrementally.

来源:https://stackoverflow.com/questions/39597772/how-to-append-content-to-a-pdf-using-pypdf2-and-preserve-the-past-versions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!