VintaSoft Imaging .NET SDK v8.7
In This Topic
    Codecs: How to convert PDF to TIFF?
    In This Topic

    SDK needs to render PDF page (draw text, images and graphics on PDF page) when converting PDF document to 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 UserAndSystemFontProgramsController class.
    More info about fonts in PDF document can be found here.


    Here is an example that shows how to convert PDF document to TIFF file using image collection and TiffEncoder:
    ' The project, which uses this code, must have references to the following assemblies:
    ' - Vintasoft.Imaging
    
    ''' <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
                  
    
    // The project, which uses this code, must have references to the following assemblies:
    // - Vintasoft.Imaging
    
    /// <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();
            }
        }
    
    }
                    
    


    Here is an example that shows how to convert PDF document to TIFF file using PdfDocument and TiffFile
    ' The project, which uses this code, must have references to the following assemblies:
    ' - Vintasoft.Imaging
    ' - Vintasoft.Imaging.Pdf
    
    ''' <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
                  
    
    // The project, which uses this code, must have references to the following assemblies:
    // - Vintasoft.Imaging
    // - Vintasoft.Imaging.Pdf
    
    /// <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();
                    }
                }
            }
        }
    }