-
Notifications
You must be signed in to change notification settings - Fork 30
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
Form field content gets lost after flatten #86
Comments
I was just fighting against a very similar problem: I have a PDF with a form, and a field named "fieldname"
works, and creates a new PDF with a form with the 'fieldname' field correctly dispalying Hello. But when I add |
What is flatten supposed to be doing exactly? |
https://pdf-lib.js.org/docs/api/classes/pdfform#flatten flatten Defined in api/form/PDFForm.ts:537 Flatten all fields in this PDFForm. Flattening a form field will take the current appearance for each of that field's widgets and make them part of their page's content stream. All form fields and annotations associated are then removed. Note that once a form has been flattened its fields can no longer be accessed or edited. This operation is often used after filling form fields to ensure a consistent appearance across different PDF readers and/or printers. Another common use case is to copy a template document with form fields into another document. In this scenario you would load the template document, fill its fields, flatten it, and then copy its pages into the recipient document - the filled fields will be copied over. |
Then I wonder if it's not related to the same question raised here: #80 Where are the state data being stored before we call save()? |
What were you trying to do?
Flatten an uploaded pdf file. The key difference is how the form was filled beforehand.
How did you attempt to do it?
What actually happened?
The "Name" field is empty after flatten
What did you expect to happen?
All fields should keep their value
How can we reproduce the issue?
https://jsfiddle.net/dwvs6tbg/1/
Steps to reproduce:
This is the original pdf file
sample_pdf.pdf
This is the pdf file filled out using chrome browser --> "Name" field keeps it's value after flatten
sample_pdf_chrome.pdf
This is the pdf file filled out using Adobe Acrobat --> "Name" field is empty after flatten
sample_pdf_acrobat.pdf
Version
2.2.4
What environment are you running pdf-lib in?
Browser
Checklist
Additional Notes
No response
The text was updated successfully, but these errors were encountered: