PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Value was either too large or too small for an Int64 Import
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3893
Page 1 of 1

Author:  salli [ Fri Dec 07, 2018 10:50 pm ]
Post subject:  Value was either too large or too small for an Int64 Import

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)

Author:  () => true [ Sat Dec 08, 2018 7:56 am ]
Post subject:  Re: Value was either too large or too small for an Int64 Imp

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.

Author:  salli [ Tue Dec 11, 2018 9:22 pm ]
Post subject:  Re: Value was either too large or too small for an Int64 Imp

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.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/