Skip to content

PDFs render too small treating pts as px #1219

@chenlijun99

Description

@chenlijun99

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):

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfresh

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions