# Highlight annotation is broken for some pdf

**URL:** <https://pdfjs.community/t/highlight-annotation-is-broken-for-some-pdf/432>\
**Category:** Technical Support\
**Created:** [January 5, 2021, 3:27am UTC](https://pdfjs.community/t/highlight-annotation-is-broken-for-some-pdf/432 "2021-01-05T03:27:16Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![ehtesham.ahmad.nadim](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/ehtesham.ahmad.nadim/32/425_2.png) [@ehtesham.ahmad.nadim](https://pdfjs.community/u/ehtesham.ahmad.nadim)\
**Post date:** [January 5, 2021, 3:27am UTC](https://pdfjs.community/t/highlight-annotation-is-broken-for-some-pdf/432/1 "2021-01-05T03:27:16Z")

</div>

I am using version 7.2.1

For some pdf, the highlight annotation is not working properly. The highlighted text is not taking space as the text in the pdf. The same thing is happening in the official demo.

 ![PDF.js Viewer Demo PDF.js Express](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/fc21db9e8a789a7d4874fc46dd98edd658ae7eb5.jpeg)

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [January 5, 2021, 5:13pm UTC](https://pdfjs.community/t/highlight-annotation-is-broken-for-some-pdf/432/2 "2021-01-05T17:13:57Z")

</div>

Hi there!

Are you able to provide us with that document so we can reproduce and find a fix?

Thank you!  
Logan

---

<div class="post-metadata">

**Author:** ![ehtesham.ahmad.nadim](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/ehtesham.ahmad.nadim/32/425_2.png) [@ehtesham.ahmad.nadim](https://pdfjs.community/u/ehtesham.ahmad.nadim)\
**Post date:** [January 7, 2021, 4:20am UTC](https://pdfjs.community/t/highlight-annotation-is-broken-for-some-pdf/432/3 "2021-01-07T04:20:50Z")

</div>

[pone.0192022.pdf](https://pdfjs.community/uploads/short-url/kzqQo4jeiWedYVEVlvCint4AqD6.pdf) (2.2 MB)

Here it is

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [January 8, 2021, 7:48pm UTC](https://pdfjs.community/t/highlight-annotation-is-broken-for-some-pdf/432/4 "2021-01-08T19:48:09Z")

</div>

Thanks @ehtesham.ahmad.nadim! We can reproduce this issue and are looking into a fix now.

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [January 8, 2021, 10:00pm UTC](https://pdfjs.community/t/highlight-annotation-is-broken-for-some-pdf/432/5 "2021-01-08T22:00:07Z")

</div>

Hey there!

I looked into a bit, and the error is coming from the core PDF.js library which unfortunately we do not support. The issue is reproducible in vanilla PDF.js. You can reproduce by opening your document [here](https://mozilla.github.io/pdf.js/web/viewer.html) and then selecting some text, copying it, and pasting it somewhere else. You will see that there are no spaces in the text.

To get this issue fixed you will have to open a ticket in the open source [PDF.js repo](https://github.com/mozilla/pdf.js).

If you wish, we can also open a ticket there on your behalf, and share the document you posted with your permission. Let us know if you would like us to do that.

If you _do_ open a ticket there, please post a link to it here so we can track it and make sure it gets merged in once the ticket is resolved.

Thank you!  
Logan

---

<div class="post-metadata">

**Author:** ![ehtesham.ahmad.nadim](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/ehtesham.ahmad.nadim/32/425_2.png) [@ehtesham.ahmad.nadim](https://pdfjs.community/u/ehtesham.ahmad.nadim)\
**Post date:** [January 11, 2021, 3:58am UTC](https://pdfjs.community/t/highlight-annotation-is-broken-for-some-pdf/432/6 "2021-01-11T03:58:58Z")

</div>

Hey @Logan,  
Please open a ticket in the PDF.js repo and let me know the update.

---

<div class="post-metadata">

**Author:** ![ehtesham.ahmad.nadim](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/ehtesham.ahmad.nadim/32/425_2.png) [@ehtesham.ahmad.nadim](https://pdfjs.community/u/ehtesham.ahmad.nadim)\
**Post date:** [January 20, 2021, 8:14am UTC](https://pdfjs.community/t/highlight-annotation-is-broken-for-some-pdf/432/7 "2021-01-20T08:14:43Z")

</div>

Hey @Logan ,  
It’s been a while didn’t hear anything from you about the spacing issue. I have found another issue. I think it is related to the spacing issue that I have told you about earlier. When I highlight a mathematical formula in a document pdf js can not recognize the special characters.

 ![PDF.js Viewer Demo PDF.js Express (1)](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/1X/aec216d5c5bf7fa1ba68f7253ab4812177ba0428.jpeg)

I am attaching the document for your convenience.  
[pbio.3000210.pdf](https://pdfjs.community/uploads/short-url/lEid2FaCcc8xco70p4186OtLHk5.pdf) (2.6 MB)

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [January 20, 2021, 3:37pm UTC](https://pdfjs.community/t/highlight-annotation-is-broken-for-some-pdf/432/8 "2021-01-20T15:37:41Z")

</div>

Hey everyone,

Thanks for the additional bug reports here.

There seems to be a lot of other PDF.js users facing the same issue, and there is already multiple bug reports open.

- [https://github.com/mozilla/pdf.js/issues/7310](https://github.com/mozilla/pdf.js/issues/7310)
- [No spaces between words when copying text · Issue #10640 · mozilla/pdf.js · GitHub](https://github.com/mozilla/pdf.js/issues/10640)

I will try out some of the suggested “fixes” in those threads and let you know if I find a solution. I will also track those issues and see if an actual fix is ever released.

Thanks!

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [January 20, 2021, 5:01pm UTC](https://pdfjs.community/t/highlight-annotation-is-broken-for-some-pdf/432/9 "2021-01-20T17:01:36Z")

</div>

Hello,

I tried out some of the fixes that people suggested in the PDF.js bug reports, and some of them _did_ fix the issue, but the fixes caused multiple other issues throughout the SDK so unfortunately I cannot use them.

The issue is deeply rooted inside the PDF.js source code, so unfortunately I cannot do much to help here.

If this is a major issue for you, consider checking out our sister product, [PDFTron WebViewer](https://www.pdftron.com/webviewer/). It is able to parse the text correctly.

I’ll continue to play around with this issue when I get some time, but for now all I can do is track the GitHub issues and hope a fix gets pushed to the PDF.js repo.

Thanks!  
Logan
