PDFsharp & MigraDoc Foundation

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

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed Sep 23, 2009 3:43 pm 
Offline

Joined: Wed Sep 23, 2009 2:45 pm
Posts: 3
Hi, I have been using PDFSharp for a while and it has been working OK, but recently users have found problems with PDF files generated with a new scanner.
When the following line of code is executed:

Code:
PdfDocument inputDocument = PdfReader.Open(file, PdfDocumentOpenMode.Import)


an exception of type PdfReaderException is raised with the following message: Token '38438' was not expected.

Could this be that the PDF file generated by the scanner contains elements not supported by PDFSharp? Is there an easy way to fix this problem modifying the code? The problem file can be downloaded from http://theglobe.urudata.com/jbriosso/FACTURA-DISTRICOMP.pdf.

Thanks in advance!

Regards,
Martin


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 23, 2009 4:10 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3095
Location: Cologne, Germany
Hi, Martin,

this is not my area of expertise, but I have a patch that'll work with that file (I hope you don't come up with cruder files ...).

In Parser.cs you'll find
Code:
internal PdfTrailer ReadTrailer()


Replace this old code
Code:
string trail = this.lexer.ReadRawString(length - 31, 30); //lexer.Pdf.Substring(length - 30);
int idx = trail.IndexOf("startxref");
this.lexer.Position = length - 31 + idx;


with this new snippet:
Code:
string trail = this.lexer.ReadRawString(length - 131, 130);
int idx = trail.IndexOf("startxref");
this.lexer.Position = length - 131 + idx;

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 23, 2009 4:20 pm 
Offline

Joined: Wed Sep 23, 2009 2:45 pm
Posts: 3
Thanks Thomas, I will try what you suggest.


Top
 Profile  
Reply with quote  
PostPosted: Wed Sep 23, 2009 5:24 pm 
Offline

Joined: Wed Sep 23, 2009 2:45 pm
Posts: 3
It worked great! Thanks!


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 38 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