Unable to Style canvas #1444
-
I am using react-pdf to render a pdf file located in the public folder, I am having issues with the ability to make the canvas (being rendered by the Page component) bigger, for some reason the Page component is able to change height and width but the canvas component is not able to change height and width. Is there a way to override the style used by react-pdf_canvas without using !important? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
As A little preview this works but I want to avoid using !important. |
Beta Was this translation helpful? Give feedback.
-
Do NOT style canvas this way. Instead, explicitly pass the If it has to be dynamic, consider listening for window resize or container resize. I have handy hooks for this occasion - useWindowWidth and useIntersectionObserver - in my package @wojtekmaj/react-hooks, but of course, you can implement it yourself, too. |
Beta Was this translation helpful? Give feedback.
Do NOT style canvas this way. Instead, explicitly pass the
width
prop to the Page component. This is the only way to ensure that all layers stay aligned and everything looks good.If it has to be dynamic, consider listening for window resize or container resize. I have handy hooks for this occasion - useWindowWidth and useIntersectionObserver - in my package @wojtekmaj/react-hooks, but of course, you can implement it yourself, too.