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

Int32 overflow when opening PDF files > 2 GB
https://forum.pdfsharp.net/viewtopic.php?f=3&t=4287
Page 1 of 1

Author:  toubsen [ Wed Sep 29, 2021 11:44 am ]
Post subject:  Int32 overflow when opening PDF files > 2 GB

When opening a PDF file which is > 2GB in size, the following exception is thrown
Code:
Unhandled Exception: System.ArgumentOutOfRangeException: Non-negative number required.
Parameter name: value
   at System.IO.FileStream.set_Position(Int64 value)
   at PdfSharp.Pdf.IO.Lexer.ReadRawString(Int32 position, Int32 length)
   at PdfSharp.Pdf.IO.Parser.ReadTrailer()
   at PdfSharp.Pdf.IO.PdfReader.Open(Stream stream, String password, PdfDocumentOpenMode openmode, PdfPasswordProvider passwordProvider)
   at PdfSharp.Pdf.IO.PdfReader.Open(Stream stream, PdfDocumentOpenMode openmode)


From the stack trace it looks like PDFSharp internally is only working with 32bit ints which would lead to an overflow with this file size.

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