Some of the PDF.js code mentions an "annotation layer", for example AnnotationLayerBuilder here:
https://github.com/mozilla/pdf.js/blob/95e102c07bc257c2120fd7fd9141762b2c813a1c/web/annotation_layer_builder.js#L118
There is also pdfDocument.annotationStorage
and pdfjsLib.AnnotationLayer
, which - on all the documents I've tried - are empty, even in documents which do have text annotations.
I couldn't find any examples or documentation on the annotation layer and how it is supposed to be used, but it sure sounds interesting :)
What is the annotation layer? Is this talking about standard PDF annotations, as described in https://pspdfkit.com/blog/2018/what-are-annotations/ or https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf section 8.4 Annotations? Or, is it something internal to PDF.js?
How do I list the existing annotations from javascript code in PDF.js, and how do I add one? (just for display; not expecting to be able to save it in the pdf, of course) Can anyone provide a working code example?
Thanks!
PDF annotation is adding suggestions in the form of comments or digital sticky notes to PDF documents in the proofing stage. Basically, PDF annotation refers to providing contextual feedback right inside deliverables in PDF format. Think eBooks, white papers, reports, etc.
Show annotations and drawing markup toolsChoose Tools > Comment to open the Comment toolbar. The comments that you add to the document are displayed in the right pane.
Go to View > Show Markup Toolbar or click the (sketch pen) icon on the top right. Use the selection and the markup tools annotate the PDF. You can use type, sketch, draw, use shapes, add notes, sign, and change the format for all.
Annotations are standard for the PDF file format as described in the links you provided. They are not a new concept to PDF.js.
How you get the annotations will depend on your situation. I'm building a view layer to replace the viewer the PDF.js team built. The basic idea there is you:
const doc = getDocument(url)
const page = await doc.getPage(num)
await page.getAnnotations()
If you're already using the viewer they built, it doesn't appear to be exposed anywhere.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With