officefileapi-devexpress-dot-pdf-dot-pdfpagefacade-dot-addtextmarkupannotation-x28-devexpress-dot-pdf-dot-pdfrectangle-devexpress-dot-pdf-dot-pdftextmarkupannotationtype-x29.md
Creates a text markup annotation for the text located in the specified page rectangle.
Namespace : DevExpress.Pdf
Assembly : DevExpress.Pdf.v25.2.Core.dll
NuGet Package : DevExpress.Pdf.Core
public PdfTextMarkupAnnotationFacade AddTextMarkupAnnotation(
PdfRectangle rectangle,
PdfTextMarkupAnnotationType style
)
Public Function AddTextMarkupAnnotation(
rectangle As PdfRectangle,
style As PdfTextMarkupAnnotationType
) As PdfTextMarkupAnnotationFacade
| Name | Type | Description |
|---|---|---|
| rectangle | PdfRectangle |
The rectangle with the text that should be annotated.
| | style | PdfTextMarkupAnnotationType |
The text markup annotation type.
|
| Type | Description |
|---|---|
| PdfTextMarkupAnnotationFacade |
An object that contain text markup annotation properties.
|
If a specified rectangle does not contain text, the annotation is not created and the method returns null.
The code sample below strikes out specific text in the document:
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
// Load a document
processor.LoadDocument("..\\..\\Document.pdf");
// Access the first page properties
PdfPageFacade page = processor.DocumentFacade.Pages[0];
// Find the target phrase in a document
string strikeOutText = "Xbox";
PdfTextSearchResults strikeSearchResults = processor.FindText(strikeOutText);
if (strikeSearchResults.Status == PdfTextSearchStatus.Found)
{
// Add a text annotation to this phrase
PdfTextMarkupAnnotationFacade strikeOutAnnotation =
page.AddTextMarkupAnnotation(strikeSearchResults.Rectangles[0].BoundingRectangle, PdfTextMarkupAnnotationType.StrikeOut);
// Specify annotation properties
strikeOutAnnotation.Author = "Bill Smith";
strikeOutAnnotation.Subject = "Important!";
strikeOutAnnotation.Contents = "Please, fact-check this reference";
strikeOutAnnotation.Color = new PdfRGBColor(0.10, 0.85, 1.00);
}
// Save the result
processor.SaveDocument("..\\..\\Result.pdf");
}
Using processor As New PdfDocumentProcessor()
' Load a document
processor.LoadDocument("..\..\Document.pdf")
' Access the first page properties
Dim page As PdfPageFacade = processor.DocumentFacade.Pages(0)
' Find the target phrase in a document
Dim strikeOutText As String = "Xbox"
Dim strikeSearchResults As PdfTextSearchResults = processor.FindText(strikeOutText)
If strikeSearchResults.Status = PdfTextSearchStatus.Found Then
' Add a text annotation to this phrase
Dim strikeOutAnnotation As PdfTextMarkupAnnotationFacade = page.AddTextMarkupAnnotation(strikeSearchResults.Rectangles(0).BoundingRectangle, PdfTextMarkupAnnotationType.StrikeOut)
' Specify annotation properties
strikeOutAnnotation.Author = "Bill Smith"
strikeOutAnnotation.Subject = "Important!"
strikeOutAnnotation.Contents = "Please, fact-check this reference"
strikeOutAnnotation.Color = New PdfRGBColor(0.10, 0.85, 1.00)
End If
' Save the result
processor.SaveDocument("..\\..\\Result.pdf");
End Using
See Also