PdfImageExtractorTool Class
Visual tool that allows to select and extract images on PDF page.
This example shows how to highlight focused image in PDF document loaded into image viewer.
Public Partial Class FormWithPdfImageExtractorTool
Inherits System.Windows.Forms.Form
'...
Private _imageViewer As Vintasoft.Imaging.UI.ImageViewer
Private _imageExtractorTool As Vintasoft.Imaging.Pdf.UI.PdfImageExtractorTool
'...
Public Sub New()
'...
' create an instance of the PdfImageExtractorTool
_imageExtractorTool = New Vintasoft.Imaging.Pdf.UI.PdfImageExtractorTool()
' set a pen and brush for image selection
_imageExtractorTool.SelectionBrush = New System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(32, System.Drawing.Color.Blue))
_imageExtractorTool.SelectionPen = System.Drawing.Pens.Red
' subscribe to image extractor events
AddHandler _imageExtractorTool.ImageMouseEnter, New System.EventHandler(Of Vintasoft.Imaging.Pdf.UI.PdfImageExtractorEventArgs)(AddressOf _pdfImageExtractorTool_ImageMouseEnter)
AddHandler _imageExtractorTool.ImageMouseLeave, New System.EventHandler(Of Vintasoft.Imaging.Pdf.UI.PdfImageExtractorEventArgs)(AddressOf _pdfImageExtractorTool_ImageMouseLeave)
' set the image extractor tool as current tool
_imageViewer.VisualTool = _imageExtractorTool
End Sub
' Occurs when the mouse pointer enters the image on PDF page.
Private Sub _pdfImageExtractorTool_ImageMouseEnter(sender As Object, e As Vintasoft.Imaging.Pdf.UI.PdfImageExtractorEventArgs)
' set the focused image as selected image
_imageExtractorTool.SelectedImage = e.ContentImage
End Sub
' Occurs when the mouse pointer leaves the image on PDF page.
Private Sub _pdfImageExtractorTool_ImageMouseLeave(sender As Object, e As Vintasoft.Imaging.Pdf.UI.PdfImageExtractorEventArgs)
' remove selected image from image extractor tool
_imageExtractorTool.SelectedImage = Nothing
End Sub
End Class
public partial class FormWithPdfImageExtractorTool : System.Windows.Forms.Form
{
//...
Vintasoft.Imaging.UI.ImageViewer _imageViewer;
Vintasoft.Imaging.Pdf.UI.PdfImageExtractorTool _imageExtractorTool;
//...
public FormWithPdfImageExtractorTool()
{
//...
// create an instance of the PdfImageExtractorTool
_imageExtractorTool = new Vintasoft.Imaging.Pdf.UI.PdfImageExtractorTool();
// set a pen and brush for image selection
_imageExtractorTool.SelectionBrush =
new System.Drawing.SolidBrush(
System.Drawing.Color.FromArgb(32, System.Drawing.Color.Blue));
_imageExtractorTool.SelectionPen = System.Drawing.Pens.Red;
// subscribe to image extractor events
_imageExtractorTool.ImageMouseEnter +=
new System.EventHandler<Vintasoft.Imaging.Pdf.UI.PdfImageExtractorEventArgs>(_pdfImageExtractorTool_ImageMouseEnter);
_imageExtractorTool.ImageMouseLeave +=
new System.EventHandler<Vintasoft.Imaging.Pdf.UI.PdfImageExtractorEventArgs>(_pdfImageExtractorTool_ImageMouseLeave);
// set the image extractor tool as current tool
_imageViewer.VisualTool = _imageExtractorTool;
}
// Occurs when the mouse pointer enters the image on PDF page.
void _pdfImageExtractorTool_ImageMouseEnter(object sender, Vintasoft.Imaging.Pdf.UI.PdfImageExtractorEventArgs e)
{
// set the focused image as selected image
_imageExtractorTool.SelectedImage = e.ContentImage;
}
// Occurs when the mouse pointer leaves the image on PDF page.
void _pdfImageExtractorTool_ImageMouseLeave(object sender, Vintasoft.Imaging.Pdf.UI.PdfImageExtractorEventArgs e)
{
// remove selected image from image extractor tool
_imageExtractorTool.SelectedImage = null;
}
}
Target Platforms: .NET 7; .NET 6; .NET 5; .NET Core 3.1; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5