Open DayibBaba opened 3 weeks ago
@stephanrauh nuisance? Is there a simple work-around in which I can adjust for the apparent offsets that occur within getSerializedAnnotations()
?
OK, you're right - it's more than a nuisance. It's not as bad as many other bug because it almost works, but you're right, "almost" isn't good enough.
Your bug rings a bell. Coordinates are notoriously difficult with the annotation API. In particular, I noticed that there seems to be an offset shifting annotations upward - pretty much as you've reported. I assume that simply means I haven't understood the coordinates yet. Adding insult to injury, we're talking about an internal API of pdf.js that may change at any point in time. I hope it doesn't, but it happened in the past.
At the moment, I don't know how to proceed. Can I talk you into helping me? I know that's mean because it's you who's asking me for help, but if I give you some clues how to debug, would you like to do it?
OK, you're right - it's more than a nuisance. It's not as bad as many other bug because it almost works, but you're right, "almost" isn't good enough.
Your bug rings a bell. Coordinates are notoriously difficult with the annotation API. In particular, I noticed that there seems to be an offset shifting annotations upward - pretty much as you've reported. I assume that simply means I haven't understood the coordinates yet. Adding insult to injury, we're talking about an internal API of pdf.js that may change at any point in time. I hope it doesn't, but it happened in the past.
At the moment, I don't know how to proceed. Can I talk you into helping me? I know that's mean because it's you who's asking me for help, but if I give you some clues how to debug, would you like to do it?
I am in the middle of a project but, maybe I could look into it. I have already cloned your repo to check your code, haven't looked too deep yet.
I use
getSerializedAnnotations()
to save all annotations to aannotations: EditorAnnotation[]
variable. In turn, I save this as a JSON file on my database (firebase storage). After fetching it back and usingaddEditorAnnotation()
to reapply the annotations, they always seem to have moved just a little upwards. All annotations are pasted back and look to be higher in position then beforehand. This is especially noticeable when highlighting a specific line in the document. Looking into the save data and comparing the values does show differences in the coordinates of the annotations. So somewhere in between saving and reapplying, I am getting inconsistent values in a consistent manner (it always moves slightly upwards).Before reapplication:![image](https://github.com/stephanrauh/ngx-extended-pdf-viewer/assets/79384354/d071c4f8-dfc4-4b14-8fd5-616fbaae8c58)
After:![image](https://github.com/stephanrauh/ngx-extended-pdf-viewer/assets/79384354/6cdfdc70-69e2-4a41-8820-9894a6d8955a)
EDIT: Not saving and simply reapplying seems to work correctly. When an annotation is serialized again, and saved for reapplication, is where the issue seems to occur.