PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 8:38 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Aug 03, 2011 8:15 am 
Offline

Joined: Tue Aug 02, 2011 3:13 pm
Posts: 1
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.


Top
 Profile  
Reply with quote  
PostPosted: Fri Aug 26, 2011 6:46 pm 
Offline

Joined: Fri Aug 26, 2011 6:41 pm
Posts: 1
Awesome!! Worked like a charm. Thanks.
Dave


Top
 Profile  
Reply with quote  
PostPosted: Fri Jan 11, 2013 1:54 pm 
Offline

Joined: Fri Jan 11, 2013 1:44 pm
Posts: 1
Thanks jacekdt - very very much appreciated.

I was also having the problem of a blank PDF being created when I was using PDFSharp to merge PDF's created from .rdlc reports.

To clarify for anyone else having this issue, it is still present in the PDFSharp code & binaries as at 2013-01-11, version 1.32.

To apply the fix that jacekdt came up with, download the source code, open the file:
\PDFSharp\code\BuildAll-PdfSharp-VS2010.sln
(you'll need Visual Studio 2010)

Then in the project, expand the folder:
PdfSharp.Pdf.IO

and open the class:
Lexer.cs

Simply replace the existing ReadStream function with the code that jacekdt posted above.

Rebuild the solution, and you'll have a new binary to include in the \bin folder of your own project.


Cheers,
Mike


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 30 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group