pdfform.js
pdfform.js copied to clipboard
Is there an option to flatten the pdf file?
I'm using pypdftk in an app but researching if it's possible to move everything into client side. One option i'm using is to flatten the file, turning the form into a regular non editable pdf. Does this project offer such an option?
Good point! any chance?
@jandetlefsen have you come across any js lib that flattens pdf or a work around?
@phihag and @jandetlefsen can we flatten PDF file in client side with this lib or PDFjs lib or any other ways to flatten PDF in client side?
Not exactly what you're looking for (and very late to the party), but I made my filled-in fields read-only by adding a line to the transform function. At the end of the "if (n._pdfform_spec)" if/else block (and just before the line that says "var ref = n._pdfform_ref;"), I added "n.map.Ff = 1;" because page 433 of https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf told me if I set the Ff key to 1, it'd be read-only. Seems to work for me so far.
@Scott64 Thank you, this is a great option.
Is there any solution to this? I can't use read-only, because I'm trying to pre-fil and then let them overwrite anything before submitting the new pdf to the backend. It's not saving the user's changes, only the pre-filled data.
@Scott64 that would have saved me, but killed multi line fields. I think you're supposed to set a bit flag, not an integer value.
Just using n.map.Ff = n.map.Ff | (1 << 0);
instead did the trick. Thanks for pointing out the docs and appropriate place - super helpful!
Not progressing this issue, but might help somebody.
@zencm Thanks for the clarification, it does say "bit position" in the docs and I glossed over that and just saw "1" in my rush to find a solution. Your correction couldn't have come at a much better time because I actually need the information again for a different project 👍 Thanks! :)