question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Zoom PDF, text layer is not brought along

See original GitHub issue

https://user-images.githubusercontent.com/1231659/137839092-5ba9a181-1143-4ab7-b23e-6df15e36ff89.mov

Before you start - checklist

  • I have read documentation in README
  • I have checked sample and test suites to see real life basic implementation
  • I have checked if this question is not already asked

What are you trying to achieve? Please describe.

I’d like to implement a “Zoom in” / “Zoom out” button. I’d like the link and text layer to also be scaled.

      <Page
        loading={null}
        pageNumber={pageNumber}
        scale={data.scale}
        width={data.width}
        renderAnnotationLayer={true}
      />

where data.scale goes from 1 -> 2 and data.width is static.

Describe solutions you’ve tried

I’ve tried to set scale from 1 to 2 to implement zooming. This does zoom the PDF by 2x, but the text layer is offset.

I tried to change around scale/width to several different values to see if anything would click. No luck, which makes sense because react-pdf is multiplying width * scale, so I don’t need to do that myself.

I found a maybe relevant Github issue that’s open. However, it felt like maybe that’s referring to something other than this. I may have misunderstood the root cause it is trying to communicate, as the maintainers said it’s not reproducible.

Additional information

I’ve attached a video of my attempt. The console is printing console.log(data.scale, data.width) on every Page render.

Environment

  • Browser (if applicable) [e.g. Chrome 57, Firefox 59]: Chrome 94.0.4606.81
  • React-PDF version [e.g. 3.0.4]: 5.4.2
  • React version [e.g. 16.3.0]: 17.0.2

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
sb8244commented, Oct 19, 2021

Hm okay, that’s where I think that maybe this is a bug (although most likely is me doing something wrong and not realizing it). I am not using custom CSS and they are not aligned. I will look at isolating it in a reproduction app to see what’s going on.

1reaction
wojtekmajcommented, Oct 19, 2021

Pick either scale or width, not both.

No better way to explain than using code:

https://github.com/wojtekmaj/react-pdf/blob/e88e5c2a57d83b63d8340e6e30c32b7ccdbecc83/src/Page.jsx#L193-L207

Read more comments on GitHub >

github_iconTop Results From Across the Web

Adjusting PDF views - Adobe Support
Adjust page magnification of PDF documents using the Select & Zoom tools in Adobe Acrobat.
Read more >
Changing Layer Visibility in an Interactive PDF
First turn all the layers on (the default) so the background is showing. Then select the Background On button with the Select Object...
Read more >
Using the Zoom Whiteboard tools
Zoom Whiteboard tools are used to create and manipulate objects on canvas. You can draw, add shapes, type text, and insert sticky notes......
Read more >
Disappearing or Strange Looking Elements in the PDF
If elements disappear from the PDF after uploading to E-pages it may be because of the use of layers and layers with transparency...
Read more >
PDF layer moves as I zoom in and out - Autodesk Forums
dwg no long line-up on top of each other. What's happening, how do i prevent this from happening. I want them both to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found