VintaSoft Imaging .NET SDK 14.0: Документация для .NET разработчика
Vintasoft.Imaging.Pdf.Wpf.UI Namespace / WpfPdfTextMarkupTool Class
    Класс WpfPdfTextMarkupTool
    В этом разделе
    Визуальный инструмент, который позволяет размечать (выделять, зачеркивать, подчеркивать, волнистой линией) текст с помощью PdfTextMarkupAnnotation на PDF странице.
    Объектная модель
    PdfTextMarkupAnnotationAppearanceGenerator WpfTextSelectionTool WpfImageViewer WpfPdfTextMarkupTool
    Синтаксис
    'Declaration
    
    <DesignTimeVisibleAttribute("Visible = False")>
    <ToolboxItemAttribute("ToolboxItemType = null", "ToolboxItemTypeName = ")>
    <DefaultPropertyAttribute("Content")>
    <ContentPropertyAttribute("Content")>
    <LocalizabilityAttribute(None)>
    <StyleTypedPropertyAttribute("Property = FocusVisualStyle", "StyleTargetType = System.Windows.Controls.Control")>
    <XmlLangPropertyAttribute("Name = Language")>
    <UsableDuringInitializationAttribute("Usable = True")>
    <RuntimeNamePropertyAttribute("Name = Name")>
    <UidPropertyAttribute()>
    <TypeDescriptionProviderAttribute("TypeName = MS.Internal.ComponentModel.DependencyObjectProvider")>
    <NameScopePropertyAttribute("Name = NameScope", "Type = System.Windows.NameScope")>
    Public Class WpfPdfTextMarkupTool
       Inherits Vintasoft.Imaging.Wpf.UI.VisualTools.WpfVisualTool
    
    
    [DesignTimeVisible("Visible = False")]
    [ToolboxItem("ToolboxItemType = null", "ToolboxItemTypeName = ")]
    [DefaultProperty("Content")]
    [ContentProperty("Content")]
    [Localizability(None)]
    [StyleTypedProperty("Property = FocusVisualStyle", "StyleTargetType = System.Windows.Controls.Control")]
    [XmlLangProperty("Name = Language")]
    [UsableDuringInitialization("Usable = True")]
    [RuntimeNameProperty("Name = Name")]
    [UidProperty()]
    [TypeDescriptionProvider("TypeName = MS.Internal.ComponentModel.DependencyObjectProvider")]
    [NameScopeProperty("Name = NameScope", "Type = System.Windows.NameScope")]
    public class WpfPdfTextMarkupTool : Vintasoft.Imaging.Wpf.UI.VisualTools.WpfVisualTool
    
    
    [DesignTimeVisible("Visible = False")]
    [ToolboxItem("ToolboxItemType = null", "ToolboxItemTypeName = ")]
    [DefaultProperty("Content")]
    [ContentProperty("Content")]
    [Localizability(None)]
    [StyleTypedProperty("Property = FocusVisualStyle", "StyleTargetType = System.Windows.Controls.Control")]
    [XmlLangProperty("Name = Language")]
    [UsableDuringInitialization("Usable = True")]
    [RuntimeNameProperty("Name = Name")]
    [UidProperty()]
    [TypeDescriptionProvider("TypeName = MS.Internal.ComponentModel.DependencyObjectProvider")]
    [NameScopeProperty("Name = NameScope", "Type = System.Windows.NameScope")]
    public __gc class WpfPdfTextMarkupTool : public Vintasoft.Imaging.Wpf.UI.VisualTools.WpfVisualTool*
    
    
    [DesignTimeVisible("Visible = False")]
    [ToolboxItem("ToolboxItemType = null", "ToolboxItemTypeName = ")]
    [DefaultProperty("Content")]
    [ContentProperty("Content")]
    [Localizability(None)]
    [StyleTypedProperty("Property = FocusVisualStyle", "StyleTargetType = System.Windows.Controls.Control")]
    [XmlLangProperty("Name = Language")]
    [UsableDuringInitialization("Usable = True")]
    [RuntimeNameProperty("Name = Name")]
    [UidProperty()]
    [TypeDescriptionProvider("TypeName = MS.Internal.ComponentModel.DependencyObjectProvider")]
    [NameScopeProperty("Name = NameScope", "Type = System.Windows.NameScope")]
    public ref class WpfPdfTextMarkupTool : public Vintasoft.Imaging.Wpf.UI.VisualTools.WpfVisualTool^
    
    
    Ремарки

    Для этого визуального инструмента требуется WpfTextSelectionTool, т.е. просмотрщик изображений должно использовать WpfCompositeVisualTool, который содержит WpfTextSelectionTool и WpfPdfTextMarkupTool.

    Пример

    Вот C#/VB.NET код, который демонстрирует, как использовать инструмент разметки текста PDF для выделения текста на PDF странице.

    
    ''' <summary>
    ''' Sets the WpfPdfTextMarkupTool as current tool of specified image viewer.
    ''' </summary>
    ''' <param name="imageViewer">The image viewer.</param>
    Public Shared Sub SetPdfTextMarkupTool(imageViewer As Vintasoft.Imaging.Wpf.UI.WpfImageViewer)
        ' create an instance of the PdfTextMarkupTool class
        Dim textMarkupTool As New Vintasoft.Imaging.Pdf.Wpf.UI.WpfPdfTextMarkupTool()
    
        ' set text markup mode to "Highlight"
        textMarkupTool.MarkupMode = Vintasoft.Imaging.Pdf.Wpf.UI.WpfPdfTextMarkupToolMode.Highlight
    
        ' set color of markup annotation to "Orange"
        textMarkupTool.HighlightColor = System.Windows.Media.Colors.Orange
    
        ' subscribe to the MarkupAnnotationCreated event
        AddHandler textMarkupTool.MarkupAnnotationCreated, AddressOf TextMarkupTool_MarkupAnnotationCreated
    
        ' get TextSelectionTool from image viewer
        Dim textSelectionTool As Vintasoft.Imaging.Wpf.UI.VisualTools.WpfTextSelectionTool = GetTextSelectionTool(imageViewer)
    
        ' set the PdfTextMarkupTool+TextSelectionTool as visual tool of the image viewer
        imageViewer.VisualTool = New Vintasoft.Imaging.Wpf.UI.VisualTools.WpfCompositeVisualTool(textMarkupTool, textSelectionTool)
    End Sub
    
    ''' <summary>
    ''' Returns the text selection tool for specified image viewer.
    ''' </summary>
    ''' <param name="imageViewer">The image viewer.</param>
    ''' <returns>The text selection tool.</returns>
    Private Shared Function GetTextSelectionTool(imageViewer As Vintasoft.Imaging.Wpf.UI.WpfImageViewer) As Vintasoft.Imaging.Wpf.UI.VisualTools.WpfTextSelectionTool
        ' search a TextSelectionTool in visual tools of the image viewer
        Dim textSelectionTool As Vintasoft.Imaging.Wpf.UI.VisualTools.WpfTextSelectionTool = Vintasoft.Imaging.Wpf.UI.VisualTools.WpfVisualTool.FindVisualTool(Of Vintasoft.Imaging.Wpf.UI.VisualTools.WpfTextSelectionTool)(imageViewer.VisualTool)
        If textSelectionTool IsNot Nothing Then
            Return textSelectionTool
        End If
    
        ' create an instance of text selection tool
        Return New Vintasoft.Imaging.Wpf.UI.VisualTools.WpfTextSelectionTool()
    End Function
    
    ''' <summary>
    ''' Handles the MarkupAnnotationCreated event of the PdfTextMarkupTool visual tool.
    ''' </summary>
    Private Shared Sub TextMarkupTool_MarkupAnnotationCreated(sender As Object, e As Vintasoft.Imaging.Pdf.Wpf.UI.WpfPdfMarkupAnnotationEventArgs)
        ' set user name as title of text markup annotation
        e.MarkupAnnotation.Title = System.Environment.UserName
    End Sub
    
    
    
    /// <summary>
    /// Sets the WpfPdfTextMarkupTool as current tool of specified image viewer.
    /// </summary>
    /// <param name="imageViewer">The image viewer.</param>
    public static void SetPdfTextMarkupTool(Vintasoft.Imaging.Wpf.UI.WpfImageViewer imageViewer)
    {
        // create an instance of the PdfTextMarkupTool class
        Vintasoft.Imaging.Pdf.Wpf.UI.WpfPdfTextMarkupTool textMarkupTool = new Vintasoft.Imaging.Pdf.Wpf.UI.WpfPdfTextMarkupTool();
    
        // set text markup mode to "Highlight"
        textMarkupTool.MarkupMode = Vintasoft.Imaging.Pdf.Wpf.UI.WpfPdfTextMarkupToolMode.Highlight;
    
        // set color of markup annotation to "Orange"
        textMarkupTool.HighlightColor = System.Windows.Media.Colors.Orange;
    
        // subscribe to the MarkupAnnotationCreated event
        textMarkupTool.MarkupAnnotationCreated += TextMarkupTool_MarkupAnnotationCreated;
    
        // get TextSelectionTool from image viewer
        Vintasoft.Imaging.Wpf.UI.VisualTools.WpfTextSelectionTool textSelectionTool = GetTextSelectionTool(imageViewer);
    
        // set the PdfTextMarkupTool+TextSelectionTool as visual tool of the image viewer
        imageViewer.VisualTool = new Vintasoft.Imaging.Wpf.UI.VisualTools.WpfCompositeVisualTool(textMarkupTool, textSelectionTool);
    }
    
    /// <summary>
    /// Returns the text selection tool for specified image viewer.
    /// </summary>
    /// <param name="imageViewer">The image viewer.</param>
    /// <returns>The text selection tool.</returns>
    private static Vintasoft.Imaging.Wpf.UI.VisualTools.WpfTextSelectionTool GetTextSelectionTool(Vintasoft.Imaging.Wpf.UI.WpfImageViewer imageViewer)
    {
        // search a TextSelectionTool in visual tools of the image viewer
        Vintasoft.Imaging.Wpf.UI.VisualTools.WpfTextSelectionTool textSelectionTool =
            Vintasoft.Imaging.Wpf.UI.VisualTools.WpfVisualTool.FindVisualTool<Vintasoft.Imaging.Wpf.UI.VisualTools.WpfTextSelectionTool>(imageViewer.VisualTool);
        if (textSelectionTool != null)
            return textSelectionTool;
    
        // create an instance of text selection tool
        return new Vintasoft.Imaging.Wpf.UI.VisualTools.WpfTextSelectionTool();
    }
    
    /// <summary>
    /// Handles the MarkupAnnotationCreated event of the PdfTextMarkupTool visual tool.
    /// </summary>
    private static void TextMarkupTool_MarkupAnnotationCreated(object sender, Vintasoft.Imaging.Pdf.Wpf.UI.WpfPdfMarkupAnnotationEventArgs e)
    {
        // set user name as title of text markup annotation
        e.MarkupAnnotation.Title = System.Environment.UserName;
    }
    
    

    Иерархия наследования

    System.Object
       System.Windows.Threading.DispatcherObject
          System.Windows.DependencyObject
             System.Windows.Media.Visual
                System.Windows.UIElement
                   System.Windows.FrameworkElement
                      System.Windows.Controls.Control
                         System.Windows.Controls.ContentControl
                            Vintasoft.Imaging.Wpf.UI.VisualTools.WpfVisualTool
                               Vintasoft.Imaging.Pdf.Wpf.UI.WpfPdfTextMarkupTool

    Требования

    Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    Смотрите также