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

Support hexadecimal Default Appearance #677

Merged
merged 1 commit into from
Dec 6, 2020
Merged

Support hexadecimal Default Appearance #677

merged 1 commit into from
Dec 6, 2020

Conversation

btecu
Copy link
Contributor

@btecu btecu commented Nov 18, 2020

getDefaultAppearance is used to determine font size and the style among other things.
Some pdf files can have the DA property as a hexadecimal, causing the library to have a un-parsable DA value.

Bonus: Make return value match the function signature (string | undefined).

@Hopding
Copy link
Owner

Hopding commented Nov 24, 2020

@btecu Do you have an example of a PDF that contains hex string DAs? Also, I'm all for making this change, but I would like to create some unit tests around this method to ensure the functionality isn't broken or removed down the line.

@btecu
Copy link
Contributor Author

btecu commented Nov 24, 2020

@Hopding I sent you an example document.

@Hopding
Copy link
Owner

Hopding commented Nov 29, 2020

Thanks @btecu! Would you please create a unit test for each of the altered methods? For example, tests/core/acroform/PDFAcroField.spec.ts would load the document you shared with me (thus it would need to be added to the assets/pdfs directory), read the raw appearance strings and assert that they are hex strings, and then call the getDefaultAppearance() methods and assert that the correct value is returned. Note that we'll need to do this for both PDFAcroField and PDFWidgetAnnotation instances.

@btecu
Copy link
Contributor Author

btecu commented Dec 2, 2020

@Hopding I cannot add the PDF that I shared with you since is not a public document, and I don't know how to add a test for it without the PDF.

@Hopding Hopding changed the base branch from master to HexStringDAs December 6, 2020 19:03
@Hopding Hopding merged commit b311273 into Hopding:HexStringDAs Dec 6, 2020
Hopding added a commit that referenced this pull request Dec 6, 2020
* Support hexadecimal Default Appearance (#677)

* Add test for PDFAcroField.getDefaultAppearance

* Add test for PDFWidgetAnnotation.getDefaultAppearance

* Cleanup

Co-authored-by: Bj Tecu <[email protected]>
@Hopding
Copy link
Owner

Hopding commented Dec 6, 2020

@btecu I added tests in #693. These changes will go out in the next release of pdf-lib. Thanks for your contribution! 🎉

@Hopding
Copy link
Owner

Hopding commented Dec 6, 2020

The changes in this PR were just released in v1.13.0.

Hopding added a commit that referenced this pull request Aug 30, 2021
* Support hexadecimal Default Appearance (#677)

* Add test for PDFAcroField.getDefaultAppearance

* Add test for PDFWidgetAnnotation.getDefaultAppearance

* Cleanup

Co-authored-by: Bj Tecu <[email protected]>
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.

2 participants