PDFsharp & MigraDoc Foundation

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

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Big file generation
PostPosted: Thu Jan 11, 2018 4:59 pm 
Offline

Joined: Thu Jan 11, 2018 4:40 pm
Posts: 2
Hi, This is my first project using MigraDoc.
I need to generate a large pdf file with a huge table. The table might have up to 2 million records. Is there a way to do that?
Currently I am getting out of memory exception long before I add all rows to the table.
I am not attaching any code because at that point it is just a simplified version of the Invoice-sample from pdfsharp wiki.

I have a second question. I don't see a dispose method on MigraDoc.DocumentObjectModel.Document or MigraDoc.Rendering.PdfDocumentRenderer, how do I go about freeing the memory once I am done rendering?


Top
 Profile  
Reply with quote  
 Post subject: Re: Big file generation
PostPosted: Thu Jan 11, 2018 8:47 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 909
Location: CCAA
Hi!
panayot.p wrote:
I need to generate a large pdf file with a huge table. The table might have up to 2 million records. Is there a way to do that?
I don't know.
Make sure your app is running in 64 bit mode. Apps in 32 bit mode are limited to 2 GiB of RAM - even on computers with 32 or 64 GiB of RAM.


panayot.p wrote:
I don't see a dispose method on MigraDoc.DocumentObjectModel.Document or MigraDoc.Rendering.PdfDocumentRenderer, how do I go about freeing the memory once I am done rendering?
The IDisposable pattern makes sense for classes that use limited resources like file handles.
For POCO classes this is not needed. The Garbage Collector will remove the object when all references are gone.
Just set your variable to "null".

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


Top
 Profile  
Reply with quote  
 Post subject: Re: Big file generation
PostPosted: Fri Jan 12, 2018 8:34 am 
Offline

Joined: Thu Jan 11, 2018 4:40 pm
Posts: 2
Thank you for the fast replay.

I was wondering if this can be done smarter. Maybe by generating a few pages at a time and saving them and then continuing with the next batch instead of trying to render the whole document at once.
With the memory requirements I am seeing while generating a smaller pdf I calculated that I will need around 15 GB even before I call RenderDocument so this is not really viable in my case. I really need some sort of a page by page rendering.


Top
 Profile  
Reply with quote  
 Post subject: Re: Big file generation
PostPosted: Fri Jan 12, 2018 3:04 pm 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 909
Location: CCAA
panayot.p wrote:
I really need some sort of a page by page rendering.
Just do it.
The technique shown in this sample can also be used to create a huge document in small batches:
viewtopic.php?f=8&t=3172
Maybe not do it page by page, but in batches of 20 or 50 pages or so.

You write you have one really huge table. This will make things a bit complicated if table rows have varying heights.
It's simple if all rows have the same height.

You can even close the PDFsharp document from time to time (maybe every 500 pages) to free the PDFsharp memory, too.

_________________
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  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 190 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