private void Export_Second_And_Third_Pdf_Page_As_Grayscale_Png()
 {
     GhostscriptPngDevice dev = new GhostscriptPngDevice(GhostscriptPngDeviceType.PngGray);
     dev.GraphicsAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
     dev.TextAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
     dev.ResolutionXY = new GhostscriptImageDeviceResolution(96, 96);
     dev.InputFiles.Add(@"E:\gss_test\indispensable.pdf");
     dev.Pdf.FirstPage = 2;
     dev.Pdf.LastPage = 4;
     dev.OutputPath = @"E:\gss_test\output\indispensable_gray_page_%03d.png";
     dev.Process();
 }
        private void Export_Second_And_Third_Pdf_Page_As_Grayscale_Png()
        {
            GhostscriptPngDevice dev = new GhostscriptPngDevice(GhostscriptPngDeviceType.PngGray);

            dev.GraphicsAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
            dev.TextAlphaBits     = GhostscriptImageDeviceAlphaBits.V_4;
            dev.ResolutionXY      = new GhostscriptImageDeviceResolution(96, 96);
            dev.InputFiles.Add(@"E:\gss_test\indispensable.pdf");
            dev.Pdf.FirstPage = 2;
            dev.Pdf.LastPage  = 4;
            dev.OutputPath    = @"E:\gss_test\output\indispensable_gray_page_%03d.png";
            dev.Process();
        }
 private void Export_Second_And_Third_Pdf_Page_As_24bit_Png()
 {
     GhostscriptPngDevice dev = new GhostscriptPngDevice(GhostscriptPngDeviceType.Png16m);
     dev.GraphicsAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
     dev.TextAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
     dev.ResolutionXY = new GhostscriptImageDeviceResolution(96, 96);
     dev.InputFiles.Add(@"E:\gss_test\indispensable.pdf");
     dev.Pdf.FirstPage = 2;
     dev.Pdf.LastPage = 4;
     dev.CustomSwitches.Add("-dDOINTERPOLATE");
     dev.OutputPath = @"E:\gss_test\output\indispensable_color_page_%03d.png";
     dev.Process();
 }
        private void Extract_Pdf_Pages_As_Png_And_Add_Watermark()
        {
            GhostscriptPngDevice dev = new GhostscriptPngDevice(GhostscriptPngDeviceType.Png16m);

            dev.GraphicsAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
            dev.TextAlphaBits     = GhostscriptImageDeviceAlphaBits.V_4;
            dev.ResolutionXY      = new GhostscriptImageDeviceResolution(96, 96);
            dev.InputFiles.Add(@"E:\gss_test\indispensable.pdf");
            dev.Pdf.FirstPage = 2;
            dev.Pdf.LastPage  = 4;
            dev.PostScript    = POSTSCRIPT_APPEND_WATERMARK;
            dev.OutputPath    = @"E:\gss_test\output\indispensable_color_page_%03d.png";
            dev.Process();
        }
        private void Export_Second_And_Third_Pdf_Page_As_24bit_Png()
        {
            GhostscriptPngDevice dev = new GhostscriptPngDevice(GhostscriptPngDeviceType.Png16m);

            dev.GraphicsAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
            dev.TextAlphaBits     = GhostscriptImageDeviceAlphaBits.V_4;
            dev.ResolutionXY      = new GhostscriptImageDeviceResolution(96, 96);
            dev.InputFiles.Add(@"E:\gss_test\indispensable.pdf");
            dev.Pdf.FirstPage = 2;
            dev.Pdf.LastPage  = 4;
            dev.CustomSwitches.Add("-dDOINTERPOLATE");
            dev.OutputPath = @"E:\gss_test\output\indispensable_color_page_%03d.png";
            dev.Process();
        }
        public void LoadImage(string filepath, string destpath)
        {
            PdfReader            reader = new iTextSharp.text.pdf.PdfReader(filepath);
            GhostscriptPngDevice dev    = new GhostscriptPngDevice(GhostscriptPngDeviceType.Png256);

            dev.GraphicsAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
            dev.TextAlphaBits     = GhostscriptImageDeviceAlphaBits.V_4;
            dev.ResolutionXY      = new GhostscriptImageDeviceResolution(290, 290);
            dev.InputFiles.Add(filepath);
            dev.Pdf.FirstPage = 0;
            dev.Pdf.LastPage  = reader.NumberOfPages;
            dev.CustomSwitches.Add("-dDOINTERPOLATE");
            dev.OutputPath = destpath + "%03d.jpg";
            dev.Process();
        }
