pdfform.js icon indicating copy to clipboard operation
pdfform.js copied to clipboard

Is there an option to flatten the pdf file?

Open jandetlefsen opened this issue 6 years ago • 8 comments

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?

jandetlefsen avatar Jun 30 '18 06:06 jandetlefsen

Good point! any chance?

cpreach avatar Jul 18 '18 14:07 cpreach

@jandetlefsen have you come across any js lib that flattens pdf or a work around?

smettu007 avatar Oct 12 '18 21:10 smettu007

@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?

phanisai4u avatar Apr 14 '19 09:04 phanisai4u

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 avatar Aug 22 '19 14:08 Scott64

@Scott64 Thank you, this is a great option.

Zjcompt avatar Jan 26 '20 06:01 Zjcompt

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.

ustincameron avatar Jul 05 '20 13:07 ustincameron

@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 avatar Jan 27 '21 23:01 zencm

@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! :)

Scott64 avatar Apr 01 '21 13:04 Scott64