RedactionMarkAppearance Свойство (WpfPdfRemoveContentTool)
Возвращает или задает внешний вид знака исправления, который будет отображаться на PDF странице после применения знака исправления.
Property Value
Значение по умолчанию - null.
Вот C#/VB.NET код, который демонстрирует, как определить внешний вид метки исправления и применить метку исправления программным способом:
''' <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.PdfRedactionMarkType.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.PdfRedactionMarkType.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();
}
Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5