Skip to content
Guides

Annotation Replies

The annotation replies feature allows you and other users to engage in written discussions directly within the document. ComPDFKit provides a convenient API for accessing replies in the document, along with 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. Obtain the page object.
  2. Retrieve annotations on the page.
  3. Create a text reply annotation on the annotation and add the reply content.

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

C#
// Obtain the page object.
CPDFPage page = document.PageAtIndex(0);

// Retrieve annotations on the page.
CPDFAnnotation annotation = page.GetAnnotations()[0];

// Create a text reply annotation on the annotation and add the reply content.
annotation.CreateReplyAnnotation();

Create State Replies

The status reply feature allows you to mark the status of an annotation, with options for checked and commented states. The status types can be distinguished using the CPDFAnnotationState enumeration.

The steps to create a status reply are as follows:

  1. Obtain the page object.
  2. Retrieve the annotation on the page.
  3. Create a marked state reply.
  4. Create a review state reply.

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

C#
// Obtain the page object.
CPDFPage page = document.PageAtIndex(0);

// Retrieve the annotation on the page.
CPDFAnnotation annotation = page.GetAnnotations()[0];

// Create a marked state reply.
CPDFAnnotation markedReply = annotation.CreateReplyStateAnnotation(CPDFAnnotationState.C_ANNOTATION_MARKED);

// Create a review state reply.
CPDFAnnotation stateReply = annotation.CreateReplyStateAnnotation(CPDFAnnotationState.C_ANNOTATION_ACCEPTED);

Enumeration Types for State Reply Annotations

NameDescription
C_ANNOTATION_MARKEDChecked state, used for checked status replies
C_ANNOTATION_UNMARKEDUnchecked state, used for checked status replies
C_ANNOTATION_ACCEPTEDAccepted state, used for commented status replies
C_ANNOTATION_REJECTEDRejected state, used for commented status replies
C_ANNOTATION_CANCELLEDCancelled state, used for commented status replies
C_ANNOTATION_COMPLETEDCompleted state, used for commented status replies
C_ANNOTATION_NONENo state, used for commented status replies
C_ANNOTATION_ERRORState error

Getting All Replies

The Get All Replies feature allows you to retrieve all replies under an annotation, including text replies and status replies. The reply types can be distinguished using the CPDFReplyAnnotationType enumeration.

The steps to get all replies are as follows:

  1. Obtain the page object.
  2. Retrieve the annotation object on the page.
  3. Retrieve all reply annotations and classify them.
C#
// Obtain the page object.
CPDFPage page = document.PageAtIndex(0);

// Retrieve the annotation object on the page.
CPDFAnnotation annotation = page.GetAnnotations()[0];

// Obtain the status replies of the annotation.
foreach (CPDFAnnotation replyAnnot in annotation.GetReplies())
{
    if(replyAnnot.IsMarkedStateAnnot())
    {
        // Marked state reply.
    }
    else if(replyAnnot.IsReviewStateAnnot())
    {
        // Review state reply.
    }
    else
    {
        // Text reply.
    }
}