Skip to content

Annotation are not loading for highlight #2345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
karankapadni opened this issue May 28, 2024 · 14 comments
Closed

Annotation are not loading for highlight #2345

karankapadni opened this issue May 28, 2024 · 14 comments
Assignees
Labels
bug of the base viewer (Mozilla's pdf.js) Please open the ticket at https://github.com/mozilla/pdf.js/issues bug Something isn't working Confirmed I've managed to reproduce the bug. That's great news: chances are I'll solve it. I'd like to help but it's difficult You've raised an issue that's just right - but for some reason, it's hard to solve.

Comments

@karankapadni
Copy link

I need your help!
Need your help in loading the annotations which are saved before.

Check this first
The pdf Viewer Service has the function to load the annotations addEditorAnnotation()

Describe the bug

  1. Go to Pdf Viewer
  2. Add the highlight using the function addEditorAnnotation(highlight)
  3. highlight is of type HighlightEditorAnnotation
  4. On click of the button once function is fired nothing happens no highlights are loaded

Version info

  • Version of ngx-extended-pdf-viewer - 20.0.2
@stephanrauh stephanrauh self-assigned this May 29, 2024
@stephanrauh
Copy link
Owner

To be honest, I haven't tried adding highlights programmatically yet. I'm sure it's possible, but that's all I know. My best guess is you've forgotten an attribute, used wrong values, or something like this. Adding annotations programmatically is a low-level API that may change at any point in time, so you're in danger zone if you're using it.

The best way to figure out the correct JSON object is reverse engineering. Add a highlight, export it to a JSON object, and play around with it. Sometimes pdf.js is very capricious - for example, if the coordinate are slightly off, it may refuse to render anything at all.

That said, how did you define your highlight object? Can you send me a reproducer? I can't promise to solve the issue, but at least I can promise to have a look at it.

@stephanrauh stephanrauh added Please send me a reproducer A reproducer is a minimal but working project showing the problem. user support You've got a question, or a misconfiguration, or simply need a hint how to get things up and running I'd like to help but it's difficult You've raised an issue that's just right - but for some reason, it's hard to solve. labels May 29, 2024
@karankapadni
Copy link
Author

karankapadni commented May 30, 2024

@stephanrauh Thank you so much, I appreciate your acknowledgement. below is some of the information that might help,
I'm calling function in NgxExtendedPdfViewerService

addEditorAnnotation(serializedAnnotation: string | EditorAnnotation): void;

where type EditorAnnotation is derived from

export type HighlightEditorAnnotation = {
    annotationType: 9;
    color: Array<number>;
    rect: Array<number>;
    pageIndex: number;
    rotation: 0 | 90 | 180 | 270;
};
export type EditorAnnotation = InkEditorAnnotation | FreeTextEditorAnnotation | StampEditorAnnotation | HighlightEditorAnnotation;

and this is the object we are passing to be rendered

{
      "annotationType": 9,
      "color": [
          255,
          203,
          230
      ],
      "pageIndex": 0,
      "rect": [
          56.902778125604456,
          621.2189030686666,
          130.6876860527253,
          637.6820141616604
      ],
      "rotation": 0,
  }

I have got this from export function we have, which is getSerializedAnnotations(), I would appreciate if you let me know whether there is work around or the params passed are wrong.

@DayibBaba
Copy link

DayibBaba commented Jun 1, 2024

I am having the same exact problem. Do you also get warning messages such as Warning: paste: "t is not iterable"?

@karankapadni
Copy link
Author

It is giving me something like Warning:'paste: "boxes is not iterable"'

@stephanrauh
Copy link
Owner

The difference between "t is not iterable" and "boxes is not iterable" may be that one of you is using the minified JavaScript files and the other is not. For debugging or reporting errors, please use the non-minified files. That makes everything a lot easier. The attribute I'm referring to is [minifiedJSLibraries]="false".

@stephanrauh
Copy link
Owner

@DayibBaba Your new ticket (#2355) indicates you've managed to solve this issue. Do you have new insight you can share with us?

@DayibBaba
Copy link

@DayibBaba Your new ticket (#2355) indicates you've managed to solve this issue. Do you have new insight you can share with us?

The images in ticket #2355 showcase a little trick that uses a different annotation method to mimic a highlight. Its essentially a drawing with adjusted opacity.

@stephanrauh
Copy link
Owner

Oh, ok. Yeah, I already wondered about the squiggly highlight. :)

@stephanrauh
Copy link
Owner

I've finally managed to have a look at your issue. I'm afraid I've got bad news. You can't add highlights programmatically because the API I was using simply doesn't work. This, in turn, is because you can't copy and paste highlights, so the programmers didn't care about that and didn't implement the paste API properly. The JSON object you get by exporting the highlight is pretty much useless.

In the long run, I'm not ready to accept that, but in the short term, I'm not able to provide a solution. The only thing I can currently do is documenting that adding highlights is not possible.

stephanrauh added a commit to stephanrauh/extended-pdf-viewer-showcase that referenced this issue Jun 28, 2024
@stephanrauh
Copy link
Owner

I've reluctantly published that highlights aren't supported yet. Just out of curiosity: would you pay money for this feature? I'm a consultant, so paying me for programming is always an option, even though this project is strictly non-commercial.

@stephanrauh stephanrauh added Confirmed I've managed to reproduce the bug. That's great news: chances are I'll solve it. bug of the base viewer (Mozilla's pdf.js) Please open the ticket at https://github.com/mozilla/pdf.js/issues bug Something isn't working and removed Please send me a reproducer A reproducer is a minimal but working project showing the problem. user support You've got a question, or a misconfiguration, or simply need a hint how to get things up and running labels Jun 28, 2024
@ldu2
Copy link

ldu2 commented Nov 19, 2024

I've reluctantly published that highlights aren't supported yet. Just out of curiosity: would you pay money for this feature? I'm a consultant, so paying me for programming is always an option, even though this project is strictly non-commercial.

We are willing to do a sponsor on this, are you still open to this? @stephanrauh

@stephanrauh
Copy link
Owner

@ldu2 Well, maybe. At the moment, I'd have to talk my employer into it, so we're talking about an international contract. I don't know if they do this, but I can ask. Which country do you live in?

@ldu2
Copy link

ldu2 commented Nov 19, 2024

@ldu2 Well, maybe. At the moment, I'd have to talk my employer into it, so we're talking about an international contract. I don't know if they do this, but I can ask. Which country do you live in?

We are in the US.

@ldu2
Copy link

ldu2 commented Nov 20, 2024

@stephanrauh if it's appearing to be problematic, is it possible for you to give me some pointers where I can start to look at and dig into? I'd really appreciate it. Let me know. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug of the base viewer (Mozilla's pdf.js) Please open the ticket at https://github.com/mozilla/pdf.js/issues bug Something isn't working Confirmed I've managed to reproduce the bug. That's great news: chances are I'll solve it. I'd like to help but it's difficult You've raised an issue that's just right - but for some reason, it's hard to solve.
Projects
None yet
Development

No branches or pull requests

4 participants