PdfPageFacade.AddTextMarkupAnnotation(IEnumerable<PdfOrientedRectangle>, PdfTextMarkupAnnotationType) Method
In This Article
Creates a text markup annotation at the specified page area.
Namespace: DevExpress.Pdf
Assembly: DevExpress.Pdf.v24.2.Core.dll
NuGet Package: DevExpress.Pdf.Core
#Declaration
public PdfTextMarkupAnnotationFacade AddTextMarkupAnnotation(
IEnumerable<PdfOrientedRectangle> textRectangles,
PdfTextMarkupAnnotationType style
)
#Parameters
Name | Type | Description |
---|---|---|
text |
IEnumerable<Pdf |
A collection of rectangles that specify a page area where the annotation should be located.’ |
style | Pdf |
The text markup annotation type. |
#Returns
Type | Description |
---|---|
Pdf |
An object that contain text markup annotation properties. |
#Remarks
This method returns null if the collection of PdfOrientedRectangle objects is empty.
The code sample below highlights a specific text in the document:
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
// Load a document
processor.LoadDocument("..\\..\\Document.pdf");
// Access the first page properties
PdfPageFacade page = pdfDocumentProcessor.DocumentFacade.Pages[0];
// Find the phrase to highlight
string annotatedText =
"We estimate that each component of Ounce provides independent pseudorandom theory.";
PdfTextSearchResults searchResults = pdfDocumentProcessor.FindText(annotatedText);
if (searchResults.Status == PdfTextSearchStatus.Found)
{
// Highlight found text
PdfTextMarkupAnnotationFacade textMarkupAnnotation =
page.AddTextMarkupAnnotation(searchResults.Rectangles, PdfTextMarkupAnnotationType.Highlight);
// Specify annotation properties
textMarkupAnnotation.Author = "Bill Smith";
textMarkupAnnotation.Subject = "Important!";
textMarkupAnnotation.Contents = "Please, fact-check this diagram";
textMarkupAnnotation.Color = new PdfRGBColor(0.10, 0.85, 1.00);
}
// Save the result
processor.SaveDocument("..\\..\\Result.pdf");
}
See Also