Skip to content
New issue

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

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

Already on GitHub? # to your account

Form Flatten #716

Merged
merged 2 commits into from
Dec 21, 2020
Merged

Form Flatten #716

merged 2 commits into from
Dec 21, 2020

Conversation

btecu
Copy link
Contributor

@btecu btecu commented Dec 20, 2020

Implements form flattening. Closes #554.

Copy link
Owner

@Hopding Hopding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@btecu Wow... this is awesome! Form flattening is a much wanted feature that will help a lot of users. It's probably the biggest missing form-filling feature. Thanks for working on this! I've left a few pieces of feedback for you.

Copy link
Owner

@Hopding Hopding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Thanks again @btecu!

@chislin
Copy link

chislin commented Dec 24, 2020

When running form.flatten() on PDF saved from result of executing script from this example, I get this error:

 Error: Failed to find page undefined for element favorite.superhero
    at _loop_1 (/node_modules/pdf-lib/cjs/api/form/PDFForm.js:463:27)
    at PDFForm.flatten (/node_modules/pdf-lib/cjs/api/form/PDFForm.js:492:17)

@Hopding
Copy link
Owner

Hopding commented Dec 24, 2020

Looks like this is because the form flattening implementation relies on an optional widget field:

image

pdf-lib could set this field when adding widgets to pages. But it does seem unfortunate that form flattening would require the presence of an optional field.

@btecu
Copy link
Contributor Author

btecu commented Dec 25, 2020

@chislin is this the pdf-lib_form_creation_example.pdf file? It only has one page.
I'd like to know if you have a document with more than one page, where a widget is missing the P reference.

For these other cases, we could check if P is missing and the document only has one page, and default to that one.

@chislin
Copy link

chislin commented Dec 25, 2020

@btecu attached one
form_on_3rd.pdf

@btecu
Copy link
Contributor Author

btecu commented Dec 27, 2020

@chislin can you create an issue?

Hopding pushed a commit that referenced this pull request Aug 30, 2021
* Form Flatten

* Code review
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] API to Flatten PDF Forms
3 participants