stephanrauh / ngx-extended-pdf-viewer

A full-blown PDF viewer for Angular 16, 17, and beyond
https://pdfviewer.net
Apache License 2.0
450 stars 167 forks source link

Display position is not aligned when selecting text in Firefox #2323

Closed myl1992 closed 1 month ago

myl1992 commented 2 months ago

Hello, I am using the text selection tool in different browsers with ngx-extended-pdf-viewer, the position of the selected text displayed in Firefox is significantly different from the actual location, but it works fine in Google Chrome.

text selection in firefox: 图片

text selection in google chrome: 图片

Version info: v19.7.1 Demo pdf link: https://arxiv.org/pdf/1402.7022.pdf

I'm not sure if this is an issue with pdf.js, please help me take a look. Thank you

stephanrauh commented 2 months ago

You can open your file in https://mozilla.github.io/pdf.js/web/viewer.html to find out whether it's a pdf.js problem or my problem.

myl1992 commented 1 month ago

I opened the pdf.js demo file in Firefox browser and compared it with the presentation of pdf.js demo file in ngx-extended-pdf-viewer: extend demo file in pdf.js: pdfjs

Version info: v19.7.1 Demo pdf link: https://github.com/mozilla/pdf.js/blob/master/web/compressed.tracemonkey-pldi-09.pdf

stephanrauh commented 1 month ago

That might shed some light on the mystery. I've tried to reproduce your issue in the showcase, and it works fine - see the screenshot. Can you open the tracemonkey file on https://pdfviewer.net and confirm that, please?

If the selection is correct on https://pdfviewer.net, but not in your application, than your CSS files are causing the problem. This kind of problems is always a bit hard to hunt down. Compare the CSS rules of the text layer in both projects using the Chrome developer tools. With some patience, you'll find the difference, and you'll be able to fix it.

If so, please tell me, so I know I can safely close the ticket.

Screenshot with Chrome:

image

Screenshot with Firefox:

image
myl1992 commented 1 month ago

You are right, it works fine in https://pdfviewer.net/. I think it may be due to some css conflicts caused by other introduced components. Next, I need to do some checks. Thank you very much~

stephanrauh commented 1 month ago

I'm closing the ticket now. I hope you've managed to find the root problem in the meantime!

Best regards, Stephan