VintaSoft Imaging .NET SDK 15.0: Documentation for .NET developer
In This Topic
    Codecs: How to convert an extra large PDF page to a TIFF image?
    In This Topic
    Here is C# code that shows how to convert an extra large PDF page to a TIFF image:
    namespace ConvertLargePdfToTiffConsoleApp
    {
        /// <summary>
        /// This example shows how to convert PDF page of unlimited size to a TIFF file.<br />
        /// Size of PDF page is not limited because image renderer divides PDF page into tiles and
        /// process each tile separately.<br />
        /// Size of TIFF image is not limited because TIFF encoder divides TIFF image into tiles and
        /// process each tile separately.
        /// </summary>
        class Program
        {
            static void Main(string[] args)
            {
                try
                {
                    // create an image collection
                    using (Vintasoft.Imaging.ImageCollection images = new Vintasoft.Imaging.ImageCollection())
                    {
                        // add PDF document to the image collection
                        images.Add("documentWithLargePage.pdf");
                        // set the rendering resolution for PDF document
                        images.SetRenderingSettings(new Vintasoft.Imaging.Codecs.Decoders.RenderingSettings(new Vintasoft.Imaging.Resolution(300, 300)));
    
                        // create TIFF encoder
                        using (Vintasoft.Imaging.Codecs.Encoders.TiffEncoder tiffEncoder = new Vintasoft.Imaging.Codecs.Encoders.TiffEncoder())
                        {
                            // specify that TIFF encoder must create tiles in TIFF file - this prevents loading the whole PDF image into memory
                            tiffEncoder.Settings.UseTiles = true;
                            // specify the TIFF tile size
                            tiffEncoder.Settings.TileSize = new System.Drawing.Size(2048, 2048);
                            // specify that TIFF encoder must detect the image compression automatically
                            tiffEncoder.Settings.Compression = Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffCompression.Auto;
    
                            // subscribe to the image saving progress
                            images.ImageSavingProgress += Images_ImageSavingProgress;
    
                            // save images to TIFF file
                            images.SaveSync("output.tif", tiffEncoder);
                        }
    
                        // clear image collection and dispose images
                        images.ClearAndDisposeItems();
    
                        System.Console.WriteLine("File is converted successfully.");
                    }
                }
                catch (System.Exception ex)
                {
                    System.Console.WriteLine(string.Format("Error: {0}", ex.Message));
                }
                System.Console.WriteLine("Press any key...");
                System.Console.ReadKey();
            }
    
            private static void Images_ImageSavingProgress(object sender, Vintasoft.Imaging.ProgressEventArgs e)
            {
                // print information about image saving progress
                System.Console.Write(string.Format("{0} ", e.Progress));
            }
    
        }
    }