Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/20.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# 保存使用PdfPig提取的图像_C#_.net_Pdf_Console Application - Fatal编程技术网

C# 保存使用PdfPig提取的图像

C# 保存使用PdfPig提取的图像,c#,.net,pdf,console-application,C#,.net,Pdf,Console Application,我正在使用C#在一个控制台应用程序(.Net Core)项目中试验PdfPig 以下代码旨在从PDF获取图像并将其保存到我的桌面: IEnumerable<IPdfImage> images = page.GetImages(); foreach (IPdfImage image in images) { Console.WriteLine(image); byte[] bitmap = image.RawBytes.ToArray(); string ex

我正在使用C#在一个控制台应用程序(.Net Core)项目中试验PdfPig

以下代码旨在从PDF获取图像并将其保存到我的桌面:

IEnumerable<IPdfImage> images = page.GetImages();

foreach (IPdfImage image in images)
{
    Console.WriteLine(image);
    byte[] bitmap = image.RawBytes.ToArray();
    string exportPath = @"C:\Users\ed\Desktop\" + Guid.NewGuid().ToString() + ".jpg";   
    System.IO.File.WriteAllBytes(exportPath, bitmap);
}
请有人建议如何修改这个;我怀疑我是如何创建图像文件的


谢谢大家!

假设pdf图像的原始字节构成jpg图像。事实并非如此,pdf有许多位图格式,这是正确的。你知道我能识别并导出正确文件格式的方法吗?看起来这些图像是tif文件,我从你的问题“CCITTFaxDecode”中提取的。
XObject Image (w 595.1999999999999, h 841.92): <Type, /XObject>, <Subtype, /Image>, <Width, 2480>, <Height, 3508>, <BitsPerComponent, 1>, <ColorSpace, /DeviceGray>, <Filter, /CCITTFaxDecode>, <DecodeParms, <Columns, 2480>, <Rows, 3508>>, <Length, 381787>

XObject Image (w 595.1999999999999, h 841.92): <Type, /XObject>, <Subtype, /Image>, <Width, 2480>, <Height, 3508>, <BitsPerComponent, 1>, <ColorSpace, /DeviceGray>, <Filter, /CCITTFaxDecode>, <DecodeParms, <Columns, 2480>, <Rows, 3508>>, <Length, 241054>
97266a2b-5e2b-49e1-8b19-f6716f294a4d.jpg it appears that we don't support this file format.