PdfSharp throws exception during loading compressed PDF document. I am not sure if all compressed documents but I have tested on pdfs generated by Microsoft Reporting Services 2008.
I have found the problem in
PdfSharp.Pdf.IO.Lexer class in method
ReadStream.
I have changed it to below code and the compressed pdf are processed correctly now:
Code:
public byte[] ReadStream(int length)
{
MoveToNonWhiteSpace();
pdf.Position = idxChar;
byte[] bytes = new byte[length];
int read = this.pdf.Read(bytes, 0, length);
Debug.Assert(read == length);
// synchronize idxChar etc.
this.Position += length;
return bytes;
}
Can any body incorporate that changes in PDFSharp for future releases.
If required I can send example of pdf file which can not be opened.