public static void Run() { // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Images(); //Open document Document pdfDocument = new Document(dataDir+ "PageToTIFF.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, dataDir + "output.tif"); }
public static void Run() { // ExStart:AllPagesToTIFF // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Images(); // Open document Document pdfDocument = new Document(dataDir+ "PageToTIFF.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, dataDir + "AllPagesToTIFF_out.tif"); // ExEnd:AllPagesToTIFF System.Console.WriteLine("PDF all pages converted to one tiff file successfully!"); }
public static void Run() { // ExStart:BradleyAlgorithm // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdf_Images(); // Open document Document pdfDocument = new Document(dataDir+ "PageToTIFF.pdf"); string outputImageFile = dataDir + "resultant_out.tif"; string outputBinImageFile = dataDir + "37116-bin_out.tif"; // Create Resolution object Resolution resolution = new Resolution(300); // Create TiffSettings object TiffSettings tiffSettings = new TiffSettings(); tiffSettings.Compression = CompressionType.LZW; tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Format1bpp; // Create TIFF device TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings); // Convert a particular page and save the image to stream tiffDevice.Process(pdfDocument, outputImageFile); using (FileStream inStream = new FileStream(outputImageFile, FileMode.Open)) { using (FileStream outStream = new FileStream(outputBinImageFile, FileMode.Create)) { tiffDevice.BinarizeBradley(inStream, outStream, 0.1); } } // ExEnd:BradleyAlgorithm System.Console.WriteLine("Conversion using bradley algorithm performed successfully!"); }
public static void NewApproach() { // ExStart:NewApproach // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles(); // Create PdfConverter object and bind input PDF file PdfConverter pdfConverter = new PdfConverter(); pdfConverter.BindPdf(dataDir + "inFile.pdf"); pdfConverter.DoConvert(); // Create TiffSettings object and set CompressionType TiffSettings tiffSettings = new TiffSettings(); // Convert to TIFF image pdfConverter.SaveAsTIFF(dataDir + "PDFToTIFFConversion_out.tif", 300, 300, tiffSettings, new WinAPIIndexBitmapConverter()); pdfConverter.Close(); // ExEnd:NewApproach }
public static void Run() { // ExStart:PDFToTIFFConversion // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfFacades_TechnicalArticles(); // Create PdfConverter object and bind input PDF file PdfConverter pdfConverter = new PdfConverter(); pdfConverter.Resolution = new Aspose.Pdf.Devices.Resolution(300); pdfConverter.BindPdf(dataDir + "inFile.pdf"); pdfConverter.DoConvert(); // Create TiffSettings object and set ColorDepth TiffSettings tiffSettings = new TiffSettings(); tiffSettings.Depth = ColorDepth.Format1bpp; // Convert to TIFF image pdfConverter.SaveAsTIFF(dataDir + "PDFToTIFFConversion_out.tif", 300, 300, tiffSettings); pdfConverter.Close(); // ExEnd:PDFToTIFFConversion }
public static void Main() { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); //create PdfConverter object and bind input PDF file PdfConverter pdfConverter = new PdfConverter(); // create Resolution object with 300 as an argument Aspose.Pdf.Devices.Resolution resolution = new Aspose.Pdf.Devices.Resolution(300); // specify the resolution value for PdfConverter object pdfConverter.Resolution = resolution; // bind the source PDF file pdfConverter.BindPdf(dataDir+ "input.pdf"); // start the conversion process pdfConverter.DoConvert(); //create TiffSettings object and set ColorDepth TiffSettings tiffSettings = new TiffSettings(); tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Format1bpp; //convert to TIFF image pdfConverter.SaveAsTIFF(dataDir+ "output.tif", 300, 300, tiffSettings); // close Converter object pdfConverter.Close(); }
private static string SaveAsTiff(string inputFile, string outputFolder) { try { if (!File.Exists(inputFile)) { throw new FileNotFoundException($"Die Datei {inputFile} konnte nicht gefunden werden"); } //create var pdfConverter = new Aspose.Pdf.Facades.PdfConverter(); // create Resolution object with 300 as an argument var resolution = new Resolution(240); // specify the resolution value for PdfConverter object - default is 150 pdfConverter.Resolution = resolution; // bind the source PDF file pdfConverter.BindPdf(inputFile); // start the conversion process pdfConverter.DoConvert(); //create TiffSettings object, set Compression and ColorDepth var tiffSettings = new TiffSettings { Compression = CompressionType.None }; var guid = Guid.NewGuid().ToString(); var filepath = Path.Combine(outputFolder, $"{Path.GetFileNameWithoutExtension(guid)}.tiff"); pdfConverter.SaveAsTIFF(filepath, tiffSettings); pdfConverter.Close(); return(filepath); } catch (Exception e) { Console.WriteLine(e); throw; } }
public static void Run() { // ExStart:ConvertToTIFFSettings // The path to the documents directory. string dataDir = RunExamples.GetDataDir_AsposePdfFacades_Images(); // Create PdfConverter object and bind input PDF file PdfConverter pdfConverter = new PdfConverter(); // Create Resolution object with 300 as an argument Aspose.Pdf.Devices.Resolution resolution = new Aspose.Pdf.Devices.Resolution(300); // Specify the resolution value for PdfConverter object pdfConverter.Resolution = resolution; // Bind the source PDF file pdfConverter.BindPdf(dataDir+ "ConvertToTIFF-Settings.pdf"); // Start the conversion process pdfConverter.DoConvert(); // Create TiffSettings object and set ColorDepth TiffSettings tiffSettings = new TiffSettings(); tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Format1bpp; // Convert to TIFF image pdfConverter.SaveAsTIFF(dataDir+ "output_out.tif", 300, 300, tiffSettings); // Close Converter object pdfConverter.Close(); // ExEnd:ConvertToTIFFSettings }
public static void Main() { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); //create PdfConverter object and bind input PDF file PdfConverter pdfConverter = new PdfConverter(); // create Resolution object with 300 as an argument Aspose.Pdf.Devices.Resolution resolution = new Aspose.Pdf.Devices.Resolution(300); // specify the resolution value for PdfConverter object pdfConverter.Resolution = resolution; // bind the source PDF file pdfConverter.BindPdf(dataDir + "input.pdf"); // start the conversion process pdfConverter.DoConvert(); //create TiffSettings object and set ColorDepth TiffSettings tiffSettings = new TiffSettings(); tiffSettings.Depth = Aspose.Pdf.Devices.ColorDepth.Format1bpp; //convert to TIFF image pdfConverter.SaveAsTIFF(dataDir + "output.tif", 300, 300, tiffSettings); // close Converter object pdfConverter.Close(); }
public static void Main(string[] args) { // The path to the documents directory. string dataDir = Path.GetFullPath("../../../Data/"); //Open document Document pdfDocument = new Document(dataDir+ "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, dataDir + "output.tif"); }