VintaSoft Imaging .NET SDK v8.7
Vintasoft.Imaging.Pdf.Wpf.UI Namespace / WpfPdfRemoveContentTool Class / RedactionMarkAppearance Property
Example



In This Topic
    RedactionMarkAppearance Property (WpfPdfRemoveContentTool)
    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 redaction mark appearance and apply redaction marks programmatically:
    ''' <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.Wpf.UI.WpfImageViewer)
    	' if WPF image viewer does not have image
    	If viewer.Image Is Nothing Then
    		Throw New System.InvalidOperationException()
    	End If
                
    	' if WPF 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 WpfPdfRemoveContentTool as current tool of image viewer
    	Dim removeContentTool As New Vintasoft.Imaging.Pdf.Wpf.UI.WpfPdfRemoveContentTool()
    	viewer.VisualTool = removeContentTool
                
    	' create the redaction mark
    	Dim mark As New Vintasoft.Imaging.Pdf.Wpf.UI.WpfRedactionMark(viewer.Image)
    	' specify that redaction mark must remove all PDF content
    	mark.MarkType = Vintasoft.Imaging.Pdf.Wpf.UI.WpfRedactionMarkType.RemoveAll
    	' calculate and specify the redaction mark rectangle
    	Dim rect As System.Windows.Rect = Vintasoft.Imaging.Wpf.WpfObjectConverter.CreateWindowsRect(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.Wpf.UI.WpfImageViewer viewer)
    {
        // if WPF image viewer does not have image
        if (viewer.Image == null)
            throw new System.InvalidOperationException();
                
        // if WPF 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 WpfPdfRemoveContentTool as current tool of image viewer
        Vintasoft.Imaging.Pdf.Wpf.UI.WpfPdfRemoveContentTool removeContentTool =
            new Vintasoft.Imaging.Pdf.Wpf.UI.WpfPdfRemoveContentTool();
        viewer.VisualTool = removeContentTool;
                
        // create the redaction mark
        Vintasoft.Imaging.Pdf.Wpf.UI.WpfRedactionMark mark =
            new Vintasoft.Imaging.Pdf.Wpf.UI.WpfRedactionMark(viewer.Image);
        // specify that redaction mark must remove all PDF content
        mark.MarkType = Vintasoft.Imaging.Pdf.Wpf.UI.WpfRedactionMarkType.RemoveAll;
        // calculate and specify the redaction mark rectangle
        System.Windows.Rect rect =
            Vintasoft.Imaging.Wpf.WpfObjectConverter.CreateWindowsRect(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