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:
Retrieve the page object where you want to create the text reply from CPDFDocument.
Get the annotation on the page object.
Create a text reply annotation on the annotation and add the reply content.
Here's an example code for creating a text reply:
// 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");
// 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:
- Retrieve the page object where you want to create the state reply from
CPDFDocument
. - Get the annotation on the page object.
- Create mark state reply annotations and review state reply annotations on the annotation.
Here's an example code for creating state replies:
// 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);
// 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
Name | Description |
---|---|
MarkState.MARKED | Check state, used for mark replies |
MarkState.UNMARKED | Uncheck state, used for mark replies |
ReviewState.REVIEW_ACCEPTED | Accepted state, used for review replies |
ReviewState.REVIEW_ACCEPTED | Rejected state, used for review replies |
ReviewState.CANCELLED | Canceled state, used for review replies |
ReviewState.COMPLETED | Completed state, used for review replies |
ReviewState.NONE | No state, used for review replies |
ReviewState.ERROR | Error 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:
- Retrieve the page object you need from
CPDFDocument
. - Get the annotation on the page object.
- Get all replies of the annotation.
Here's an example code for getting all replies:
// 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();
// 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