Hi,
I've been using the provided example
http://www.pdfsharp.net/wiki/ExportImages-sample.ashx to extract images from each page in a PDF.
The provided example shows how to determine if an image is /DCTDecode or /FlateDecode, I've provided a fragment of the code sample from your Wiki below (for reference):
Code:
string filter = objImage.Elements.GetName("/Filter");
switch (filter) {
case "/DCTDecode":
ExportJpegImage(objImage, ref count);
break;
case "/FlateDecode":
ExportFlateImage(objImage, ref count);
break;
}
But some of my PDFs seems to have images with two encodings and this causes the GetName() method to fail with a null exception. I've provided an example PDF fragment below:
Code:
6 0 obj
<<
/Type /XObject
/Subtype /Image
/Name /Img1
/Filter [/FlateDecode/DCTDecode]
/Width 2480
/Height 3508
/BitsPerComponent 8
/ColorSpace /DeviceRGB
/Length 7 0 R
>>
stream
My understanding is that /Filter [/FlateDecode/DCTDecode] means that the Image was encoding using Flate and then DCT and I should decode in reverse order. Is that correct?
But I don't know how to detect this condition in code since GetName("/Filter") returns null in this scenario.
So how do I detect this scenario in code?
And in the above /FlateDecode/DCTDecode example, what should I be doing to decode it and save to disk?
Thanks.
Simon Bond