Skip to content

Error when reading a large PDF file #137

Open

Description

@wiltonkkw

Summary of the issue

I want to read a PDF file page by page using PdfReader and writer.GetImportPage() and output to another PDF file. It work perfectly when the file is small than 1G bytes in size.
But have error when reading a large file (say 2G byte with 200k pages)

The large file for testing https://www.filemail.com/d/zooxpazvktiqxpx

Environment

Windows

iTextSharp.LGPLv2.Core version: 3.4.15
.NET Core SDK version: 6
IDE: VS2022

Example code/Steps to reproduce:

var reader = new PdfReader(inputFilename);
var pageCount = reader.NumberOfPages;
for (var pageNo = 1; pageNo < pageCount; pageNo++)
{
   var page = writer.GetImportedPage(reader, pageNo);
  // write to another PDF file
}

When reading a large file, it keep showing the errors in below when instantiating PdfReaer

Output:

Exception message:
Full Stack trace:
Exception thrown: 'System.InvalidOperationException' in iTextSharp.LGPLv2.Core.dll
Exception thrown: 'System.IO.IOException' in iTextSharp.LGPLv2.Core.dll
Exception thrown: 'System.IO.IOException' in iTextSharp.LGPLv2.Core.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in iTextSharp.LGPLv2.Core.dll
Exception thrown: 'System.IO.IOException' in iTextSharp.LGPLv2.Core.dll
Exception thrown: 'System.IO.IOException' in iTextSharp.LGPLv2.Core.dll
Exception thrown: 'System.IO.IOException' in iTextSharp.LGPLv2.Core.dll
Exception thrown: 'System.IO.IOException' in iTextSharp.LGPLv2.Core.dll
Exception thrown: 'System.IO.IOException' in iTextSharp.LGPLv2.Core.dll
Exception thrown: 'System.IO.IOException' in iTextSharp.LGPLv2.Core.dll
Exception thrown: 'System.IO.IOException' in iTextSharp.LGPLv2.Core.dll
Exception thrown: 'System.IO.IOException' in iTextSharp.LGPLv2.Core.dll
Exception thrown: 'System.IO.IOException' in iTextSharp.LGPLv2.Core.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in iTextSharp.LGPLv2.Core.dll
Exception thrown: 'System.IO.IOException' in iTextSharp.LGPLv2.Core.dll
Exception thrown: 'System.IO.IOException' in iTextSharp.LGPLv2.Core.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in iTextSharp.LGPLv2.Core.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in iTextSharp.LGPLv2.Core.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in iTextSharp.LGPLv2.Core.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.IO.IOException' in iTextSharp.LGPLv2.Core.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.FormatException' in System.Private.CoreLib.dll
:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions