Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there an option to flatten the pdf file? #13

Open
jandetlefsen opened this issue Jun 30, 2018 · 8 comments
Open

Is there an option to flatten the pdf file? #13

jandetlefsen opened this issue Jun 30, 2018 · 8 comments

Comments

@jandetlefsen
Copy link

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?

@cpreach
Copy link

cpreach commented Jul 18, 2018

Good point! any chance?

@smettu007
Copy link

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

@phanisai4u
Copy link

phanisai4u commented Apr 14, 2019

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

@Scott64
Copy link

Scott64 commented Aug 22, 2019

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.

@Zjcompt
Copy link

Zjcompt commented Jan 26, 2020

@Scott64 Thank you, this is a great option.

@ustincameron
Copy link

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.

@zencm
Copy link

zencm commented Jan 27, 2021

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

@Scott64
Copy link

Scott64 commented Apr 1, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants