private void Export_First_And_Second_Pdf_Page_As_Color_Jpeg()
 {
     GhostscriptJpegDevice dev = new GhostscriptJpegDevice(GhostscriptJpegDeviceType.Jpeg);
     dev.GraphicsAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
     dev.TextAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
     dev.ResolutionXY = new GhostscriptImageDeviceResolution(96, 96);
     dev.JpegQuality = 80;
     dev.InputFiles.Add(@"E:\gss_test\indispensable.pdf");
     dev.Pdf.FirstPage = 2;
     dev.Pdf.LastPage = 4;
     dev.OutputPath = @"E:\gss_test\output\indispensable_color_page_%03d.jpeg";
     dev.Process();
 }
        private void Export_First_And_Second_Pdf_Page_As_Grayscale_Jpeg()
        {
            GhostscriptJpegDevice dev = new GhostscriptJpegDevice(GhostscriptJpegDeviceType.JpegGray);

            dev.GraphicsAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
            dev.TextAlphaBits     = GhostscriptImageDeviceAlphaBits.V_4;
            dev.ResolutionXY      = new GhostscriptImageDeviceResolution(96, 96);
            dev.JpegQuality       = 80;
            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.jpeg";
            dev.Process();
        }
Beispiel #3
0
        private void Export_First_And_Second_Pdf_Page_As_Color_Jpeg()
        {
            GhostscriptJpegDevice dev = new GhostscriptJpegDevice(GhostscriptJpegDeviceType.Jpeg);

            dev.GraphicsAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
            dev.TextAlphaBits     = GhostscriptImageDeviceAlphaBits.V_4;
            dev.ResolutionXY      = new GhostscriptImageDeviceResolution(96, 96);
            dev.JpegQuality       = 80;
            dev.InputFiles.Add(@"..\..\..\test\t2.pdf");
            dev.Pdf.FirstPage = 2;
            dev.Pdf.LastPage  = 4;
            dev.OutputPath    = @"..\..\..\test\output\t2_color_page_%03d.jpeg";
            dev.Process();
        }
Beispiel #4
0
        private void b_pdf2jpg_Click(object sender, EventArgs e)
        {
            try
            {
                if (listBox1.SelectedIndex != -1 & comboBox1.Text == "*.pdf")
                {
                    foreach (var item in listBox1.SelectedItems)
                    {
                        Convert.ToString(item);
                        string sourcePdf = Convert.ToString(item);
                        string thename   = Path.GetFileNameWithoutExtension(sourcePdf);
                        raf    = new iTextSharp.text.pdf.RandomAccessFileOrArray(sourcePdf);
                        reader = new iTextSharp.text.pdf.PdfReader(raf, null);
                        var page  = reader.GetPageSize(1);
                        int heigt = Convert.ToInt16(page.Height);
                        int width = Convert.ToInt16(page.Width);
                        //uzycie wprapera z Nuget
                        //GhostscriptWrapper.GeneratePageThumb(@sourcePdf, @sourcePdf.Replace("pdf", "jpg"), 1, width, heigt);
                        //GhostscriptWrapper.GeneratePageThumb(sourcePdf, sourcePdf.Replace("pdf", "jpg"), 1, 297, 210);
                        GhostscriptJpegDevice dev = new GhostscriptJpegDevice(GhostscriptJpegDeviceType.Jpeg);
                        dev.GraphicsAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
                        dev.TextAlphaBits     = GhostscriptImageDeviceAlphaBits.V_4;
                        dev.ResolutionXY      = new GhostscriptImageDeviceResolution(300, 300);
                        dev.JpegQuality       = 100;
                        dev.InputFiles.Add(@sourcePdf);
                        dev.Pdf.FirstPage = 1;
                        dev.Pdf.LastPage  = 1;
                        dev.OutputPath    = @sourcePdf.Replace("pdf", "jpg");
                        dev.Process();
                    }

                    System.Media.SystemSounds.Beep.Play();
                    MessageBox.Show("koniec");
                }

                else
                {
                    System.Media.SystemSounds.Beep.Play();
                    MessageBox.Show("Wskaż pliki pdf na liście");
                }
            }
            catch
            {
            }
        }
        public string LoadImage(string InputPDFFile, int PageNumber, HttpContext context)
        {
            string outImageName = Path.GetFileNameWithoutExtension(InputPDFFile);

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


            GhostscriptJpegDevice dev = new GhostscriptJpegDevice(GhostscriptJpegDeviceType.Jpeg);

            dev.GraphicsAlphaBits = GhostscriptImageDeviceAlphaBits.V_4;
            dev.TextAlphaBits     = GhostscriptImageDeviceAlphaBits.V_4;
            dev.ResolutionXY      = new GhostscriptImageDeviceResolution(250, 250);
            dev.InputFiles.Add(InputPDFFile);
            dev.Pdf.FirstPage = PageNumber;
            dev.Pdf.LastPage  = PageNumber;
            dev.CustomSwitches.Add("-dDOINTERPOLATE");
            dev.OutputPath = context.Server.MapPath(@"~/Media/" + outImageName);
            dev.Process();
            return(outImageName);
        }