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

PDFForm.flatten() does not handle rotated fields correctly #733

Closed
Hopding opened this issue Jan 5, 2021 · 3 comments · Fixed by #734
Closed

PDFForm.flatten() does not handle rotated fields correctly #733

Hopding opened this issue Jan 5, 2021 · 3 comments · Fixed by #734

Comments

@Hopding
Copy link
Owner

Hopding commented Jan 5, 2021

PDF form fields can be rotated. However, the rotation logic for form field widgets should be "in-place" (see rotateInPlace), as opposed to the more common (at least in PDF land) logic of "about-the-origin" rotation. The current logic used in PDFForm.flatten() appears to be using "about-the-origin" logic, which leads to incorrect results after flattening a rotated field. See below for examples clarifying this:

✅ Correct Rendering of Rotated Fields

You can generate this document yourself by running yarn apps:node 17 and looking at the first page of the resulting document.

❌ Incorrect Rendering of Rotated Fields

You can generate this document yourself by running yarn apps:node 18 and looking at the fifth page of the resulting document.

@Hopding
Copy link
Owner Author

Hopding commented Jan 5, 2021

@btecu Think it would be fairly straightforward to use rotateInPlace for flattening? I'm assuming that's not what's currently being used.

@btecu
Copy link
Contributor

btecu commented Jan 5, 2021

Curiously, this evening it was brought to my attention this issue so it was already on my radar.
The document before the fix:
image

After the fix:
image

I've also tested the document mentioned above and it's also fixed.

@princ09
Copy link

princ09 commented Jan 5, 2021

Hi @Hopding , Thanks for this wonderful lib. I just saw documentation related rotateInPlace but I am not able to understand how to use it. should be used with PngImage?
I want to have like this https://user-images.githubusercontent.com/47990313/103611620-ab976f00-4f48-11eb-9eb6-c37802238308.jpg
where pdf might be rotated but image i want to be fixed at top left.
Please provide example for rotateInPlace for pngImage.

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 a pull request may close this issue.

3 participants