I have a fairly large PDF document (more than 1 GB) but I am only concerned with the first page of it. I was doing the following in order to avoid taking complete PDF in memory.
PdfPage inputpdf = PdfReader.Open(filepath).Pages[0];
But even this is not working and I am getting system out of memory exception every other time. Anyone have any idea how to work with large file without storing the complete information in memory. All I am looking for is one page.
Below is stack trace.
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at PdfSharp.Pdf.IO.Lexer.ReadStream(Int32 length)
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(String path, String password, PdfDocumentOpenMode openmode, PdfPasswordProvider provider)
P.S. I am working on .NET Core, Azure function EP1 model. (3.5 GB memory)