Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用C语言从PDF中提取图像#_C#_Pdf_Image Processing_Ghostscript - Fatal编程技术网

C# 使用C语言从PDF中提取图像#

C# 使用C语言从PDF中提取图像#,c#,pdf,image-processing,ghostscript,C#,Pdf,Image Processing,Ghostscript,我在从PDF中提取图像时遇到问题。我尝试使用GhostScript,但是图像是用像素化的牙齿提取的,就像在对象的边缘画线一样。我什么也没试过。增加DPI时,提取的图像太大。提取时会降低图像质量 我非常感谢任何人推荐一个包来执行这样的操作-付费或免费。有足够多的通用PDF库可用于从PDF中提取图像。并非所有这些方法都提供了一种简单的方法 作为的开发人员之一,我可以为该任务推荐它 以下示例演示如何从PDF中提取所有图像: static void ExtractImagesFromPdfPages()

我在从PDF中提取图像时遇到问题。我尝试使用GhostScript,但是图像是用像素化的牙齿提取的,就像在对象的边缘画线一样。我什么也没试过。增加DPI时,提取的图像太大。提取时会降低图像质量


我非常感谢任何人推荐一个包来执行这样的操作-付费或免费。

有足够多的通用PDF库可用于从PDF中提取图像。并非所有这些方法都提供了一种简单的方法

作为的开发人员之一,我可以为该任务推荐它

以下示例演示如何从PDF中提取所有图像:

static void ExtractImagesFromPdfPages()
{
    string path = "";
    using (PdfDocument pdf = new PdfDocument(path))
    {
        for (int i = 0; i < pdf.Pages.Count; i++)
        {
            for (int j = 0; j < pdf.Pages[i].Images.Count; j++)
            {
                string imageName = string.Format("page{0}-image{1}", i, j);
                string imagePath = pdf.Pages[i].Images[j].Save(imageName);
            }
        }
    }
}
static void ExtractImagesFromPdfPages()
{
字符串路径=”;
使用(PdfDocument pdf=新PdfDocument(路径))
{
对于(int i=0;i

该库不会对图像重新采样。它将保存与PDF中完全相同的内容。

我对PdfSharp有很好的经验。这里可以找到示例源代码:。我在我的项目中也使用了PdfSharp。实际上,任何通用PDF库都应该允许您以自然分辨率提取嵌入的位图。
PDF.Pages[I].Images[j]
返回页面资源中的所有图像还是返回页面上使用的图像?后者不一定包括资源中的所有图像,但还包括内联图像和使用过的XObject中的图像。@mkl它返回所有图像(内联图像和非内联图像)啊,这很好。仅仅是页面资源中的图像就可能会产生误导。