officefileapi-devexpress-dot-pdf-dot-pdfpagefacade-dot-addtextmarkupannotation-x28-devexpress-dot-pdf-dot-pdforientedrectangle-devexpress-dot-pdf-dot-pdftextmarkupannotationtype-x29.md
Creates a text markup annotation at the specified page area.
Namespace : DevExpress.Pdf
Assembly : DevExpress.Pdf.v25.2.Core.dll
NuGet Package : DevExpress.Pdf.Core
public PdfTextMarkupAnnotationFacade AddTextMarkupAnnotation(
PdfOrientedRectangle textRectangle,
PdfTextMarkupAnnotationType style
)
Public Function AddTextMarkupAnnotation(
textRectangle As PdfOrientedRectangle,
style As PdfTextMarkupAnnotationType
) As PdfTextMarkupAnnotationFacade
| Name | Type | Description |
|---|---|---|
| textRectangle | PdfOrientedRectangle |
A rectangle that specifies a page area where the annotation should be located.
| | style | PdfTextMarkupAnnotationType |
The text markup annotation type.
|
| Type | Description |
|---|---|
| PdfTextMarkupAnnotationFacade |
An object that contain text markup annotation properties.
|
If a specified page area does not contain text, the AddTextMarkupAnnotation 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
PdfDocumentFacade facade = processor.DocumentFacade;
PdfPageFacade page = facade.Pages[0];
// Find the target phrase in the document
string strikeOutText = "Xbox";
PdfTextSearchResults strikeSearchResults = processor.FindText(strikeOutText);
if (strikeSearchResults.Status == PdfTextSearchStatus.Found)
{
// Add text markup annotation to this phrase
PdfTextMarkupAnnotationFacade strikeOutAnnotation =
page.AddTextMarkupAnnotation(strikeSearchResults.Rectangles[0], 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);
}
}
Using processor As New PdfDocumentProcessor()
' Load a document
processor.LoadDocument("..\..\Document.pdf")
' Access the first page properties
Dim facade As PdfDocumentFacade = processor.DocumentFacade
Dim page As PdfPageFacade = facade.Pages(0)
' Find the target phrase in the document
Dim strikeOutText As String = "Xbox"
Dim strikeSearchResults As PdfTextSearchResults = processor.FindText(strikeOutText)
If strikeSearchResults.Status = PdfTextSearchStatus.Found Then
' Add text markup annotation to this phrase
Dim strikeOutAnnotation As PdfTextMarkupAnnotationFacade =
page.AddTextMarkupAnnotation(strikeSearchResults.Rectangles(0), 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
End Using
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the AddTextMarkupAnnotation(PdfOrientedRectangle, PdfTextMarkupAnnotationType) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
pdf-document-api-highlight-search-results/CS/HighlightSearchResults/Program.cs#L68
PdfTextMarkupAnnotationFacade annotation =
page.AddTextMarkupAnnotation(result.Rectangles[i], PdfTextMarkupAnnotationType.Highlight);
if (annotation != null)
pdf-document-api-highlight-search-results/VB/HighlightSearchResults/Program.vb#L57
For i As Integer = 0 To result.Rectangles.Count - 1
Dim annotation As PdfTextMarkupAnnotationFacade = page.AddTextMarkupAnnotation(result.Rectangles(i), PdfTextMarkupAnnotationType.Highlight)
If annotation IsNot Nothing Then
See Also