PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Aug 18, 2019 2:31 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 
Offline

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.

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

}
ms.Close();
ms.Dispose();

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)


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

Joined: Wed Dec 09, 2009 8:59 am
Posts: 316
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


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

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.


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 8 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:  
cron
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group