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

PdfDocumentProcessor.AddTextMarkupAnnotation(Int32, PdfRectangle, PdfTextMarkupAnnotationType) Method

Adds a text markup annotation to the specified rectangle that corresponds to a text that should be annotated on the page.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Docs.v19.1.dll

Declaration

public PdfTextMarkupAnnotationData AddTextMarkupAnnotation(
    int pageNumber,
    PdfRectangle rectangle,
    PdfTextMarkupAnnotationType style
)

Parameters

Name Type Description
pageNumber Int32

An integer value that specifies the number of a page where the annotation should be added.

rectangle PdfRectangle

A PdfRectangle object that represents the rectangle corresponding 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

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

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

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

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the AddTextMarkupAnnotation(Int32, PdfRectangle, PdfTextMarkupAnnotationType) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also