Is there an easy way to add sticky notes or comments? #2987
-
Hi, I am currently exploring this library and it's documentation but I did not find any information about sticky notes / comments addition. This pdf viewer loads existing notes from a PDF correctly so I assume there could be a possibility to add my own notes and export PDF in a way so they would be later visible (for example within Acrobat). I checked and when PDF is loaded within the browser, there is an option to add comment and when saved, this comment is later visible within Acrobat. Does anyone managed to implement similar thing? For me it is crucial as it will define if I will be able to rely on this library or not. Cheers, Kamil |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Probably your best option is using pdf-lib. The PDF viewer is able to display sticky notes, but it's not able to add sticky notes dynamically. The editors currently only support the PDF.js annotation subtypes /FreeText, /Ink, /Stamp, /Highlight and /Signature. /FreeText is closely related to /Text, but I doubt the editor rendering engine is able to support /Text. On the other hand - it shouldn't be so difficult. You can use a signal to get the
No idea how this translates in pdf.js datastructures - but chances are they're similar, just more verbose. Here's how to get the PdfViewerApplication object: private PDFViewerApplication: IPDFViewerApplication | undefined;
constructor(
notificationService: PDFNotificationService,
private cdr: ChangeDetectorRef,
) {
effect(() => {
this.PDFViewerApplication = notificationService.onPDFJSInitSignal();
if (this.PDFViewerApplication) {
this.onPdfJsInit();
}
});
} |
Beta Was this translation helpful? Give feedback.
This weekend, I tried to make it work without using an external library. In theory, it must be possible - but how to do it beats me.
Instead, I've added a demo to the showcase showing how to add annotations using pdf-lib. It's not perfect - it shows differently in print, and when I download the file and open it in Chrome, the annotation uses more vertical space than in ngx-extended-pdf-viewer - but I suppose it shows the way to a good solution: https://pdfviewer.net/extended-pdf-viewer/adding-arbitrary-annotations
I'd like to hear from you. Does this approach work for you?