public static void Main()
        {
            // NOTE:
            // When used in trial mode, the library imposes some restrictions.
            // Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            // for more information.

            string outputDocumentPath = "SaveAsBitonalTiff.tiff";
            string outputPagePath     = "SaveAsBitonalTiff_page0.tiff";

            using (PdfDocument pdf = new PdfDocument(@"..\Sample Data\jfif3.pdf"))
            {
                PdfDrawOptions options = PdfDrawOptions.Create();
                options.BackgroundColor      = new PdfRgbColor(255, 255, 255);
                options.HorizontalResolution = 300;
                options.VerticalResolution   = 300;

                // specify bitonal TIFF as the desired output compression
                options.Compression = ImageCompressionOptions.CreateBitonalTiff();

                // save one page
                pdf.Pages[0].Save(outputPagePath, options);

                // save the whole document as multipage TIFF
                pdf.SaveAsTiff(outputDocumentPath, options);
            }

            Console.WriteLine($"The output is located in {Environment.CurrentDirectory}");
        }
Ejemplo n.º 2
0
        public static void PDFToImage(string path, string savePath, string extension)
        {
            // replace string.Empty with your license key
            LicenseManager.AddLicenseData(LicenceKey);

            using (PdfDocument pdf = new PdfDocument(path))
            {
                PdfDrawOptions options = PdfDrawOptions.Create();
                options.BackgroundColor = new PdfRgbColor(255, 255, 255);
                options.Compression     = ImageCompressionOptions.CreateJpeg();
                var index = 1;
                foreach (var pdfPage in pdf.Pages)
                {
                    var fileName = savePath + "-" + index++ + extension;
                    pdfPage.Save(fileName, options);
                }
            }
        }
Ejemplo n.º 3
0
        public static void Main()
        {
            // NOTE:
            // When used in trial mode, the library imposes some restrictions.
            // Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            // for more information.

            string pathToImage = "SavePageAsImage.jpg";

            using (PdfDocument pdf = new PdfDocument(@"Sample Data\jfif3.pdf"))
            {
                PdfDrawOptions options = PdfDrawOptions.Create();
                options.BackgroundColor = new PdfRgbColor(255, 255, 255);
                options.Compression     = ImageCompressionOptions.CreateJpeg();

                pdf.Pages[1].Save(pathToImage, options);
            }

            Process.Start(pathToImage);
        }
        public static void Main()
        {
            // NOTE:
            // When used in trial mode, the library imposes some restrictions.
            // Please visit http://bitmiracle.com/pdf-library/trial-restrictions.aspx
            // for more information.

            string pathToImage = "SavePageAsImage.jpg";

            using (PdfDocument pdf = new PdfDocument(@"..\Sample Data\jfif3.pdf"))
            {
                PdfDrawOptions options = PdfDrawOptions.Create();
                options.BackgroundColor = new PdfRgbColor(255, 255, 255);
                options.Compression     = ImageCompressionOptions.CreateJpeg();

                pdf.Pages[1].Save(pathToImage, options);
            }

            Console.WriteLine($"The output is located in {Environment.CurrentDirectory}");
        }
Ejemplo n.º 5
0
        private async Task <Stream> Inner()
        {
            var filename = "我的简历.pdf";

            using (var pdfDocumentStream = File.OpenRead(filename))
            {
                var            document = new PdfDocument(pdfDocumentStream);
                var            page     = document.Pages[0];
                PdfDrawOptions options  = PdfDrawOptions.Create();
                options.BackgroundColor = new PdfRgbColor(255, 255, 255);
                options.Compression     = ImageCompressionOptions.CreateJpeg();
                double resolutionRate = page.Resolution / 200;
                options.HorizontalResolution = 200;
                options.VerticalResolution   = 200;

                var memoryStream = new MemoryStream();
                {
                    page.Save(memoryStream, options);
                }
                memoryStream.Seek(0, SeekOrigin.Begin);
                return(await Task.FromResult(memoryStream));
            }
        }
Ejemplo n.º 6
0
        public static async Task <List <Stream> > PDFToImage(string path)
        {
            // replace string.Empty with your license key
            LicenseManager.AddLicenseData(LicenceKey);

            return(await Task.Run(() =>
            {
                var streamList = new List <Stream>();
                using (PdfDocument pdf = new PdfDocument(path))
                {
                    PdfDrawOptions options = PdfDrawOptions.Create();
                    options.BackgroundColor = new PdfRgbColor(255, 255, 255);
                    options.Compression = ImageCompressionOptions.CreateJpeg();
                    foreach (var page in pdf.Pages)
                    {
                        var outputStream = new MemoryStream();
                        page.Save(outputStream, options);
                        streamList.Add(outputStream);
                    }
                }
                return streamList;
            }));
        }