officefileapi-devexpress-dot-pdf-46c16e3c.md
Contains members used to manage text markup annotations (text highlights) without access to their inner structure.
Namespace : DevExpress.Pdf
Assembly : DevExpress.Pdf.v25.2.Core.dll
NuGet Package : DevExpress.Pdf.Core
public class PdfTextMarkupAnnotationFacade :
PdfMarkupAnnotationFacade
Public Class PdfTextMarkupAnnotationFacade
Inherits PdfMarkupAnnotationFacade
The following members return PdfTextMarkupAnnotationFacade objects:
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 PdfPageFacade.Annotations property retrieves all annotations on the page. You can filter text markup annotation properties, cast them to the PdfTextMarkupAnnotationFacade class, and use class properties to modify annotation parameters.
The code sample below changes the markup type and color of all text markup annotations on the first page:
using DevExpress.Pdf;
using System.Linq;
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
// Load a document
processor.LoadDocument("..\\..\\Document.pdf");
// Access the first page properties
PdfPageFacade page = processor.DocumentFacade.Pages[0];
// Retrieve all text markup annotations
var textMarkups = page.Annotations.Where
(annotation => annotation.Type == PdfAnnotationType.TextMarkup);
// Change annotation parameters
foreach (PdfTextMarkupAnnotationFacade markup in textMarkups)
{
markup.MarkupType = PdfTextMarkupAnnotationType.Squiggly;
markup.Color = new PdfRGBColor(0.10, 0.85, 1.00);
}
// Save the result
processor.SaveDocument("..\\..\\Result.pdf");
}
Imports DevExpress.Pdf
Imports System.Linq
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)
' Retrieve all text markup annotations
Dim textMarkups = page.Annotations.Where
(Function(annotation) annotation.Type = PdfAnnotationType.TextMarkup)
' Change annotation parameters
For Each markup As PdfTextMarkupAnnotationFacade In textMarkups
markup.MarkupType = PdfTextMarkupAnnotationType.Squiggly
markup.Color = New PdfRGBColor(0.10, 0.85, 1.00)
Next markup
' Save the result
processor.SaveDocument("..\\..\\Result.pdf")
End Using
Call one of the following methods to flatten an annotation:
| Method | Description |
|---|---|
| PdfDocumentFacade.FlattenAnnotations | Flattens document annotations. |
| PdfPageFacade.FlattenAnnotations | Flattens annotations of a specific page. |
| PdfAnnotationFacade.Flatten() | Flattens a specific annotation. |
The code sample below flattens all text markup annotations on the first page:
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
// Load a document
processor.LoadDocument("..\\..\\Document.pdf");
// Access the first page properties
PdfPageFacade page = processor.DocumentFacade.Pages[0];
// Flatten all text markups
page.FlattenAnnotations(PdfAnnotationType.TextMarkup);
// 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)
' Flatten all text markups
page.FlattenAnnotations(PdfAnnotationType.TextMarkup)
' Save the result
processor.SaveDocument("..\\..\\Result.pdf")
End Using
Call the PdfAnnotationFacade.Remove() method to remove a specific annotation.
The code sample below removes all text markup annotations from the first page:
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
// Load a document
processor.LoadDocument("..\\..\\Document.pdf");
// Access the first page properties
PdfPageFacade page = processor.DocumentFacade.Pages[0];
// Retrieve all text markup annotations
var textMarkups = page.Annotations.Where
(annotation => annotation.Type == PdfAnnotationType.TextMarkup).ToList();
foreach (PdfTextMarkupAnnotationFacade markup in textMarkups)
{
// Remove each annotation
markup.Remove();
}
// 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)
' Retrieve all text markup annotations
Dim textMarkups = page.Annotations.Where
(Function(annotation) annotation.Type = PdfAnnotationType.TextMarkup).ToList()
For Each markup As PdfTextMarkupAnnotationFacade In textMarkups
' Remove each annotation
markup.Remove()
Next markup
' Save the result
processor.SaveDocument("..\\..\\Result.pdf");
End Using
Object PdfAnnotationFacade PdfMarkupAnnotationFacade PdfTextMarkupAnnotationFacade
See Also