officefileapi-devexpress-dot-pdf-dot-pdfpagefacade-dot-addredactannotation-x28-system-dot-collections-dot-generic-dot-ienumerable-devexpress-dot-pdf-dot-pdforientedrectangle-system-dot-boolean-x29.md
Creates a redaction annotation at the specified page area. Allows you to specify whether to use the page coordinate system
Namespace : DevExpress.Pdf
Assembly : DevExpress.Pdf.v25.2.Core.dll
NuGet Package : DevExpress.Pdf.Core
public PdfRedactAnnotationFacade AddRedactAnnotation(
IEnumerable<PdfOrientedRectangle> rectangles,
bool usePageCoordinateSystem = true
)
Public Function AddRedactAnnotation(
rectangles As IEnumerable(Of PdfOrientedRectangle),
usePageCoordinateSystem As Boolean = True
) As PdfRedactAnnotationFacade
| Name | Type | Description |
|---|---|---|
| rectangles | IEnumerable<PdfOrientedRectangle> |
A collection of rectangles that specify a page area where the annotation should be located.
|
| Name | Type | Default | Description |
|---|---|---|---|
| usePageCoordinateSystem | Boolean | True |
true to use the page coordinate system; otherwise, false.
|
| Type | Description |
|---|---|
| PdfRedactAnnotationFacade |
An object that contains redact annotation properties.
|
The following code snippet searches for specific words and creates redaction annotations over them:
using DevExpress.Pdf;
PdfDocumentProcessor pdfProcessor = new PdfDocumentProcessor();
pdfProcessor.LoadDocument("..\\..\\Invoice.pdf");
PdfDocumentFacade documentFacade = pdfProcessor.DocumentFacade;
PdfTextSearchParameters searchParameters =
new PdfTextSearchParameters();
searchParameters.CaseSensitive = true;
searchParameters.WholeWords = true;
string[] search = new string[] { "Maria Anders", "030-0074321", "[email protected]" };
foreach (string word in search)
{
PdfTextSearchResults results = pdfProcessor.FindText(word, searchParameters);
// If the text is found, create an annotation
if (results.Status == PdfTextSearchStatus.Found) {
var pageIndex = results.Page.GetPageIndex();
PdfRedactAnnotationFacade redactAnnotation =
documentFacade.Pages[pageIndex].AddRedactAnnotation(results.Rectangles);
redactAnnotation.Author = "Jane Doe";
// Set the redaction annotation appearance
redactAnnotation.FontColor = new PdfRGBColor(0, 0, 0);
redactAnnotation.FillColor = new PdfRGBColor(1, 1, 1);
redactAnnotation.FontName = "Arial";
redactAnnotation.FontSize = 0; // Enables font auto-size
redactAnnotation.OverlayText = "Classified";
redactAnnotation.TextJustification = PdfTextJustification.Centered;
redactAnnotation.RepeatText = false;
}
}
// Save the document with the redaction annotation
// and send it for review
pdfProcessor.SaveDocument("output_to_review.pdf");
Imports DevExpress.Pdf
Private pdfProcessor As New PdfDocumentProcessor()
pdfProcessor.LoadDocument("..\..\Invoice.pdf")
Dim documentFacade As PdfDocumentFacade = pdfProcessor.DocumentFacade
Dim searchParameters As New PdfTextSearchParameters()
searchParameters.CaseSensitive = True
searchParameters.WholeWords = True
Dim search() As String = { "Maria Anders", "030-0074321", "[email protected]" }
For Each word As String In search
Dim results As PdfTextSearchResults = pdfProcessor.FindText(word, searchParameters)
' If the text is found, create an annotation
If results.Status = PdfTextSearchStatus.Found Then
Dim pageIndex = results.Page.GetPageIndex()
Dim redactAnnotation As PdfRedactAnnotationFacade = documentFacade.Pages(pageIndex).AddRedactAnnotation(results.Rectangles)
redactAnnotation.Author = "Jane Doe"
' Set the redaction annotation appearance
redactAnnotation.FontColor = New PdfRGBColor(0, 0, 0)
redactAnnotation.FillColor = New PdfRGBColor(1, 1, 1)
redactAnnotation.FontName = "Arial"
redactAnnotation.FontSize = 0 ' enables font auto-size
redactAnnotation.OverlayText = "Classified"
redactAnnotation.TextJustification = PdfTextJustification.Centered
redactAnnotation.RepeatText = False
End If
Next word
' Save the document with the redaction annotation
' and send it for review
pdfProcessor.SaveDocument("output_to_review.pdf")
See Also