Code Monkey home page Code Monkey logo

Comments (5)

edg2s avatar edg2s commented on May 25, 2024

What are you using to render the PDF in the browser?

from rangefix.

myself3421 avatar myself3421 commented on May 25, 2024

We are using pdf.js library to render PDF.

from rangefix.

edg2s avatar edg2s commented on May 25, 2024

If I extract the HTML from the pdf.js render, I get all 3 rects in both FF and Chrome. If I run RangeFix inside the original pdf.js online viewer, I get 6 rects in both browser (maybe 3 more for the fake selection?)

Can you provide a standalone example of the bug you describe, e.g. in a CodePen?

from rangefix.

myself3421 avatar myself3421 commented on May 25, 2024

Hi,
-Please go through the link "https://codesandbox.io/s/displaying-pdf-using-react-forked-6bqup7?file=/src/components/pdf/all-pages.js"
-Open the output window in a separate tab and also open devTool console tab.
-Select the 'Vestibulum neque massa, scelerisque sit amet ligula eu, congue molestie mi. Praesent ut
varius sem. Nullam at porttitor arcu, nec lacinia nisi. Ut ac dolor vitae odio interdum
condimentum.
' text from first paragraph.
-On mouse up event, we console log the "clientRects received from RangeFix" so please check the console log.

Follow the same scenario on the Google Chrome browser, Firefox, and Edge browser.
Observe the console log on the respective browser.

Note: I have verified on windows 10
Chrome browser Version 105.0.5195.102 (Official Build) (64-bit),
Firefox 104.0.2 (64-bit), and
Microsoft Edge Version 105.0.1343.33 (Official build) (64-bit)

Observation: Received clientRects from the Below code
let range = document.getSelection().getRangeAt(0);
let rects = RangeFix.getClientRects(range);

Google Chrome: 4 clientRects
Firefox: 3 clientRects
Microsoft Edge: 4 clientRects

One more eg. select the first 4 lines from the document and check the console log on Chrome and Firefox it gives a different result.
At my end, I am receiving 10 rects in Chrome and 6 rects in Firefox.

from rangefix.

edg2s avatar edg2s commented on May 25, 2024

A minimal test case is:

<p>Foo <b>bar</b> baz<p>

In Chrome you get a rect for the text node "bar" as well as a rect for the <b> element. In Firefox you only get one for the <b> tag.

I don't know which behaviour is closer to spec, or if this library could detect and fix it. Generally when using the rects lists you should assume that the rects could overlap and adapt your use case accordingly.

from rangefix.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.