react-pdf
react-pdf copied to clipboard
PDFs render too small treating pts as px
Before you start - checklist
- [X] I followed instructions in documentation written for my React-PDF version
- [X] I have checked if this bug is not already reported
- [X] I have checked if an issue is not listed in Known issues
- [X] 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):
+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
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.
This issue was closed because it has been stalled for 14 days with no activity.
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
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
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
Until a fix is found you can multiply your desired scale by 1.33 to get actual document size