问题
I am using iTextsharp to extracted images from epaper PDF files, the images in the PDF files are in CMYK format, but the extracted images are in RGB. Please advice on this. Thanks in advance
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);
}
回答1:
Unfortunately, .NET isn't really up to the job for what you need to do as it really only works in RGB. Please see this answer to another question (https://stackoverflow.com/a/1773496/7122) which has more details.
来源:https://stackoverflow.com/questions/19363265/c-sharp-itextsharp-extracted-cmyk-images-returns-in-rgb-format