stephanrauh / ngx-extended-pdf-viewer

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

All annotation tools break after first use #2634

Closed pneves-ciandt closed 1 week ago

pneves-ciandt commented 1 week ago

Whenever I use the highlighter or the drawing tool, or even the "add text", the viewer breaks after I add the first one. For the highlighter, if I try to highlight a second selection, it starts drawing the highlighter wherever I drag my mouse and it won't stop, and I cant select any of the highlights afterwards. The same for the drawing tool, I cant select the annotations and move them nor delete them. For the highlights, I get this error on the console:

Uncaught TypeError: Cannot read properties of null (reading 'isEmpty')
    at #Ra (viewer-4.7.693.min.mjs:23:299624)
    at pointerUpCallback (viewer-4.7.693.min.mjs:23:298847)
    at j.invokeTask (zone.js:402:31)
    at N.runTask (zone.js:173:47)
    at M.invokeTask [as invoke] (zone.js:483:34)
    at J (zone.js:1631:18)
    at ue (zone.js:1674:33)
    at Oe (zone.js:1695:16)

To make sure I wasn't getting conflicts with any other libs, I created a new empty angular app with just the viewer and a component with an empty div where I loaded a sample PDF like this:

<app-header></app-header>
<div class="content">
  <ngx-extended-pdf-viewer style="width: 100%;"
    [src]="'https://pdfobject.com/pdf/sample.pdf'"
    [height]="'90vh'"
    [textLayer]="true" />
</div>

But I'm still getting all the errors, which is weird because I see it working on the https://pdfviewer.net/extended-pdf-viewer/textlayer page. I even tried to update to the alpha version to see if it was something that was fixed, but still got nothing. I am completely lost, if anyone could help me make this work. I'll update this with a link to a video showing the errors as soon as I can

pneves-ciandt commented 1 week ago

Samples:

https://github.com/user-attachments/assets/a0e88b53-2c60-47c7-a32b-fcbf6a3f9dcd https://github.com/user-attachments/assets/a983c939-98c4-4284-b700-d8f6258cd8e6

pneves-ciandt commented 1 week ago

Even though the ngx-extended-pdf-viewer says it works with Angular 16, this error above is only fixed when I run it on Angular 17. Updating my Angular version did the trick

stephanrauh commented 1 week ago

Interesting. Are you sure the root problem is the Angular version? For me, the easy way out is to increase the minimum required version, so I expect a "yes"... but to be honest, I'd hate to force Angular developers to update just because I'm lazy.

stephanrauh commented 1 week ago

BTW, when you submit an error, it's a good idea to set the attribute [minifiedJSLibraries]="false". It makes both debugging and understanding stack traces easier.

pneves-ciandt commented 1 week ago

@stephanrauh Ah, thanks. It was my first time doing it. But yeah, I upgraded all angular libs from 16 to 17 and it worked like a charm without changing anything else. The errors on the video above didn't happen anymore....