Unable to get the style of each span element which we got it in react pdf 5 version #1937
Open
4 tasks done
Labels
bug
Something isn't working
Before you start - checklist
Description
Its a blocker for me in my project, need help on this
I was using version 5 of React-PDF to render a file, and my goal was to fetch the x and y coordinates of the selected text on the PDF.
To achieve this, I used the element.style of the span elements, which provided the top and left attributes in px for the selected text.
Recently, I upgraded to React-PDF version 9, where the top and left attributes of each span style are now provided in percentages (%) instead of px.
Could you share how to obtain these attributes in px, or suggest a method to convert the percentage-based coordinates to px?
Steps to reproduce
Inspect the page that renders the PDF.
View the span tags corresponding to the text in the PDF.
Check the element.style of span tag.
Expected behavior
react-pdf 5 version result of span attribute which i used to generate x and y coordinate:
element.style {
height: 1em;
font-family: Helvetica, sans-serif;
font-size: 38px;
position: absolute;
top: 182.33px;
left: 158.12px;
transform-origin: left bottom;
white-space: pre;
pointer-events: all;
}
styles in px of top and left attribute, else suggestion to fetch in px / for conversion to px.
Actual behavior
react-pdf version 9 / latest version's result :
element.style {
left: 26.57%;
top: 22.47%;
font-size: calc(var(--scale-factor)* 38.00px);
font-family: sans-serif;
transform: scaleX(1.01528);
}
Additional information
No response
Environment
The text was updated successfully, but these errors were encountered: