Adding Instant comments to PDFs on Android

Nutrient Android SDK provides a user interface (UI) for viewing, adding, and deleting comments in PDF documents. The component, Instant Comments, is available only if you’re using Nutrient Instant.

Comments enable collaborative workflows where multiple users can discuss specific sections of a PDF document without leaving the viewer. Nutrient Instant enables users to receive updates in real time.

Licensing

Comments require a separate component in your Nutrient license. Without this included in your license, you won’t be able to add the functionality of viewing, searching, or adding comments in your application. 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, ask our Sales team for a trial license if you’re interested.

Terminology

Before starting, here are a few key terms related to comments:

  • Root annotation — The annotation to which all the comments in a single thread are linked.

  • Comment thread — A group of comments associated with the same root annotation.

  • Comment — A single comment added by a user.

Root annotation types

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 icon) comment menu item. 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 Nutrient Instant Comments tool is disabled by default. If your Document Engine license includes it, 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

You can add comments in two ways, depending on the type of root annotation.

Annotation creation menu

To add a comment marker annotation, press the annotation icon in the main toolbar and select the comment tool. Tap anywhere on the document to add the comment marker annotation at that location.

comment-toolbar

Using text markup annotations

To add a comment linked to a text in the document, select the text, and tap the three dots icon to select the Comments option. This opens a comment editor where you can add your first comment and start the new thread.

comment-markup-menu

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 the 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.