Skip to main content
All docs
V25.1
  • 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.1.Core.dll

    NuGet Package: DevExpress.Pdf.Core

    Declaration

    public PdfRedactAnnotationFacade AddRedactAnnotation(
        PdfOrientedRectangle rectangle,
        bool usePageCoordinateSystem = true
    )

    Parameters

    Name Type Description
    rectangle PdfOrientedRectangle

    A page rectangle where the redaction annotation should be located.

    Optional Parameters

    Name Type Default Description
    usePageCoordinateSystem Boolean True

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

    Returns

    Type Description
    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:

    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");
    
    See Also