I recently tried annotating in PDF Viewer provided Mozilla where I can annotate and save the annotations within the pdf.
But my use case is to annotate and export the annotation as JSON, then I want to import it back while rendering the PDF.
I have tried,
// Gets all the annotation data as a map that can be exported as JSON
annotations = pdfDocument.annotationStorage.serializable();
// Tried loading the Annotations by setting it after the new render
pdfjsLib.getDocument({
data: pdfData,
cMapUrl: CMAP_URL,
cMapPacked: CMAP_PACKED,
enableXfa: true,
}).promise.then((_pdfDocument) => {
for (let [key, value] of annotations) {
pdfDocument.annotationStorage.setValue(key,value);
}
})
This stores the annotation to the storage, but it is not rendered in UI. Does anyone have the same use case and tried importing and exporting PDF annotation in Mozilla PDF Js?
Is there any method in the PDFViewer class to import the serialized annotation?
Your small input will be greatly appreciated. Thanks for reading my question.