Exemple #1
0
        public static string PDFToBMP(string pdfFilePath, string bmpFilePath)
        {
            var stream     = new FileStream(pdfFilePath, FileMode.Open);
            var pdfConvert = new Aspose.Pdf.Facades.PdfConverter();
            var pdfDoc     = new Aspose.Pdf.Document(stream);

            pdfConvert.BindPdf(pdfDoc);
            pdfConvert.DoConvert();
            pdfConvert.GetNextImage(bmpFilePath, new Aspose.Pdf.PageSize(200, 150), System.Drawing.Imaging.ImageFormat.Bmp);
            pdfConvert.Close();
            pdfConvert.Dispose();
            stream.Flush();
            stream.Close();
            return(bmpFilePath);
        }
Exemple #2
0
        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;
            }
        }