PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sat Nov 17, 2018 12:35 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: Tue Jul 01, 2008 8:11 am 
Offline

Joined: Tue Jul 01, 2008 7:29 am
Posts: 3
Code:
MigraDoc.DocumentObjectModel.Tables.Cell.AddImage(string fileName)


This function leaves the image stream open which makes it impossible to delete the image file while the app is still running!

Why don't you implement a constructor of Image class with a stream parameter instead of (or in addition to) the path parameter?

I have all my images stored in a databese as byte[].
I have to save them as image files,
then build the pdf file
and then when i try to clean up and delete the images
i get an exception that the files are still in use.
even though the pdf file is already closed.

the bug is not in my code because when I save the byte[] to image files
and skip the part when I add the image to the pdf,
all images are successfully deleted.

Other than that I wish to thank you for this wonderful tool.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Jul 14, 2008 8:29 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 2875
Location: Cologne, Germany
MigraDoc needs a file - this is by design.
We could accept a stream parameter and create a temporary file internally.

Images are cached. They will be included only once in the PDF file even if they appear at multiple locations.
This cache persists even if the PDF file is closed.
This cache would not work (or would require special treatment) with files created from streams.

But I do hope that the file handle will be closed if you dispose the PDFsharp and MigraDoc objects (you may have to call GC.WaitForPendingFinalizers()).
Sorry, but I don't have time to test this right now.

_________________
Regards
Thomas Hoevel
PDFsharp Team


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: No registered users and 2 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