VintaSoft Imaging .NET SDK v8.6
Vintasoft.Imaging.Pdf.UI Namespace / PdfRemoveContentTool Class / RedactionMarkAppearance Property
Example



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
    'Declaration
     
    Public Property RedactionMarkAppearance As GraphicsFigure
    public GraphicsFigure RedactionMarkAppearance {get; set;}
    public: __property GraphicsFigure* get_RedactionMarkAppearance();
    public: __property void set_RedactionMarkAppearance( 
       GraphicsFigure* value
    );
    public:
    property GraphicsFigure^ RedactionMarkAppearance {
       GraphicsFigure^ get();
       void set (    GraphicsFigure^ value);
    }

    Property Value

    Default value is null.
    Example
    This example 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.UI.RedactionMarkType.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.UI.RedactionMarkType.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: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also