VintaSoft Imaging .NET SDK 12.3: Documentation for .NET developer
In This Topic
    Codecs: How to convert PDF to TIFF?
    In This Topic
    SDK renders PDF page (draws text, images and graphics on PDF page) when converting PDF document to a TIFF file.

    By default SDK:

    You need override algorithm for searching external fonts if PDF document contains not standard external fonts. This can be done using the FileFontProgramsControllerWithFallbackFont class.
    More info about fonts in PDF document can be found here.

    Here is an example that shows how to convert PDF document with default resolution (96 dpi) to TIFF file using ImageCollection and TiffEncoder classes:
    /// <summary>
    /// Class shows how to convert PDF document to TIFF file using ImageCollection and TiffEncoder classes.
    /// </summary>
    public class ConvertPdfToTiffUsingEncoder
    {
    
        /// <summary>
        /// Converts PDF document to TIFF file using ImageCollection and TiffEncoder classes.
        /// </summary>
        public static void Convert(string pdfFileName, string tiffFileName)
        {
            // create image collection
            using (Vintasoft.Imaging.ImageCollection imageCollection = 
                new Vintasoft.Imaging.ImageCollection())
            {
                // add PDF document to collection
                imageCollection.Add(pdfFileName);
    
                // create TiffEncoder
                using (Vintasoft.Imaging.Codecs.Encoders.TiffEncoder tiffEncoder = 
                    new Vintasoft.Imaging.Codecs.Encoders.TiffEncoder(true))
                {
                    // set TIFF compression to Zip
                    tiffEncoder.Settings.Compression = 
                        Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffCompression.Zip;
    
                    // save images of image collection to TIFF file using TiffEncoder
                    imageCollection.SaveSync(tiffFileName, tiffEncoder);
                }
    
                // dispose images
                imageCollection.ClearAndDisposeItems();
            }
        }
    
    }
    
    ''' <summary>
    ''' Class shows how to convert PDF document to TIFF file using ImageCollection and TiffEncoder classes.
    ''' </summary>
    Public Class ConvertPdfToTiffUsingEncoder
    
        ''' <summary>
        ''' Converts PDF document to TIFF file using ImageCollection and TiffEncoder classes.
        ''' </summary>
        Public Shared Sub Convert(pdfFileName As String, tiffFileName As String)
            ' create image collection
            Using imageCollection As New Vintasoft.Imaging.ImageCollection()
                ' add PDF document to collection
                imageCollection.Add(pdfFileName)
    
                ' create TiffEncoder
                Using tiffEncoder As New Vintasoft.Imaging.Codecs.Encoders.TiffEncoder(True)
                    ' set TIFF compression to Zip
                    tiffEncoder.Settings.Compression = Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffCompression.Zip
    
                    ' save images of image collection to TIFF file using TiffEncoder
                    imageCollection.SaveSync(tiffFileName, tiffEncoder)
                End Using
    
                ' dispose images
                imageCollection.ClearAndDisposeItems()
            End Using
        End Sub
    
    End Class
    
    


    Here is an example that shows how to convert PDF document with specified resolution to TIFF file using ImageCollection and TiffEncoder classes:
    /// <summary>
    /// Class shows how to convert PDF document to TIFF file using ImageCollection and TiffEncoder classes.
    /// PDF document is rendered with specified resolution.
    /// </summary>
    public class ConvertPdfToTiffUsingEncoderWithSpecifiedResolution
    {
    
        /// <summary>
        /// Converts PDF document to TIFF file using ImageCollection and TiffEncoder classes.
        /// PDF document is rendered with specified resolution.
        /// </summary>
        public static void Convert(string pdfFileName, string tiffFileName, float dpi)
        {
            // create image collection
            using (Vintasoft.Imaging.ImageCollection imageCollection = new Vintasoft.Imaging.ImageCollection())
            {
                // add PDF document to collection
                imageCollection.Add(pdfFileName);
    
                // set rendering settings
                imageCollection.SetRenderingSettings(new Vintasoft.Imaging.Codecs.Decoders.RenderingSettings(
                    dpi,
                    dpi,
                    Vintasoft.Imaging.ImageInterpolationMode.HighQualityBilinear,
                    Vintasoft.Imaging.Drawing.DrawingSmoothingMode.AntiAlias));
    
                // create TiffEncoder
                using (Vintasoft.Imaging.Codecs.Encoders.TiffEncoder tiffEncoder = 
                    new Vintasoft.Imaging.Codecs.Encoders.TiffEncoder(true))
                {
                    // set TIFF compression to Zip
                    tiffEncoder.Settings.Compression = 
                        Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffCompression.Zip;
    
                    // save images of image collection to TIFF file using TiffEncoder
                    imageCollection.SaveSync(tiffFileName, tiffEncoder);
                }
    
                // dispose images
                imageCollection.ClearAndDisposeItems();
            }
        }
    }
    
    ''' <summary>
    ''' Class shows how to convert PDF document to TIFF file using ImageCollection and TiffEncoder classes.
    ''' PDF document is rendered with specified resolution.
    ''' </summary>
    Public Class ConvertPdfToTiffUsingEncoderWithSpecifiedResolution
    
        ''' <summary>
        ''' Converts PDF document to TIFF file using ImageCollection and TiffEncoder classes.
        ''' PDF document is rendered with specified resolution.
        ''' </summary>
        Public Shared Sub Convert(pdfFileName As String, tiffFileName As String, dpi As Single)
            ' create image collection
            Using imageCollection As New Vintasoft.Imaging.ImageCollection()
                ' add PDF document to collection
                imageCollection.Add(pdfFileName)
    
                ' set rendering settings
                imageCollection.SetRenderingSettings(New Vintasoft.Imaging.Codecs.Decoders.RenderingSettings(dpi, dpi, Vintasoft.Imaging.ImageInterpolationMode.HighQualityBilinear, Vintasoft.Imaging.Drawing.DrawingSmoothingMode.AntiAlias))
    
                ' create TiffEncoder
                Using tiffEncoder As New Vintasoft.Imaging.Codecs.Encoders.TiffEncoder(True)
                    ' set TIFF compression to Zip
                    tiffEncoder.Settings.Compression = Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffCompression.Zip
    
                    ' save images of image collection to TIFF file using TiffEncoder
                    imageCollection.SaveSync(tiffFileName, tiffEncoder)
                End Using
    
                ' dispose images
                imageCollection.ClearAndDisposeItems()
            End Using
        End Sub
    End Class
    
    


    Here is an example that shows how to convert PDF document with default resolution (96 dpi) to TIFF file using PdfDocument and TiffFile classes:
    /// <summary>
    /// Class shows how to convert PDF document to TIFF file using PdfDocument and TiffFile classes.
    /// </summary>
    public class ConvertPdfToTiffUseImageFile
    {
        /// <summary>
        /// Converts PDF document to TIFF file using PdfDocument and TiffFile classes.
        /// </summary>
        public static void Convert(string pdfFileName, string tiffFileName)
        {
            // open existing PDF document
            using (Vintasoft.Imaging.Pdf.PdfDocument pdfDocument = new Vintasoft.Imaging.Pdf.PdfDocument(pdfFileName))
            {
                // create new TIFF file
                using (Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile tiffFile = 
                    new Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile(tiffFileName, 
                        Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFileFormat.LittleEndian))
                {
                    // set TIFF compression to Zip
                    tiffFile.Pages.EncoderSettings.Compression = 
                        Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffCompression.Zip;
                    // for each PDF page
                    for (int i = 0; i < pdfDocument.Pages.Count; i++)
                    {
                        // render PDF page and add as image to Tiff file
                        tiffFile.Pages.Add(pdfDocument.Pages[i].Render());
                        // save changes to TIFF file
                        tiffFile.SaveChanges();
                    }
                }
            }
        }
    }
    
    ''' <summary>
    ''' Class shows how to convert PDF document to TIFF file using PdfDocument and TiffFile classes.
    ''' </summary>
    Public Class ConvertPdfToTiffUseImageFile
        ''' <summary>
        ''' Converts PDF document to TIFF file using PdfDocument and TiffFile classes.
        ''' </summary>
        Public Shared Sub Convert(pdfFileName As String, tiffFileName As String)
            ' open existing PDF document
            Using pdfDocument As New Vintasoft.Imaging.Pdf.PdfDocument(pdfFileName)
                ' create new TIFF file
                Using tiffFile As New Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile(tiffFileName, Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFileFormat.LittleEndian)
                    ' set TIFF compression to Zip
                    tiffFile.Pages.EncoderSettings.Compression = Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffCompression.Zip
                    ' for each PDF page
                    For i As Integer = 0 To pdfDocument.Pages.Count - 1
                        ' render PDF page and add as image to Tiff file
                        tiffFile.Pages.Add(pdfDocument.Pages(i).Render())
                        ' save changes to TIFF file
                        tiffFile.SaveChanges()
                    Next
                End Using
            End Using
        End Sub
    End Class
    
    


    Here is an example that shows how to convert PDF document with specified resolution to TIFF file using PdfDocument and TiffFile classes:
    /// <summary>
    /// Class shows how to convert PDF document to TIFF file using PdfDocument and TiffFile classes.
    /// PDF document is rendered with specified resolution.
    /// </summary>
    public class ConvertPdfToTiffUseImageFileWithSpecifiedResolution
    {
    
        /// <summary>
        /// Converts PDF document to TIFF file using PdfDocument and TiffFile classes.
        /// PDF document is rendered with specified resolution.
        /// </summary>
        public static void Convert(string pdfFileName, string tiffFileName, float dpi)
        {
            // open existing PDF document
            using (Vintasoft.Imaging.Pdf.PdfDocument pdfDocument = 
                new Vintasoft.Imaging.Pdf.PdfDocument(pdfFileName))
            {
                // set resolution
                pdfDocument.RenderingSettings.Resolution = 
                    new Vintasoft.Imaging.Resolution(dpi, dpi);
                
                // set rendering mode - optimal balance between rendering speed and quality
                pdfDocument.RenderingSettings.RenderingMode = Vintasoft.Imaging.Pdf.PdfRenderingMode.Normal;
    
                // create new TIFF file
                using (Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile tiffFile = 
                    new Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile(tiffFileName, 
                        Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFileFormat.LittleEndian))
                {
                    // set TIFF compression to Zip
                    tiffFile.Pages.EncoderSettings.Compression = 
                        Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffCompression.Zip;
                    // for each PDF page
                    for (int i = 0; i < pdfDocument.Pages.Count; i++)
                    {
                        // render PDF page and add as image to Tiff file
                        tiffFile.Pages.Add(pdfDocument.Pages[i].Render());
                        // save changes to TIFF file
                        tiffFile.SaveChanges();
                    }
                }
            }
        }
    
    }
    
    ''' <summary>
    ''' Class shows how to convert PDF document to TIFF file using PdfDocument and TiffFile classes.
    ''' PDF document is rendered with specified resolution.
    ''' </summary>
    Public Class ConvertPdfToTiffUseImageFileWithSpecifiedResolution
    
        ''' <summary>
        ''' Converts PDF document to TIFF file using PdfDocument and TiffFile classes.
        ''' PDF document is rendered with specified resolution.
        ''' </summary>
        Public Shared Sub Convert(pdfFileName As String, tiffFileName As String, dpi As Single)
            ' open existing PDF document
            Using pdfDocument As New Vintasoft.Imaging.Pdf.PdfDocument(pdfFileName)
                ' set resolution
                pdfDocument.RenderingSettings.Resolution = New Vintasoft.Imaging.Resolution(dpi, dpi)
    
                ' set rendering mode - optimal balance between rendering speed and quality
                pdfDocument.RenderingSettings.RenderingMode = Vintasoft.Imaging.Pdf.PdfRenderingMode.Normal
    
                ' create new TIFF file
                Using tiffFile As New Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFile(tiffFileName, Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffFileFormat.LittleEndian)
                    ' set TIFF compression to Zip
                    tiffFile.Pages.EncoderSettings.Compression = Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffCompression.Zip
                    ' for each PDF page
                    For i As Integer = 0 To pdfDocument.Pages.Count - 1
                        ' render PDF page and add as image to Tiff file
                        tiffFile.Pages.Add(pdfDocument.Pages(i).Render())
                        ' save changes to TIFF file
                        tiffFile.SaveChanges()
                    Next
                End Using
            End Using
        End Sub
    
    End Class