Back to Devexpress

PdfMarkupAnnotationFacade.AddReply(String, String) Method

officefileapi-devexpress-dot-pdf-dot-pdfmarkupannotationfacade-dot-addreply-x28-system-dot-string-system-dot-string-x29.md

latest3.6 KB
Original Source

PdfMarkupAnnotationFacade.AddReply(String, String) Method

Adds a comment to the document annotation.

Namespace : DevExpress.Pdf

Assembly : DevExpress.Pdf.v25.2.Core.dll

NuGet Package : DevExpress.Pdf.Core

Declaration

csharp
public PdfMarkupAnnotationComment AddReply(
    string author,
    string contents
)
vb
Public Function AddReply(
    author As String,
    contents As String
) As PdfMarkupAnnotationComment

Parameters

NameTypeDescription
authorString

The comment’s author.

| | contents | String |

The comment’s text.

|

Returns

TypeDescription
PdfMarkupAnnotationComment

The annotation comment.

|

Example

The code sample below adds two nested comments to all sticky notes (the document in opened in WinForms PDF Viewer):

csharp
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
    // Load a document
    processor.LoadDocument("..\\..\\Document.pdf");

    // Access the first page properties
    PdfPageFacade pageFacade = processor.DocumentFacade.Pages[0];

    // Retrieve all text annotations
    var stickyNotes = pageFacade.Annotations.Where
            (annotation => annotation.Type == PdfAnnotationType.Text);
    foreach (PdfTextAnnotationFacade stickyNote in stickyNotes)
    {
        // Add comments
        AddAnnotationComments(stickyNote);
    }

    // Save the result
    processor.SaveDocument("..\\..\\Result.pdf");
}

private static void AddAnnotationComments(PdfMarkupAnnotationFacade annotation)
{
    PdfMarkupAnnotationComment comment =
       annotation.AddReply("Reviewer", "Done");
    comment.Subject = "Proofread";

    PdfMarkupAnnotationComment nestedComment =
       comment.AddReply(annotation.Author, "Thanks");
    nestedComment.Subject = "Reviewed";
}
vb
Using processor As New PdfDocumentProcessor()
  ' Load a document
  processor.LoadDocument("..\..\Document.pdf")

  ' Access the first page properties
  Dim pageFacade As PdfPageFacade = processor.DocumentFacade.Pages(0)

  ' Retrieve all text annotations
  Dim stickyNotes = pageFacade.Annotations.Where
    (Function(annotation) annotation.Type = PdfAnnotationType.Text)
  For Each stickyNote As PdfTextAnnotationFacade In stickyNotes
    ' Add comments
    AddAnnotationComments(stickyNote)
  Next stickyNote

  ' Save the result
  processor.SaveDocument("..\..\Result.pdf")
End Using

private static void AddAnnotationComments(PdfMarkupAnnotationFacade annotation)
  Dim comment As PdfMarkupAnnotationComment = annotation.AddReply("Reviewer", "Done")
  comment.Subject = "Proofread"

  Dim nestedComment As PdfMarkupAnnotationComment = comment.AddReply(annotation.Author, "Thanks")
  nestedComment.Subject = "Reviewed"

See Also

PdfMarkupAnnotationFacade Class

PdfMarkupAnnotationFacade Members

DevExpress.Pdf Namespace