예제 #1
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);
                }
            }
        }
        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}");
        }
예제 #4
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));
            }
        }
예제 #5
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;
            }));
        }