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();
        }
        private void startStep3()
        {
            device.GraphicsAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
            device.TextAlphaBits     = GhostscriptImageDeviceAlphaBits.V_4;
            device.ResolutionXY      = resolution;
            device.InputFiles.Add(srcPath.Text);
            device.CustomSwitches.Add("-dDOINTERPOLATE");

            int[] pageOrder   = { 1, 3, 4, 6, 7, 9, 10, 12, 13, 15, 16, 18, 19, 21 };
            int   photosSaved = 0;

            while (photosSaved < 14)
            {
                //Get photo
                device.OutputPath    = System.IO.Path.Combine(tempPath, "./" + photosSaved + ".png");
                device.Pdf.FirstPage = pageOrder[photosSaved];
                device.Pdf.LastPage  = pageOrder[photosSaved];
                device.Process();

                //Get image from file system
                images[photosSaved] = System.Drawing.Image.FromFile(device.OutputPath);

                //Update display
                photosSaved++;
                step3ProgressBar.Value = photosSaved;
                step3Label.Text        = photosSaved + " out of 14 images generated.";
                step3ProgressBar.Update();
                step3Label.Update();
            }

            //Next tab
            changeToTab(3);
            //Update
            tabControl1.Update();
            //Start step 4
            startStep4();
        }
Exemple #10
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));
            }
        }