Back to Devexpress

PdfPageFacade.AddRedactAnnotation(PdfOrientedRectangle, Boolean) Method

officefileapi-devexpress-dot-pdf-dot-pdfpagefacade-dot-addredactannotation-x28-devexpress-dot-pdf-dot-pdforientedrectangle-system-dot-boolean-x29.md

latest4.5 KB
Original Source

PdfPageFacade.AddRedactAnnotation(PdfOrientedRectangle, Boolean) Method

Creates a redaction annotation in the specified rectangle. 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

Declaration

csharp
public PdfRedactAnnotationFacade AddRedactAnnotation(
    PdfOrientedRectangle rectangle,
    bool usePageCoordinateSystem = true
)
vb
Public Function AddRedactAnnotation(
    rectangle As PdfOrientedRectangle,
    usePageCoordinateSystem As Boolean = True
) As PdfRedactAnnotationFacade

Parameters

NameTypeDescription
rectanglePdfOrientedRectangle

A page rectangle where the redaction annotation should be located.

|

Optional Parameters

NameTypeDefaultDescription
usePageCoordinateSystemBooleanTrue

true to use the page coordinate system; otherwise, false.

|

Returns

TypeDescription
PdfRedactAnnotationFacade

An object that contains redaction annotation properties.

|

Remarks

Example: Create a Redaction Annotation on a Search Result

The following code snippet searches for a specific word and creates a redaction annotation at its location:

csharp
using DevExpress.Pdf;

PdfDocumentProcessor pdfProcessor = new PdfDocumentProcessor();
pdfProcessor.LoadDocument("Demo.pdf");

PdfDocumentFacade documentFacade = pdfProcessor.DocumentFacade;
PdfTextSearchResults results = pdfProcessor.FindText("Anders");

// 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[0]);
    redactAnnotation.Author = "Jane Doe";
    // Set up the redaction annotation appearance
    redactAnnotation.FillColor = new PdfRGBColor(0, 0, 0);
    redactAnnotation.FontColor = new PdfRGBColor(1, 1, 1);
    redactAnnotation.FontName = "Calibri";
    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");
vb
Imports DevExpress.Pdf

Private pdfProcessor As New PdfDocumentProcessor()
pdfProcessor.LoadDocument("Demo.pdf")

Dim documentFacade As PdfDocumentFacade = pdfProcessor.DocumentFacade
Dim results As PdfTextSearchResults = pdfProcessor.FindText("Anders")

' 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(0))
  redactAnnotation.Author = "Jane Doe"
  ' Set up the redaction annotation appearance
  redactAnnotation.FillColor = New PdfRGBColor(0, 0, 0)
  redactAnnotation.FontColor = New PdfRGBColor(1, 1, 1)
  redactAnnotation.FontName = "Calibri"
  redactAnnotation.FontSize = 0 ' Enables font auto-size
  redactAnnotation.OverlayText = "Classified"
  redactAnnotation.TextJustification = PdfTextJustification.Centered
  redactAnnotation.RepeatText = False
End If
' Save the document with the redaction annotation and send it for review
pdfProcessor.SaveDocument("output_to_review.pdf")

See Also

PdfPageFacade Class

PdfPageFacade Members

DevExpress.Pdf Namespace