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

Is there a way to access a page's dimensions? #512

Closed
SandMoshi opened this issue Jan 15, 2020 · 3 comments
Closed

Is there a way to access a page's dimensions? #512

SandMoshi opened this issue Jan 15, 2020 · 3 comments
Assignees
Labels
question Further information is requested

Comments

@SandMoshi
Copy link

SandMoshi commented Jan 15, 2020

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)
@SandMoshi SandMoshi changed the title Is there a way to access a file's dimensions? Is there a way to access a page's dimensions? Jan 15, 2020
@wojtekmaj wojtekmaj self-assigned this Jan 16, 2020
@wojtekmaj wojtekmaj added the question Further information is requested label Jan 16, 2020
@wojtekmaj
Copy link
Owner

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

@SandMoshi
Copy link
Author

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

@wojtekmaj
Copy link
Owner

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 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants