Introduction to Annotations

PSPDFKit Libraries supports most common annotation types:

These are standard annotations (as defined in the PDF Reference) that can be read and written by many apps, including Adobe Acrobat and Apple’s Preview app.

Working with Annotations in Code

The PSPDFKit .NET Library uses Instant Annotation JSON to read and write annotations to and from a document, which allows for reusability across many of our products.

When a document is loaded, it’s possible to query the document to return the annotation representation of the document. Using GetAnnotations, you will receive a JArray populated with the annotation information of the page queried.

For more information on the Annotation JSON format, please see our Server guides.

Creating and Deleting Annotations

To create an annotation on a page, simply use the annotation JSON format to add the annotation you want:

Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
var annotationJson = new JObject
{
    {"backgroundColor", "#FF0000"},
    {"bbox", new JArray(10, 10, 400, 400)},
    {"creatorName", "Me"},

    ...

    {"type", "pspdfkit/text"},
    {"updatedAt", "2018-08-21T14:35:51Z"},
    {"v", 1}
};
document.GetAnnotationProvider().AddAnnotation(annotationJson);

To delete an annotation, you need to reference the pageIndex and pdfObjectId of the annotation in the document:

1
document.GetAnnotationProvider().RemoveAnnotation(0, 1);