PdfPageFacade.AddTextAnnotation(PdfRectangle, String) Method
In This Article
Adds a text annotation to the specified area on the page.
Namespace: DevExpress.Pdf
Assembly: DevExpress.Pdf.v24.2.Core.dll
NuGet Package: DevExpress.Pdf.Core
#Declaration
public PdfTextAnnotationFacade AddTextAnnotation(
PdfRectangle rect,
string iconName
)
#Parameters
Name | Type | Description |
---|---|---|
rect | Pdf |
A page area to add the text annotation. |
#Optional Parameters
Name | Type | Default | Description |
---|---|---|---|
icon |
String | "Note" | The name of the annotation icon. |
#Returns
Type | Description |
---|---|
Pdf |
An object that contain text annotation properties. |
#Remarks
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, PdfTextAnnotationIconName.Help);
// 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");
}
See Also