Exemple #7
0
        public static void ConvertPdfToImage(string libPath, string inputPDFFilePath, int pageNumber, string outputFilePath, int width, int height)
        {
            GhostscriptVersionInfo gvi = new GhostscriptVersionInfo(libPath);

            GhostscriptPngDevice dev = new GhostscriptPngDevice(GhostscriptPngDeviceType.Png256);

            dev.GraphicsAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
            dev.TextAlphaBits     = GhostscriptImageDeviceAlphaBits.V_4;
            dev.ResolutionXY      = new GhostscriptImageDeviceResolution(290, 290);
            dev.InputFiles.Add(inputPDFFilePath);
            dev.Pdf.FirstPage = pageNumber;
            dev.Pdf.LastPage  = pageNumber;
            dev.CustomSwitches.Add("-dDOINTERPOLATE");
            dev.OutputPath = outputFilePath;
            dev.Process(gvi, true, null);
        }
Exemple #8
0
        public void LoadImage(string InputPDFFile, int PageNumber)
        {
            //string outImageName = @"D:\testGI\AA\Meatslave_Aiko_Iwase.pdf";
            string outImageName = InputPDFFile;

            outImageName = outImageName + "_" + PageNumber.ToString() + "_.jpg";


            GhostscriptPngDevice dev = new GhostscriptPngDevice(GhostscriptPngDeviceType.Png256);

            dev.GraphicsAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
            dev.TextAlphaBits     = GhostscriptImageDeviceAlphaBits.V_4;
            dev.ResolutionXY      = new GhostscriptImageDeviceResolution(290, 290);
            dev.InputFiles.Add(InputPDFFile);
            dev.Pdf.FirstPage = PageNumber;
            dev.Pdf.LastPage  = PageNumber;
            dev.CustomSwitches.Add("-dDOINTERPOLATE");
            dev.OutputPath = @"D:\testGI\AA\" + outImageName;
            dev.Process();
        }
Exemple #9
0
        public void PdfToImage(string inputfile)
        {
            GhostscriptVersionInfo _lastInstalledVersion = GetGhostscriptVersion();

            int pageCount = GetPageCount(inputfile);

            var outputpath = FileUtilities.GetOutputPath(inputfile, ActionType.PDFTOIMAGE, formatChange: true, newExtension: ".jpeg", hasMultipleOutput: pageCount > 1, outputNameFormat: "{0}_Page_{1}");

            GhostscriptPngDevice img = new GhostscriptPngDevice
            {
                GraphicsAlphaBits = GhostscriptImageDeviceAlphaBits.V_4,
                TextAlphaBits     = GhostscriptImageDeviceAlphaBits.V_4,
                Resolution        = 600,
                PostScript        = string.Empty
            };

            img.InputFiles.Add(inputfile);

            for (int i = 1; i <= pageCount; i++)
            {
                img.Pdf.FirstPage = i;
                img.Pdf.LastPage  = i;

                var outputfilename = string.Format(outputpath, Path.GetFileNameWithoutExtension(inputfile), i);

                if (File.Exists(outputfilename))
                {
                    File.Delete(outputfilename);
                }

                img.OutputPath = outputfilename;
                img.Process(_lastInstalledVersion, false, null);

                Console.WriteLine("Generated {0}", Path.GetFileName(outputfilename));
            }
        }