React-pdf: Is there a way to access a page's dimensions?

Created on 15 Jan 2020  路  3Comments  路  Source: wojtekmaj/react-pdf

What are you trying to achieve? Please describe.

I am displaying a PDF file, they are single-page files, but I would like to be able to access the file's dimensions so I can calculate the zoom level. I didn't see anything in the documentation about reading a file's data once loaded.

Additional information

I would like to read the data from the file anytime before it's rendered.

Environment

  • React-PDF version 4.1.0
  • React version 16.8
  • Webpack version (CRA 3.2.0)
question

Most helpful comment

Yes, absolutely. <Page />'s onLoadSuccess callback gets page object as an argument, and said object contains everything you need: width, height (scaled - as rendered), originalWidth, originalHeight (original).

All 3 comments

Yes, absolutely. <Page />'s onLoadSuccess callback gets page object as an argument, and said object contains everything you need: width, height (scaled - as rendered), originalWidth, originalHeight (original).

Would you be interested in having me add this as an example to the README in a pull request?

Hmmm, I'd need not to be picky and document all the interesting arguments. I'll tackle it, but not right now - swimming in notifications 馃槥

Was this page helpful?
0 / 5 - 0 ratings