PDFsharp & MigraDoc Foundation

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

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Feb 24, 2010 3:57 pm 
Offline

Joined: Mon Jan 04, 2010 2:44 pm
Posts: 23
There exists a PDFDocument(Stream outputStream) constructor.
The documentation says "Creates a new PDF document using the specified stream. To open an existing PDF file, use the PdfReader class." Given the second sentence and the parameter name "outputStream", I assumed that the constructor configures the document to dump the PDF to that stream (in my case, a FileStream) least every couple hundred pages/KB. (Also in the thought process: If PDFDocument(Stream)/Close() has the same behaviour as PDFDocument()/Save(Stream, false), why do both exist?)

However, there's no evidence (either behaviourly or in the source) that it actually does so.

Is there any way to get the behaviour I was expecting: a PDFDocument that gets written to the passed Stream as I write to the document? Currently, I'm creating documents that manage to consume over 1 GB in memory, which makes me concerned that I might run out of 32-bit address space sometime soon.
I realize that this requires some restrictions on what changes I can make, but that's not an issue; once I've drawn on a page, I never modify that drawing except to draw on top of it, and once I add a new page, I never modify any previous page.

I could, if necessary, count up how many objects of what sorts I will be drawing -- I already count pages before I do any drawing, and I could relatively easily count what I draw on those pages, since I have to touch them all anyway.


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 24, 2010 4:39 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3096
Location: Cologne, Germany
PDFsharp was designed to keep everything in memory.

With large files this can become a problem

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Thu Feb 25, 2010 2:50 pm 
Offline

Joined: Thu Feb 25, 2010 2:44 pm
Posts: 14
So then let me confirm this, since we are actually running into an Out of Memory exception when dealing with files that have lots of full-page images: Is there no way to "progressively" write out a PDF with PDFsharp? In other words, create a PdfDocument, add pages to it, and then tell it to write what it currently has but not finalize the document, dispose of the current pages (or at least their content streams) to free up memory, add more pages, write them, etc?


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

All times are UTC


Who is online

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