PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 9:21 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Thu Mar 12, 2020 2:09 am 
Offline

Joined: Thu Mar 12, 2020 2:03 am
Posts: 1
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. Any thoughts on 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).using pdfsharp nuget package 1.50.5147


Top
 Profile  
Reply with quote  
PostPosted: Thu Mar 12, 2020 4:32 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 909
Location: CCAA
Already discussed on SO:
https://stackoverflow.com/a/60639529/162529

PDFsharp reads the whole document when you call PdfReader.Open() and appending .Pages[0] does not reduce the required memory at all.

If your code runs in 32 bit mode then try switching to 64 bit mode to break the 2 GB barrier.

If that does not help then consider upgrading your Azure model to include more memory or maybe try a different tool other than PDFsharp.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 131 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:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group