Skip to main content
A newer version of this page is available. .
.NET Standard 2.0+

PdfDocumentProcessor.AddTextMarkupAnnotation(PdfDocumentPosition, PdfDocumentPosition, PdfTextMarkupAnnotationType) Method

Adds a text markup annotation for a text located within the specified positions on the page.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Docs.v19.1.dll

Declaration

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

Parameters

Name Type Description
startPosition PdfDocumentPosition

A PdfDocumentPosition object that represents the start point of a page area that corresponds to a text that should be annotated on the page.

endPosition PdfDocumentPosition

A PdfDocumentPosition object that represents the end point of a page area that corresponds to a text that should be annotated on the page.

style PdfTextMarkupAnnotationType

A PdfTextMarkupAnnotationType enumeration value that specifies the markup annotation type to be added to a page.

Returns

Type Description
PdfTextMarkupAnnotationData

A PdfTextMarkupAnnotationData object that represents the created text markup annotation on a page.

Remarks

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

Note

If a text for which the markup annotation is created, starts on one page and ends on another page, this method adds annotation only to a page where the text starts.

After creating a text markup annotation, you can specify the markup annotation properties using PdfTextMarkupAnnotationData object.

Example

This example shows how to create a text markup annotation that highlights a text in a PDF document and specify the annotation properties.

To add a text markup annotation to a page, call one of PdfDocumentProcessor.AddTextMarkupAnnotation overload methods, where specify the page number and a page area corresponding to a text that should be annotated on this page. Note that if a specified page area does not correspond to a text on the page, the annotation is not created and PdfDocumentProcessor.AddTextMarkupAnnotation overload methods return null.

Imports System
Imports DevExpress.Pdf

Namespace CreateMarkupAnnotation
    Friend Class Program
        Shared Sub Main(ByVal args() As String)

            ' Create a PDF Document Processor.
            Using processor As New PdfDocumentProcessor()

                ' Load a document.
                processor.LoadDocument("..\..\Document.pdf")

                ' Add a text markup annotation to the first page for a text corresponding to the specified page area.
                Dim annot As PdfTextMarkupAnnotationData = processor.AddTextMarkupAnnotation(1, New PdfRectangle(90, 100, 240, 230), PdfTextMarkupAnnotationType.Highlight)
                If annot IsNot Nothing Then

                    ' Specify the annotation properties.                    
                    annot.Author = "Bill Smith"
                    annot.Contents = "Note"
                    annot.Color = New PdfRGBColor(0.8, 0.2, 0.1)

                    ' Save the result document.
                    processor.SaveDocument("..\..\Result.pdf")
                Else
                    Console.WriteLine("The annotation cannot be added to a page. Make sure, a specified page area corresponds to a text on the page.")
                End If
            End Using
        End Sub
    End Class
End Namespace
See Also