-
Notifications
You must be signed in to change notification settings - Fork 190
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
Saving and reapplying annotations inconsistency #2355
Comments
@stephanrauh nuisance? Is there a simple work-around in which I can adjust for the apparent offsets that occur within |
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://private-user-images.githubusercontent.com/79384354/336107298-d071c4f8-dfc4-4b14-8fd5-616fbaae8c58.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NTQzOTAsIm5iZiI6MTczODk1NDA5MCwicGF0aCI6Ii83OTM4NDM1NC8zMzYxMDcyOTgtZDA3MWM0ZjgtZGZjNC00YjE0LThmZDUt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ODQ1ZGRhZjUyNjAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.H8xH9j7NgUL2BrKIyEEZmk20CvYoSASgJAXVLmHyqHE)
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.
The text was updated successfully, but these errors were encountered: