PdfDocumentProcessor.AddTextMarkupAnnotation(PdfDocumentArea, PdfTextMarkupAnnotationType) Method
Adds a text markup annotation to the specified page area that corresponds to a text that should be annotated on the page.
Namespace: DevExpress.Pdf
Assembly: DevExpress.Docs.v18.2.dll
Declaration
public PdfTextMarkupAnnotationData AddTextMarkupAnnotation(
PdfDocumentArea area,
PdfTextMarkupAnnotationType style
)
Parameters
Name | Type | Description |
---|---|---|
area | PdfDocumentArea | A PdfDocumentArea object that specifies the document area that should be associated with a text for which the markup annotation is added. |
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 page area does not correspond to a text on the page, the AddTextMarkupAnnotation 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.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-add-a-text-markup-annotation-to-pdf-T545395
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