VintaSoft Imaging .NET SDK 15.1: Documentation for .NET developer
Vintasoft.Imaging.Pdf.UI Namespace / PdfRemoveContentTool Class / RedactionMarkAppearance Property
Syntax Example Requirements SeeAlso
In This Topic
RedactionMarkAppearance Property (PdfRemoveContentTool)
In This Topic
Gets or sets the redaction mark appearance that will be drawn on PDF page after redaction mark is applied.
Syntax
Example

This C#/VB.NET code shows how to define the redaction mark appearance and programmatically apply the redaction marks to a PDF document:


''' <summary>
''' Creates the redaction mark with custom appearance and applies the redaction mark
''' to PDF page.
''' </summary>
Public Shared Sub TestRedactionMarkAppearance(viewer As Vintasoft.Imaging.UI.ImageViewer)
    ' if image viewer does not have image
    If viewer.Image Is Nothing Then
        Throw New System.InvalidOperationException()
    End If

    ' if image viewer contains not PDF page
    Dim page As Vintasoft.Imaging.Pdf.Tree.PdfPage = Vintasoft.Imaging.Pdf.PdfDocumentController.GetPageAssociatedWithImage(viewer.Image)
    If page Is Nothing Then
        Throw New System.InvalidOperationException()
    End If

    ' create and set PdfRemoveContentTool as current tool of image viewer
    Dim removeContentTool As New Vintasoft.Imaging.Pdf.UI.PdfRemoveContentTool()
    viewer.VisualTool = removeContentTool

    ' create the redaction mark
    Dim mark As New Vintasoft.Imaging.Pdf.UI.RedactionMark(viewer.Image)
    ' specify that redaction mark must remove all PDF content
    mark.MarkType = Vintasoft.Imaging.Pdf.PdfRedactionMarkType.RemoveAll
    ' calculate and specify the redaction mark rectangle
    Dim rect As System.Drawing.RectangleF = page.MediaBox
    rect.Inflate(-rect.Width / 4, -rect.Height / 4)
    mark.SelectedRect = rect

    ' add the redaction mark to a list of redaction marks of visual tool
    removeContentTool.Add(mark)

    ' create redaction mark appearance
    Dim textBox As New Vintasoft.Imaging.Pdf.Drawing.GraphicsFigures.TextBoxFigure(New Vintasoft.Imaging.Pdf.Drawing.PdfBrush(System.Drawing.Color.Red), "TOP SECRET", page.Document.FontManager.GetStandardFont(Vintasoft.Imaging.Pdf.Tree.Fonts.PdfStandardFontType.Helvetica), 0)
    textBox.TextAlignment = Vintasoft.Imaging.Pdf.Drawing.PdfContentAlignment.Center
    textBox.Brush = New Vintasoft.Imaging.Pdf.Drawing.PdfBrush(System.Drawing.Color.Black)
    textBox.AutoFontSize = True
    removeContentTool.RedactionMarkAppearance = textBox

    ' apply redaction marks
    removeContentTool.ApplyRedactionMarks()
End Sub


/// <summary>
/// Creates the redaction mark with custom appearance and applies the redaction mark
/// to PDF page.
/// </summary>
public static void TestRedactionMarkAppearance(Vintasoft.Imaging.UI.ImageViewer viewer)
{
    // if image viewer does not have image
    if (viewer.Image == null)
        throw new System.InvalidOperationException();

    // if image viewer contains not PDF page
    Vintasoft.Imaging.Pdf.Tree.PdfPage page =
        Vintasoft.Imaging.Pdf.PdfDocumentController.GetPageAssociatedWithImage(viewer.Image);
    if (page == null)
        throw new System.InvalidOperationException();

    // create and set PdfRemoveContentTool as current tool of image viewer
    Vintasoft.Imaging.Pdf.UI.PdfRemoveContentTool removeContentTool =
        new Vintasoft.Imaging.Pdf.UI.PdfRemoveContentTool();
    viewer.VisualTool = removeContentTool;

    // create the redaction mark
    Vintasoft.Imaging.Pdf.UI.RedactionMark mark =
        new Vintasoft.Imaging.Pdf.UI.RedactionMark(viewer.Image);
    // specify that redaction mark must remove all PDF content
    mark.MarkType = Vintasoft.Imaging.Pdf.PdfRedactionMarkType.RemoveAll;
    // calculate and specify the redaction mark rectangle
    System.Drawing.RectangleF rect = page.MediaBox;
    rect.Inflate(-rect.Width / 4, -rect.Height / 4);
    mark.SelectedRect = rect;

    // add the redaction mark to a list of redaction marks of visual tool
    removeContentTool.Add(mark);

    // create redaction mark appearance
    Vintasoft.Imaging.Pdf.Drawing.GraphicsFigures.TextBoxFigure textBox =
        new Vintasoft.Imaging.Pdf.Drawing.GraphicsFigures.TextBoxFigure(
            new Vintasoft.Imaging.Pdf.Drawing.PdfBrush(System.Drawing.Color.Red),
            "TOP SECRET",
            page.Document.FontManager.GetStandardFont(Vintasoft.Imaging.Pdf.Tree.Fonts.PdfStandardFontType.Helvetica),
            0);
    textBox.TextAlignment = Vintasoft.Imaging.Pdf.Drawing.PdfContentAlignment.Center;
    textBox.Brush = new Vintasoft.Imaging.Pdf.Drawing.PdfBrush(System.Drawing.Color.Black);
    textBox.AutoFontSize = true;
    removeContentTool.RedactionMarkAppearance = textBox;

    // apply redaction marks
    removeContentTool.ApplyRedactionMarks();
}

Requirements

Target Platforms: .NET 10; .NET 9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

See Also