C# 如何使用C从pdf文件中提取图像#

C# 如何使用C从pdf文件中提取图像#,c#,image,pdf,bitmap,C#,Image,Pdf,Bitmap,如何将.pdf文件中的图像导入System.Drawing.Bitmap?对于与.NET中的pdf文件有关的内容,我建议 它看起来像是提取图像,但我还没有机会测试这个 希望这对你有所帮助,祝你好运:)你可能想尝试完成这项任务 以下示例演示如何从PDF文件中的图像创建System.Drawing.Bitmap: static void GetImagesFromPdfAsBitmaps() { string pathToPdf = ""; using (PdfD

如何将.pdf文件中的图像导入System.Drawing.Bitmap?

对于与.NET中的pdf文件有关的内容,我建议

它看起来像是提取图像,但我还没有机会测试这个

希望这对你有所帮助,祝你好运:)

你可能想尝试完成这项任务

以下示例演示如何从PDF文件中的图像创建
System.Drawing.Bitmap

static void GetImagesFromPdfAsBitmaps()
{
    string pathToPdf = "";
    using (PdfDocument pdf = new PdfDocument(pathToPdf))
    {
        for (int i = 0; i < pdf.Images.Count; i++)
        {
            using (MemoryStream ms = new MemoryStream())
            {
                pdf.Images[i].Save(ms);

                // don't forget to rewind stream
                ms.Position = 0;

                System.Drawing.Image bitmap = System.Drawing.Bitmap.FromStream(ms);
                // ... use the bitmap and then dispose it
                bitmap.Dispose();
            }
        }
    }
}
static void getimagesfrompdfasbitmap()
{
字符串pathToPdf=“”;
使用(PdfDocument pdf=新PdfDocument(pathToPdf))
{
对于(int i=0;i
该库还可以将图像保存到文件中。该库不会对图像进行重采样(即,您将获得与PDF中完全相同的图像)


免责声明:我为图书馆的供应商Bit Miracle工作。

我对iText#和PdfSharp的经验是,他们编写pdf文件比阅读pdf文件更好。@Joel-希望我能加上一条评论。。)这个图书馆对非商业用途仍然是免费的吗?“我在网站上没看到有人提到这件事。”保罗·惠特不幸的是,现在已经不是这样了。对不起,我已经更新了答案。