Adding Instant comments to PDFs on Android

As of PSPDFKit 7 for Android, PSPDFKit provides user interface (UI) components for viewing, adding, and deleting comments in PDF documents. This component, Instant Comments, is available only if you’re using PSPDFKit Instant.

You can use comments to build collaborative workflows where multiple users can discuss specific sections of a document without leaving the viewer. The PSPDFKit Instant engine allows users to receive updates in real time.

Licensing

Comments require a separate component in your PSPDFKit license. Without this included in your license, your app won’t be able to view, search, or add comments. Please contact our Sales team to add comments to your license.

If you’re a new customer, you can try comments without a license key. If you’re an existing customer, please ask our Sales team for a trial license if you’re interested.

Terminology

Before continuing, it’s helpful to first define some terminology as it relates to comments:

  • root annotation — This is the annotation to which all the comments in a single thread are linked.

  • comment thread — This is a group of comments with the same root annotation.

  • comment — This is a single comment added by any user.

Introduction

All comments are linked to their respective root annotations. The comments with the same root annotation are part of a single comment thread. There can be two types of root annotations:

  • TextMarkupAnnotation — You can start a new comment thread by selecting some text and tapping the comment menu item (comment icon). In this case, the text markup annotation created will act as a root annotation.

  • NoteAnnotation — Note annotations are used as the root of comment marker annotations. You can place them anywhere in the PDF document to start comment threads.

Getting Started

The PSPDFKit Instant Comments tool is disabled by default. If your Document Engine license includes it, then you need to explicitly add the INSTANT_COMMENT_MARKER annotation tool type to the editableAnnotationTools of the PdfConfiguration instance you’re using:

val defaultAnnotationTools = PdfConfiguration.Builder().build().enabledAnnotationTools

// Explicitly enable Instant comment markers if your server supports this feature.
val configuration = PdfActivityConfiguration.Builder(context)
    .enabledAnnotationTools(defaultAnnotationTools + AnnotationTool.INSTANT_COMMENT_MARKER)
    .build()
final List<AnnotationTool> annotationTools = new PdfConfiguration.Builder()
    .build()
    .getEnabledAnnotationTools();

// Explicitly enable Instant comment markers if your server supports this feature.
annotationTools.add(AnnotationTool.INSTANT_COMMENT_MARKER);
final PdfActivityConfiguration configuration = new PdfActivityConfiguration.Builder(context)
    .enabledAnnotationTools(annotationTools)
    .build();

Adding a Comment

Since there are two types of root annotations, there are two ways you can add comments with the user interface.

Annotation Creation Menu

comment-toolbar

To add a comment marker, you first need to reveal the annotation creation toolbar. This is done by pressing the annotation icon in the main toolbar and then selecting the comment tool. Now tap anywhere on the document to add the comment marker at that location.

Using Text Markup Annotations

comment-markup-menu

If you want to add a comment linked to text in the document, you can do so by adding a comment to a text markup annotation. To do this, select some text, then tap on the three dots to reveal additional actions, and select the Comments action. This will present a comment editor where you can add your first comment and start the new thread.

Note that, at the moment, we don’t support the addition of comments or comment marker annotations using programmatic APIs. This is something that might change in future.

Deleting a Comment

You can delete an individual comment by invoking the menu for the comment and tapping the trash icon. If all the comments of a thread are deleted, the corresponding root annotation is automatically deleted.

Document Engine currently doesn’t expose any APIs for deleting a comment.

Information

Comment editing isn’t supported in the current version.