How to convert PDF files to images

前端 未结 12 525
庸人自扰
庸人自扰 2020-11-27 14:46

I need to convert PDF files to images. If the PDF file is multi-page,I just need one image that contains all of the PDF pages.

Is there an open sou

12条回答
  •  渐次进展
    2020-11-27 15:09

    The NuGet package Pdf2Png is available for free and is only protected by the MIT License, which is very open.

    I've tested around a bit and this is the code to get it to convert a PDF file to an image (tt does save the image in the debug folder).

    using cs_pdf_to_image;
    using PdfToImage;
    
    private void BtnConvert_Click(object sender, EventArgs e)
    {
        if(openFileDialog1.ShowDialog() == DialogResult.OK)
        {
            try
            {
                string PdfFile = openFileDialog1.FileName;
                string PngFile = "Convert.png";
                List Conversion = cs_pdf_to_image.Pdf2Image.Convert(PdfFile, PngFile);
                Bitmap Output = new Bitmap(PngFile);
                PbConversion.Image = Output;
            }
            catch(Exception E)
            {
                MessageBox.Show(E.Message);
            }
        }
    }
    

提交回复
热议问题