PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Feb 26, 2021 1:00 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: Fri Dec 07, 2018 10:50 pm 

Joined: Fri Dec 07, 2018 10:40 pm
Posts: 2
The code below is working for 100s of documents. But one of the document it is failing on the pdfReader.Open(ms, pdfDocumentOpenMode.Import). The document can be downloaded and opened in browser just fine.

I can't share the document publically, I am happy to email it privately for testing.

MemoryStream ms = new MemoryStream(attachment.File_Contents);
using (PdfDocument pdfDoc = PdfReader.Open(ms, PdfDocumentOpenMode.Import))


Error: Value was either too large or too small for an Int64.
StackTrace: at System.Number.ParseInt64(String value, NumberStyles options, NumberFormatInfo numfmt)
at PdfSharp.Pdf.IO.Lexer.ScanNumber()
at PdfSharp.Pdf.IO.Lexer.ScanNextToken()
at PdfSharp.Pdf.IO.Parser.ParseObject(Symbol stop)
at PdfSharp.Pdf.IO.Parser.ReadDictionary(PdfDictionary dict, Boolean includeReferences)
at PdfSharp.Pdf.IO.Parser.ReadObject(PdfObject pdfObject, PdfObjectID objectID, Boolean includeReferences, Boolean fromObjecStream)
at PdfSharp.Pdf.IO.PdfReader.Open(Stream stream, String password, PdfDocumentOpenMode openmode, PdfPasswordProvider passwordProvider)
at PdfSharp.Pdf.IO.PdfReader.Open(Stream stream, PdfDocumentOpenMode openmode)

Reply with quote  
PostPosted: Sat Dec 08, 2018 7:56 am 
PDFsharp Expert
User avatar

Joined: Wed Dec 09, 2009 8:59 am
Posts: 323
Could be a corrupt PDF file.
Did you make the Adobe Reader test: Open the file with Adobe Reader, then select "Save as...", then try the new copy with PDFsharp.
If that works, then most likely the file is corrupt.

Ă–hmesh Volta ("() => true")
PDFsharp Team Holiday Substitute

Reply with quote  
PostPosted: Tue Dec 11, 2018 9:22 pm 

Joined: Fri Dec 07, 2018 10:40 pm
Posts: 2
I will tried that and I was unable to save the document. I think that is the problem, I will try it and update. Thanks for your response.

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: Google [Bot] and 20 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