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

PDFs render too small treating pts as px #1219

Open
4 tasks done
chenlijun99 opened this issue Dec 9, 2022 · 7 comments · May be fixed by #1717
Open
4 tasks done

PDFs render too small treating pts as px #1219

chenlijun99 opened this issue Dec 9, 2022 · 7 comments · May be fixed by #1717
Labels
bug Something isn't working fresh

Comments

@chenlijun99
Copy link

Before you start - checklist

  • I followed instructions in documentation written for my React-PDF version
  • I have checked if this bug is not already reported
  • I have checked if an issue is not listed in Known issues
  • If I have a problem with PDF rendering, I checked if my PDF renders properly in PDF.js demo

Description

Not sure if it's a bug or a feature. But when a PDF is rendered at default size using react-pdf, its size differs from the size when using PDF.js's "Actual size" option.
Specifically, react-pdf seems to take the values from the view property of PDFPageProxy and treat them as pixel, while they actually mean user points.

Steps to reproduce

  • Simply render a PDF using react-pdf without passing height, width, scale.
  • Open the same PDF using pdf.js (e.g. https://mozilla.github.io/pdf.js/web/viewer.html) and set "Actual Size" as zoom option.
  • Observe that the sizes of the two rendered PDFs differ.

Expected behavior

They should have the same size. In particular react-pdf should consider that the values in view are user points and convert them to pixel appropriately.

Actual behavior

react-pdf treats the values read from view as pixels.

Additional information

No response

Environment

  • Browser (if applicable): Firefox 107.0
  • React-PDF version: v6.2.0
  • React version: 18.2.0
  • Webpack version (if applicable):
@chenlijun99 chenlijun99 added the bug Something isn't working label Dec 9, 2022
@aarowman
Copy link

+1
I'm getting the same issue and was wondering why it happened. If I create my own custom pdf (from Word), it shows up a little bigger, but still seems small. If I use an "official" PDF from another source, it shows pretty small

@github-actions
Copy link
Contributor

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days.

@github-actions github-actions bot added the stale label Apr 24, 2023
@github-actions
Copy link
Contributor

This issue was closed because it has been stalled for 14 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 15, 2023
@aarowman
Copy link

Please re-open this issue - I think the "actual size" is the better user experience default! At a minimum, we should have an option to specify it instead of being forced in the preview mode

@ASutrick
Copy link

Please re-open this issue. After checking pdf metadata I can see that react-pdf is treating pts as pixels thus causing the document to not size correctly

@wojtekmaj wojtekmaj reopened this Sep 28, 2023
@wojtekmaj
Copy link
Owner

I'm reopening this as it indeed looks like we're not sizing PDFs correctly, although:

  • I still don't know why this happens
  • Fix will be treated as breaking change and released with the next major release because of its significance

@wojtekmaj wojtekmaj changed the title Wrong default size PDFs render too small treating pts as px Sep 28, 2023
@wojtekmaj wojtekmaj added fresh and removed stale labels Sep 28, 2023
@ASutrick
Copy link

ASutrick commented Oct 2, 2023

Until a fix is found you can multiply your desired scale by 1.33 to get actual document size

@courtneypattison courtneypattison linked a pull request Feb 11, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fresh
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants