Hi all,
i am using PDFSharp (Version: 1.31.1789.0) and i got an exception, because a pdf file, which i use, contains one image and that seems to use 2 different encodings. I tried to use the first encoding of the Array, but if i use that encoding, which is "
/FlateDecode" i got an OutOfMemoryError, when i first save the image and then try to read it programmatically.
Code:
static void ExportImage(PdfDictionary image, ImageFileInfo ifi)
{
string filter="";
try
{
//the following line runs in an exception, because image.Elements.GetName("/Filter") contains an object array with two values ("/FlateDecode" and "/DCTDecode" and not one single value
filter = image.Elements.GetName("/Filter");
}catch (Exception ex)
{
PdfSharp.Pdf.PdfItem objFilter = (PdfSharp.Pdf.PdfItem)image.Elements["/Filter"];
filter = objFilter.ToString();
}
if (filter.Contains("/DCTDecode"))
{
ifi.ImageFileName += ".jpg";
ExportJpegImage(image, ifi.ImageFileName);
}
else if (filter.Contains("/FlateDecode"))
{
ifi.ImageFileName += ".png";
ExportAsPngImage(image, ifi.ImageFileName);
}
}
i don't know, if my approach is the correct one.
if pdfdictionary.elemens["/Filter"] contains 2 values, which should i use or what should i change, to make the code working with that document?
Thanks in advance!
tetronik