.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

PdfDocumentProcessor.AddTextMarkupAnnotation(PdfDocumentPosition, PdfDocumentPosition, PdfTextMarkupAnnotationType) Method

Creates a text markup annotation for text located between the specified positions on the page.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Docs.v21.1.dll

Declaration

public PdfTextMarkupAnnotationData AddTextMarkupAnnotation(
    PdfDocumentPosition startPosition,
    PdfDocumentPosition endPosition,
    PdfTextMarkupAnnotationType style
)

Parameters

Name Type Description
startPosition PdfDocumentPosition

The start point of a page area that should be annotated.

endPosition PdfDocumentPosition

The end point of a page area that should be annotated.

style PdfTextMarkupAnnotationType

The text markup annotation type.

Returns

Type Description
PdfTextMarkupAnnotationData

The text markup annotation.

Remarks

If a specified page area does not contain text, the annotation is not created and the method returns null.

Example

The code sample below highlights text with blue and adds a sticky note at the page corner.

image

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

    //Add a text markup annotation at the first page:
    PdfTextMarkupAnnotationData textMarkup =
    processor.AddTextMarkupAnnotation(1, new PdfRectangle(90, 100, 240, 230),
    PdfTextMarkupAnnotationType.Highlight);

    if (textMarkup != null)
    {
        //Specify the annotation properties:
        textMarkup.Author = "Bill Smith";
        textMarkup.Contents = "Important!";
        textMarkup.Color = new PdfRGBColor(0.8, 0.2, 0.1);
    }

    //Add a sticky note at the first page:
    PdfTextAnnotationData textAnnotation =
    processor.AddTextAnnotation(1, new PdfPoint(100, 300));

    //Specify the annotation parameters:
    textAnnotation.Author = "Nancy Davolio";
    textAnnotation.Checked = true;
    textAnnotation.Color = new PdfRGBColor(0.8, 0.2, 0.1);
    textAnnotation.Contents = "Please proofread this document";
    textAnnotation.IconName = PdfTextAnnotationIconName.Check;

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