galkahana / PDF-Writer

High performance library for creating, modiyfing and parsing PDF files in C++
http://www.pdfhummus.com
Apache License 2.0
896 stars 214 forks source link

PDFModifiedPage custom handle of Annots #287

Open devilsclaw opened 2 weeks ago

devilsclaw commented 2 weeks ago

I am currently working on various project that need to manipulate PDFs.

The projects I am currently working on uses a preexisting template PDF that has text forms that can be filled in. My project collects info on the form objects and then filters them out and are not part of the final output PDF. I then modifies the Content Section and adds what is needed for the text to be static text. It then adds a image to the PDF which is.

The filter out section modifies all the indirect objects related to the Annot's forms and empties them and then it completely skips the annot section with coping the content to the output object.

I noticed that PDFModifiedPage WritePage copies everything so then I have the form fields and the static text on the output of the PDF.

Is it possible to remove the annot's section before the write page so that is does not try to copy it? I know I could create my own class and overload the WritePage but I was wondering if there was a way with out doing that.

galkahana commented 2 weeks ago

back when i needed to lock a form i just wrote my own version of PDFModifiedPage combined with copying only the non widgets: https://github.com/galkahana/HummusJSSamples/blob/master/lock-form/pdf-form-lock.js

so yeah, either recreate your own version of PDFModifiedPage or derive n pick n choose.