Closed NazarKalytiuk closed 3 weeks ago
OK. Let me ponder about it. The idea of hiding annotation is new to me, so I'd like to think about it.
As for exporting the annotations: Does NgxExtendedPdfViewerService.getSerializedAnnotations()
do the trick for you?
Does NgxExtendedPdfViewerService.getSerializedAnnotations() do the trick for you?
- No, it returns only annotations made with the library.
I want this primary to be able to download files with and without annotations. And it is preferable to use native annotations.
You can simply hide the annotations with CSS:
.annotationEditorLayer, .annotationLayer {
display: none;
}
Of course, that doesn't remove the annotations from the PDF file, it only hides them from the user.
To remove the annotations entirely, you have to access a low-level API:
const PDFViewerApplication: IPDFViewerApplication = (window as any).PDFViewerApplication;
if (!PDFViewerApplication?.pdfDocument?.annotationStorage) {
... // remove everything from the annotationStorage hash table
}
Note that probably changing the annotationStorage
doesn't re-render the page.
BTW, if you only want to remove editor annotions, you can use pdfViewerService.removeEditorAnnotations()
, as shown on https://pdfviewer.net/extended-pdf-viewer/export-annotations.
I've just seen that you can't remove annotations that were already stored in the document. You can only remove annotations that have been added after loading the document.
In Google Chrome default viewer there is a button show/hide annotations.
In the library these annotations render, but I didn't find how to hide them or get as JSON etc.
I added an annotation with the macos books app. pdfsample annorated.pdf