VintaSoft Imaging .NET SDK v8.7
Vintasoft.Imaging.Pdf.UI Namespace / PdfTextSelectionTool Class
Members Example



In This Topic
    PdfTextSelectionTool Class
    In This Topic
    Visual tool that allows to search and select text on PDF page.
    Object Model
    PdfTextSelectionTool ClassIObjectClipboard InterfaceCopyItemUIAction ClassPdfPage ClassDeselectAllItemsUIAction ClassImageViewer ClassSelectAllItemsUIAction ClassPdfTextRegion ClassPdfTextRegionFormatter Class
    Syntax
    'Declaration
     
    Public Class PdfTextSelectionTool 
       Inherits PdfVisualTool
       Implements Vintasoft.Imaging.UIActions.ISupportUIActions 
    public class PdfTextSelectionTool : PdfVisualTool, Vintasoft.Imaging.UIActions.ISupportUIActions  
    public __gc class PdfTextSelectionTool : public PdfVisualTool, Vintasoft.Imaging.UIActions.ISupportUIActions  
    public ref class PdfTextSelectionTool : public PdfVisualTool, Vintasoft.Imaging.UIActions.ISupportUIActions  
    Example
    This example shows how to search text in PDF document loaded into image viewer.
    Public Partial Class FormWithPdfTextSelectionTool
    	Inherits System.Windows.Forms.Form
    	'...
    	Private _imageViewer As Vintasoft.Imaging.UI.ImageViewer = Nothing
    	Private _textSelectionTool As Vintasoft.Imaging.Pdf.UI.PdfTextSelectionTool = Nothing
                
    	'...
    	Public Sub New()
    		'...
    		' creates the PdfTextSelectionTool instance
    		_textSelectionTool = New Vintasoft.Imaging.Pdf.UI.PdfTextSelectionTool(New System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(56, System.Drawing.Color.Blue)))
    		' subscribe to text selection tool events
    		AddHandler _textSelectionTool.SelectionChanged, New System.EventHandler(AddressOf _pdfViewerTool_SelectionChanged)
    		' sets the PDF text selection tool as current tool
    		_imageViewer.VisualTool = _textSelectionTool
    	End Sub
                
    	'  Occurs when the _viewerTool.Selection is changed.
    	Private Sub _pdfViewerTool_SelectionChanged(sender As Object, e As System.EventArgs)
    		If _textSelectionTool.SelectedRegion IsNot Nothing Then
    			' show selected text
    			System.Windows.Forms.MessageBox.Show(_textSelectionTool.SelectedRegion.TextContent)
    		End If
    	End Sub
    End Class
    public partial class FormWithPdfTextSelectionTool : System.Windows.Forms.Form
    {
        //...
        Vintasoft.Imaging.UI.ImageViewer _imageViewer = null;
        Vintasoft.Imaging.Pdf.UI.PdfTextSelectionTool _textSelectionTool = null;
                
        //...
        public FormWithPdfTextSelectionTool()
        {
            //...
            // creates the PdfTextSelectionTool instance
            _textSelectionTool = new Vintasoft.Imaging.Pdf.UI.PdfTextSelectionTool(
                new System.Drawing.SolidBrush(
                    System.Drawing.Color.FromArgb(56, System.Drawing.Color.Blue)));
            // subscribe to text selection tool events
            _textSelectionTool.SelectionChanged += new System.EventHandler(_pdfViewerTool_SelectionChanged);
            // sets the PDF text selection tool as current tool
            _imageViewer.VisualTool = _textSelectionTool;
        }
                
        //  Occurs when the _viewerTool.Selection is changed.
        private void _pdfViewerTool_SelectionChanged(object sender, System.EventArgs e)
        {
            if (_textSelectionTool.SelectedRegion != null)
                // show selected text
                System.Windows.Forms.MessageBox.Show(_textSelectionTool.SelectedRegion.TextContent);
        }    
    }
    Inheritance Hierarchy

    System.Object
       Vintasoft.Imaging.UI.VisualTools.VisualTool
          Vintasoft.Imaging.Pdf.UI.PdfVisualTool
             Vintasoft.Imaging.Pdf.UI.PdfTextSelectionTool

    Requirements

    Target Platforms: Windows 10, Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also