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

Cleanup all annotations #750

Merged
merged 2 commits into from
Jan 25, 2021
Merged

Cleanup all annotations #750

merged 2 commits into from
Jan 25, 2021

Conversation

btecu
Copy link
Contributor

@btecu btecu commented Jan 13, 2021

Most viewers, including PDF.js and Preview do not seem to mind the annotations but it was preventing Adobe Acrobat printing a flattened document:

@weinspach
Copy link

The error with the annotations does not only affect printing, "save as" is also not possible in Acrobat Reader and Acrobat Pro with a flattened pdf. In addition, e.g. the validation of the PDF with Datalogic's PDF Checker fails: "Unable to process document due to PDF Error".

src/api/form/PDFForm.ts Outdated Show resolved Hide resolved
@Hopding
Copy link
Owner

Hopding commented Jan 14, 2021

@btecu Can you clarify what is being done here? It looks like this logic would just delete the first annotation from a page after flattening a widget that belonged to it. If that is the intent, can you explain why that would be desirable? There's not necessarily any correlation between the first annotation on a page and the widget being flattened.

@Hopding
Copy link
Owner

Hopding commented Jan 14, 2021

Can you provide a sample document that fails to be printed after flattening? Does this only happen to certain documents, or to all documents?

@btecu
Copy link
Contributor Author

btecu commented Jan 14, 2021

@Hopding Notice the loop - is deleting all annotations. As a sample, take a look at the document in the flattening test. It doesn't appear to be a special document but the issue happens with most PDFs that have a form.

@Hopding
Copy link
Owner

Hopding commented Jan 14, 2021

Ah, I see the loop now. Deleting all the annotations seems like overkill. I don't think users would expect that flattening a form would result in all pages with fields losing their annotations.

@btecu
Copy link
Contributor Author

btecu commented Jan 14, 2021

Looks like the field annotations are the ones that were causing the issue. Removing those along with the widget annotations seems to have fix the issue.

In addition, I've improved removeField so that it cleans up the annotations.

Enhance `removeField` to cleanup annotations
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 This looks very good. The implementation is nice. I've requested one change and then this should be good to go.

src/api/form/PDFForm.ts Show resolved Hide resolved
@Hopding Hopding changed the base branch from master to cleanup-750 January 25, 2021 00:11
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.

Thanks for working on this @btecu!

@Hopding Hopding merged commit e3ca413 into Hopding:cleanup-750 Jan 25, 2021
@Hopding Hopding mentioned this pull request Jan 25, 2021
Hopding pushed a commit that referenced this pull request Aug 30, 2021
* Remove all fields & widget annotations when flattening
Enhance `removeField` to cleanup annotations

* Add `removeField` test
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

Successfully merging this pull request may close these issues.

3 participants