Allows to set properties to extract only specific images from PDF

Namespace:  SautinSoft
Assembly:  SautinSoft.PdfFocus (in SautinSoft.PdfFocus.dll) Version: 6.6.9.7 (6.6.9.7)

Syntax

      
 C#  Visual Basic 
public class CImageExtractionOptions
Public Class CImageExtractionOptions

Members

      
 All Members  Properties  
 Public

 Protected
 Instance

 Static 
 Declared

 Inherited
 XNA Framework Only 

 .NET Compact Framework Only 

 MemberDescription
MaxSize
Specify maximal size of exracted images in pixels.
MinSize
Specify minimal size of exracted images in pixels.
RasterizeComplexGraphics
Additionally convert all vector graphics to raster images or not.

Examples

CopyExtract all images with width and height more than 200px in C#
using System;
using System.IO;
using System.Collections.Generic;
using SautinSoft;

namespace Sample
{
    class Sample
    {
        static void Main(string[] args)
        {
            // Extract all images with width and height more than 200px
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();

            // This property is necessary only for registered version
            // f.Serial = "XXXXXXXXXXX";
            string pdfFile = @"..\..\..\..\..\simple text.pdf";
            string imageDir = Path.GetDirectoryName(pdfFile);

            List<PdfFocus.PdfImage> pdfImages = null;

            f.OpenPdf(pdfFile);

            if (f.PageCount > 0)
            {
                // Specify to extract only images which have width and height
                // more than 200px
                f.ImageExtractionOptions.MinSize = new System.Drawing.Size(200, 200);

                pdfImages = f.ExtractImages();                

                // Show all extracted images.
                if (pdfImages != null && pdfImages.Count > 0)
                {

                    for (int i = 0; i < pdfImages.Count; i++)
                    {
                        string imageFile = Path.Combine(imageDir, String.Format("img{0}.png", i + 1));
                        pdfImages[i].Picture.Save(imageFile);
                        System.Diagnostics.Process.Start(imageFile);
                    }
                }
            }
        }
    }
}
CopyExtract all images with width and height more than 200px in VB.Net
Imports System.IO
Imports System.Drawing.Imaging
Imports System.Collections.Generic
Imports SautinSoft

Module Sample

    Sub Main()
        ' Extract all images with width and height more than 200px
        Dim f As New SautinSoft.PdfFocus()

        ' This property is necessary only for registered version
        ' f.Serial = "XXXXXXXXXXX";
        Dim pdfFile As String = "..\..\..\..\simple text.pdf"
        Dim imageDir As String = Path.GetDirectoryName(pdfFile)

        Dim pdfImages As List(Of PdfFocus.PdfImage) = Nothing

        f.OpenPdf(pdfFile)

        If f.PageCount > 0 Then
            ' Specify to extract only images which have width and height
            ' more than 200px
            f.ImageExtractionOptions.MinSize = New System.Drawing.Size(200, 200)

            pdfImages = f.ExtractImages()

            ' Show all extracted images.
            If pdfImages IsNot Nothing AndAlso pdfImages.Count > 0 Then

                For i As Integer = 0 To pdfImages.Count - 1
                    Dim imageFile As String = Path.Combine(imageDir, String.Format("img{0}.png", i + 1))
                    pdfImages(i).Picture.Save(imageFile)
                    System.Diagnostics.Process.Start(imageFile)
                Next i
            End If
        End If
    End Sub
End Module

Inheritance Hierarchy

System..::.Object
  SautinSoft..::.PdfFocus..::.CImageExtractionOptions

See Also