Skip to content

Annotation Replies

Annotation replies enable you and other users to engage in written discussions directly within the document. ComPDFKit provides convenient APIs for accessing replies in the document, as well as user interface (UI) components for viewing and editing replies.

Creating Text Replies

Text replies allow you to add written responses below annotations, commonly used for discussions related to the annotation.

The steps to create a text reply are as follows:

  1. Retrieve the page object where you want to create the text reply from CPDFDocument.

  2. Get the annotation on the page object.

  3. Create a text reply annotation on the annotation and add the reply content.

Here's an example code for creating a text reply:

java
// Retrieve the page object where you want to create the note
CPDFPage page = document.pageAtIndex(0);
// Get the annotation on the page
CPDFAnnotation annotation = page.getAnnotations().get(0);
// Create a reply annotation and add reply content
CPDFReplyAnnotation replyAnnotation = annotation.createReplyAnnotation();
replyAnnotation.setContent("ComPDFKit");
kotlin
// Retrieve the page object where you want to create the note
val page = document.pageAtIndex(0)
// Get the annotation on the page
val annotation = page.annotations[0]
// Create a reply annotation and add reply content
val replyAnnotation = annotation.createReplyAnnotation()
replyAnnotation.content = "ComPDFKit"

Creating State Replies

State replies allow you to mark the state of annotations, categorized into mark states and review states, which can be distinguished using the ReviewState enumeration type.

The steps to create a state reply are as follows:

  1. Retrieve the page object where you want to create the state reply from CPDFDocument.
  2. Get the annotation on the page object.
  3. Create mark state reply annotations and review state reply annotations on the annotation.

Here's an example code for creating state replies:

java
// Retrieve the page object where you want to create the note
CPDFPage page = document.pageAtIndex(0);
// Get the annotation on the page
CPDFAnnotation annotation = page.getAnnotations().get(0);
// Create a mark state reply
annotation.setMarkedAnnotState(CPDFAnnotation.MarkState.MARKED);
// Create a review state reply
annotation.setReviewAnnotState(CPDFAnnotation.ReviewState.REVIEW_ACCEPTED);
kotlin
// Retrieve the page object where you want to create the note
val page = document.pageAtIndex(0)
// Get the annotation on the page
val annotation = page.annotations[0]
// Create a mark state reply
annotation.setMarkedAnnotState(CPDFAnnotation.MarkState.MARKED)
// Create a review state reply
annotation.setReviewAnnotState(CPDFAnnotation.ReviewState.REVIEW_ACCEPTED)

Enumeration Types for State Reply Annotations

NameDescription
MarkState.MARKEDCheck state, used for mark replies
MarkState.UNMARKEDUncheck state, used for mark replies
ReviewState.REVIEW_ACCEPTEDAccepted state, used for review replies
ReviewState.REVIEW_ACCEPTEDRejected state, used for review replies
ReviewState.CANCELLEDCanceled state, used for review replies
ReviewState.COMPLETEDCompleted state, used for review replies
ReviewState.NONENo state, used for review replies
ReviewState.ERRORError state

Getting All Replies

The feature to get all replies allows you to retrieve all replies under an annotation, including text replies and state replies. The ReviewState enumeration type can be used to distinguish the reply types.

The steps to get all replies are as follows:

  1. Retrieve the page object you need from CPDFDocument.
  2. Get the annotation on the page object.
  3. Get all replies of the annotation.

Here's an example code for getting all replies:

java
// Retrieve the page object where you want to create the note
CPDFPage page = document.pageAtIndex(0);
// Get the annotation on the page
CPDFAnnotation annotation = page.getAnnotations().get(0);
// Get all replies of the annotation
CPDFReplyAnnotation[] replyAnnotations = annotation.getAllReplyAnnotations();
kotlin
// Retrieve the page object where you want to create the note
val page = document.pageAtIndex(0)
// Get the annotation on the page
val annotation = page.annotations[0]
// Get all replies of the annotation
val replyAnnotations = annotation.allReplyAnnotations