officefileapi-devexpress-dot-pdf-dot-pdfpagefacade-dot-addtextannotation-x28-devexpress-dot-pdf-dot-pdfrectangle-x29.md
Adds a text annotation to the specified area on the page.
Namespace : DevExpress.Pdf
Assembly : DevExpress.Pdf.v25.2.Core.dll
NuGet Package : DevExpress.Pdf.Core
public PdfTextAnnotationFacade AddTextAnnotation(
PdfRectangle rect
)
Public Function AddTextAnnotation(
rect As PdfRectangle
) As PdfTextAnnotationFacade
| Name | Type | Description |
|---|---|---|
| rect | PdfRectangle |
A page area to add the text annotation.
|
| Type | Description |
|---|---|
| PdfTextAnnotationFacade |
An object that contains text annotation properties.
|
The code sample below creates a sticky note above a specific text:
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 text = "Xbox";
PdfTextSearchResults searchResults = processor.FindText(text);
if (searchResults.Status == PdfTextSearchStatus.Found)
{
// Add a sticky note to this phrase
PdfTextAnnotationFacade stickyNote =
page.AddTextAnnotation(searchResults.Rectangles[0].BoundingRectangle);
// Specify annotation properties
stickyNote.Author = "Bill Smith";
stickyNote.Subject = "Important!";
stickyNote.Contents = "Please, fact-check this reference";
stickyNote.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 text As String = "Xbox"
Dim searchResults As PdfTextSearchResults = processor.FindText(text)
If searchResults.Status = PdfTextSearchStatus.Found Then
' Add a sticky note to this phrase
Dim stickyNote As PdfTextAnnotationFacade =
page.AddTextAnnotation(searchResults.Rectangles(0).BoundingRectangle)
' Specify annotation properties
stickyNote.Author = "Bill Smith"
stickyNote.Subject = "Important!"
stickyNote.Contents = "Please, fact-check this reference"
stickyNote.Color = New PdfRGBColor(0.10, 0.85, 1.00)
End If
' Save the result
processor.SaveDocument("..\\..\\Result.pdf");
End Using
See Also