[Feature]: Serialization / Deserialization of Annotations with Viewer Update #18962
Unanswered
BeingAStudentIsPainful
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is the feature relevant to the Firefox PDF Viewer?
No
Feature description
I’m working on adding a feature to PDF.js that allows serialization and deserialization of PDF annotations for persistent storage across sessions. My goal is to allow users to save annotations as JSON and re-import them, displaying them immediately in the PDF viewer. While I was able to serialize and deserialize annotations using AnnotationStorage, I have been unable to get the deserialized annotations to render in the viewer.
Approach and Issues:
Attempts to Trigger Display:
To try and display the deserialized annotations, I added "Serialize Annotations" and "Deserialize Annotations" buttons in
viewer.html
, and wired up functions in viewer.js to callserialize
anddeserialize
onAnnotationStorage
. After deserialization, I tried triggeringrender
on the annotation and editor layers, but these attempts didn’t display the annotations either. In short, despite the data being present inAnnotationStorage
, nothing displays in the viewer.Current Workarounds
Currently, there is no feasible workaround. Reloading the PDF document does not make the deserialized annotations appear, and calling render functions on the annotation layers has no effect on displaying the annotations after deserialization.
P.S. I’m fairly new to the PDF.js project and have limited experience with its internals. I’ve tried various methods to get the deserialized annotations to display but haven’t been successful. Any guidance or support would be greatly appreciated. Thank you for considering this feature, and I’d be happy to provide additional details if needed.
Source.zip
Other PDF viewers
While similar functionality can be achieved in other PDF viewers, it often requires custom implementation. For example:
I've attached the source code below
PDFViewer.txt
Beta Was this translation helpful? Give feedback.
All reactions