我正在使用 iTextsharp 从电子纸 PDF 文件中提取图像,PDF 文件中的图像是 CMYK 格式,但提取的图像是 RGB。请就此提出建议。提前致谢
int xrefIdx = ((PRIndirectReference)obj).Number;
PdfObject pdfObj = doc.GetPdfObject(xrefIdx);
PdfStream str = (PdfStream)pdfObj;
byte[] bytes = PdfReader.GetStreamBytesRaw((PRStream)str);
using (System.IO.MemoryStream memStream = new System.IO.MemoryStream(bytes))
{
var rawImage = System.Drawing.Image.FromStream(memStream);
rawImage.Save(@"e:\extractedimages.jpeg", ImageFormat.Jpeg);
}