使用 .Net c# 从 PDF 中提取图像

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1554484/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 18:47:31  来源:igfitidea点击:

Extract image from PDF using .Net c#

c#.netimagepdfextract

提问by

I want to extract images from PDF. Tried many solutions but still not getting solution. Help me out....Thanks in advance

我想从 PDF 中提取图像。尝试了很多解决方案,但仍然没有解决方案。帮帮我.... 提前致谢

回答by Bobrovsky

Docotic.Pdf librarycan be used to extract images from PDFs.

Docotic.Pdf 库可用于从 PDF 中提取图像。

Here is a sample that shows how to extract all images from a PDF:

这是一个示例,展示了如何从 PDF 中提取所有图像:

static void ExtractAllImages()
{
    string path = "";
    using (PdfDocument pdf = new PdfDocument(path))
    {
        for (int i = 0; i < pdf.Images.Count; i++)
        {
            string imageName = string.Format("image{0}", i);
            string imagePath = pdf.Images[i].Save(imageName);
        }
    }
}

The library won't resample images. It will save them exactly the same as in PDF.

该库不会重新采样图像。它将以与 PDF 完全相同的方式保存它们。

Disclaimer: I work for Bit Miracle, vendor of the library.

免责声明:我为该库的供应商 Bit Miracle 工作。