coolwanglu / pdf2htmlEX

Convert PDF to HTML without losing text or format.
http://coolwanglu.github.com/pdf2htmlEX/
Other
10.37k stars 1.84k forks source link

Selection jumps #62

Open nmm opened 11 years ago

nmm commented 11 years ago

Selection "jumps" when selecting multiple paragraphs( FF and Chrome). Here is simple sample - try to select some of the internal paragraphs - the selections jumps and blinks. https://www.dropbox.com/s/upc6tdbnzt3isvb/TestSimple.html

coolwanglu commented 11 years ago

The reason is that there is some distance between the letters. The distance is not literally a space ' ', just a positional shift.

It's a known issue, I cannot add a space there since otherwise if you copy & paste the text, you will see an extra space.

There are only 2 possible workarounds

If you have better solutions, please tell me.

Marked this issue as "need solution"

jahewson commented 11 years ago

I may have found a solution to this problem. Placing a non-absolutely positioned <div> at the start of the page fixes it:

<div id="pdf-main">
  <div class="d" style="width:595.320000px;height:841.920000px;">
    <div id="p1" data-page-no="1" class="p">
      <div class="b" style="background-image:url('data:image/png;base64,iVBORw0KGgoAA...5CYII=');background-position:0 0;background-size:595.320000px 841.920000px;background-repeat:no-repeat;">
      <div><!-- adding this empty div gives the page some non-absolute content--></div>
      <div style="left:70.824000px;bottom:760.780000px;" class="l t1 h0">
        <span class="f1 s1 c0 l0 w0 r0">Lorem ipsum...

Edit: actually I may have been confused about the original problem - this is a fix for flickering/blinking when changing the selection quickly, not jumping. Though the original post did mention that the selection "blinks".

coolwanglu commented 11 years ago

OK, I'll have a try

coolwanglu commented 11 years ago

I just tried the empty div trick, which didn't work on my machine (Linux + Firefox 18.0.1)

On Thu, Jan 24, 2013 at 7:22 AM, John Hewson notifications@github.comwrote:

I have found a solution to this problem. Placing a non-absolutely positioned

at the start of the page fixes it:

```
Lorem ipsum... ``` — Reply to this email directly or view it on GitHubhttps://github.com/coolwanglu/pdf2htmlEX/issues/62#issuecomment-12628602.
jahewson commented 11 years ago

I was using Chrome 23 on OS X - it may be a Chrome bug...

coolwanglu commented 11 years ago

@nmm Can you please provide the original PDF?

coolwanglu commented 11 years ago

@jahewson Tried your solution on Chrome 26 + Windows, and it didn't work. The selection blinks when the cursor is in the gap between two lines, i.e. the areas that are not occupied by the bounding box of the characters. At this point, Chrome would consider the selection ends to the beginning -- might be valid in some sense?

It might be solved with JavaScript, I guess. But I doubt if it will be worth it.