/ Published in: C#
This technical tip shows how to convert PDF pages to TIFF image inside .NET Applications. The TiffDevice class allows you to convert PDF pages to TIFF images. This class provides a method named Process which allows you to convert all the pages in a PDF file to a single TIFF image. To convert a particular page in a PDF file to a TIFF image, use an overloaded version of the Process(..) method which takes a page number as an argument for conversion.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//The following code snippet shows how to convert all the PDF pages to a single TIFF image. //[C# Code Sample] // Open document // Create Resolution object // Create TiffSettings object tiffSettings.Compression = CompressionType.None; tiffSettings.Depth = ColorDepth.Default; tiffSettings.Shape = ShapeType.Landscape; tiffSettings.SkipBlankPages = false; // Create TIFF device // Convert a particular page and save the image to stream tiffDevice.Process(pdfDocument, "output.tif"); //[VB.NET Code Sample] 'Open document Dim pdfDocument As New Document("input.pdf") 'Create Resolution object 'Create TiffSettings object Dim tiffSettings As New TiffSettings() tiffSettings.Compression = CompressionType.None tiffSettings.Depth = ColorDepth.Default tiffSettings.Shape = ShapeType.Landscape tiffSettings.SkipBlankPages = False 'Create TIFF device 'Convert a particular page and save the image to stream tiffDevice.Process(pdfDocument, "output.tif") //Convert One Page to TIFF Image //[C# Code Sample] // Open document Document pdfDocument = new Document("input.pdf"); // Create Resolution object Resolution resolution = new Resolution(300); // Create TiffSettings object TiffSettings tiffSettings = new TiffSettings(); tiffSettings.Compression = CompressionType.None; tiffSettings.Depth = ColorDepth.Default; tiffSettings.Shape = ShapeType.Landscape; tiffSettings.SkipBlankPages = false; // Create TIFF device TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings); // Convert a particular page and save the image to stream tiffDevice.Process(pdfDocument, 1, 1, "output.tif"); //[VB.NET Code Sample] 'Open document 'Create Resolution object Dim resolution As New Resolution(300) 'Create TiffSettings object tiffSettings.Compression = CompressionType.None tiffSettings.Depth = ColorDepth.Default tiffSettings.Shape = ShapeType.Landscape tiffSettings.SkipBlankPages = False 'Create TIFF device Dim tiffDevice As New TiffDevice(resolution, tiffSettings) 'Convert a particular page and save the image to stream tiffDevice.Process(pdfDocument, 1, 1, "output.tif") //Use Bradley algorithm during conversion //[C# Code Sample] string outputImageFile = @"c:\resultant.tif"; string outputBinImageFile = @"c:\37116-bin.tif"; //open document //create Resolution object //create TiffSettings object tiffSettings.Compression = CompressionType.LZW; tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Format1bpp; //create TIFF device //convert a particular page and save the image to stream tiffDevice.Process(pdfDocument, outputImageFile); { { tiffDevice.BinarizeBradley(inStream, outStream, 0.1); } } //[VB.NET Code Sample] Dim outputImageFile As String = "c:\resultant.tif" Dim outputBinImageFile As String = "c:\37116-bin.tif" 'open document Dim pdfDocument As Aspose.Pdf.Document = New Aspose.Pdf.Document("c:\input.pdf") 'create Resolution object 'create TiffSettings object Dim tiffSettings As TiffSettings = New TiffSettings() tiffSettings.Compression = CompressionType.LZW tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Format1bpp 'create TIFF device 'convert a particular page and save the image to stream tiffDevice.Process(pdfDocument, outputImageFile) Using inStream As FileStream = New FileStream(outputImageFile, FileMode.Open) Using outStream As FileStream = New FileStream(outputBinImageFile, FileMode.Create) tiffDevice.BinarizeBradley(inStream, outStream, 0.1) End Using End Using