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

feat: variable dpi #1869

Merged
merged 2 commits into from
Jun 6, 2022
Merged

feat: variable dpi #1869

merged 2 commits into from
Jun 6, 2022

Conversation

diegomura
Copy link
Owner

Adds optional dpi prop to Page primitive

Why Page and not Document?

So the same document can have different DPIs in different pages

What this prop does under the hood

  • Resizes page dimensions to match new dpi
  • Setup PDF page UserUnit field to dpi/72

Reading at the PDF spect it seems that the latter point is the way to go, but I haven't seen any change in how readers (specially Adobe) renders pages or shows page dimensions. Seems like it's being ignored as far as I saw. But hopefully this will work for anyone requiring to have variable dpi.

Please open a new issue if someone trying this finds something not working as expected

Fixes #1066

@nikischin
Copy link
Contributor

So I had a look through the sources and did some research, and PDFKit should do the job with the userUnit already. I suspect, the changes in packages/layout/src/page/getSize.js should be reverted and the dpi variables in packages/layout/src/steps/resolveStyles.js and packages/stylesheet/src/transform/units.js should be fixed to 72 instead of the user provided dpi, as for my understanding PDFKit internally uses the 72 dpi as measuring unit and transforms it with the userUnit to the expected dpi.

Unfortunaly, I haven't managed to get the packages linked locally, so I wasn't able to test. I created a branch https://github.com/nikischin/react-pdf/tree/bugfix/customDpi, maybe you could try this @diegomura

@nikischin nikischin mentioned this pull request Jun 2, 2024
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.

dpi / resolution prop (300 dpi)
2 participants