Saves all pages of PDF document to Image file(s)

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

Syntax

      
 C#  Visual Basic 
public int ToImage(
	string outFolder,
	string templateFileName
)
Public Function ToImage ( _
	outFolder As String, _
	templateFileName As String _
) As Integer

Parameters

outFolder
String
Full path to existing folder where to save images
templateFileName
String
Template file name for image files

Return Value

0 - saving successfully
2 - can't create output file, check the output path
3 - saving failed, email to support@sautinsoft.com

Remarks

To start the process, please download the most fresh version of PDF Focus .Net.

Before converting you may set various image properties using the property ImageOptions. For example, set:
  • Dpi - image resolution in dots per inch. Default value: 120
  • ImageFormat - format for produced images as standard ImageFormat. Default value: Png
  • ColorDepth - color depth or bit depth is the number of bits used to represent the color of a single pixel. Default value: 24 bit RGB


Examples

CopyConvert PDF files to 300-dpi TIFF files in C#
using System;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;

namespace Sample
{
    class Sample
    {
        static void Main(string[] args)
        {
            //Convert PDF files to 300-dpi TIFF files
            SautinSoft.PdfFocus f = new SautinSoft.PdfFocus();
            //this property is necessary only for registered version
            //f.Serial = "XXXXXXXXXXX";

            string[] pdfFiles = Directory.GetFiles(@"..\..\..\..\..\", "*.pdf");
            string folderWithTiffs = @"..\..\..\..\..\";

            foreach (string pdffile in pdfFiles)
            {
                f.OpenPdf(pdffile);

                if (f.PageCount > 0)
                {
                    //Set image format: TIFF, 300 dpi
                    f.ImageOptions.Dpi = 300;
                    f.ImageOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Tiff;

                    //Save all pages to tiff files with 300 dpi
                    f.ToImage(folderWithTiffs, Path.GetFileNameWithoutExtension(pdffile));
                }
                f.ClosePdf();
            }
            //Show folder with tiffs
            System.Diagnostics.Process.Start(folderWithTiffs);
        }
    }
}
CopyConvert PDF files to 300-dpi TIFF files in VB.Net
Imports System.IO
Imports System.Drawing.Imaging
Imports System.Collections.Generic
Imports SautinSoft

Module Sample

    Sub Main()
        'Convert PDF files to 300-dpi TIFF files
        Dim f As New SautinSoft.PdfFocus()
        'this property is necessary only for registered version
        'f.Serial = "XXXXXXXXXXX";


        Dim pdfFiles() As String = Directory.GetFiles("..\..\..\..\", "*.pdf")
        Dim folderWithTiffs As String = "..\..\..\..\"

        For Each pdffile As String In pdfFiles
            f.OpenPdf(pdffile)

            If f.PageCount > 0 Then
                'Set image format: TIFF, 300 dpi
                f.ImageOptions.Dpi = 300
                f.ImageOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Tiff

                'Save all pages to tiff files with 300 dpi
                f.ToImage(folderWithTiffs, Path.GetFileNameWithoutExtension(pdffile))
            End If
            f.ClosePdf()
        Next pdffile
        'Show folder with tiffs
        System.Diagnostics.Process.Start(folderWithTiffs)
    End Sub
End Module

See Also