PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

ximage not releasing source file
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3688
Page 1 of 1

Author:  miken99 [ Wed Nov 08, 2017 4:30 pm ]
Post subject:  ximage not releasing source file

The cause of this issue was VS2008. When i made a second copy of my code referencing pdfsharp, it worked! The first copy must have been corrrupted in some way and it prevented release of the source files. I can say for sure now that the issue is resolved.

I am trying to use pdfsharp to write a pdf that contains text and images. I was doing really well until I ran into a problem related to the source images not being released after creating the pdf’s using ximage.

I have read through the forum and this is a pervasive thread and I do not believe there is a good answer so far. It is suggested in the posts that version 1.5 takes care of the problem but I have upgraded to version 1.5 from 1.3 and can say that it did not help. The problem exists in 1.5 as well.

I am not a c# programmer so I am using the Nuget download of Pdfsharp-gdi.dll - Version 1.50.4619.0

My environment is vs2008 and my code is in vb.net. It looks like this

Dim s3image As XImage = XImage.FromFile("saved2.bmp")

gfx1.DrawImage(s3image, 20, 65, 241, 185)
‘add more elements to the pdf here‘
s3image.Dispose()

The above code works – the image is produced on the pdf. However, after running this code I can’t delete. rename or overwrite the ‘saved2.bmp’ because it is now locked.

Am I missing something? Or does anyone have a ximage.fromstream example I could follow?
I can send an example vb.net project with this issue if that would be of help. It sounds like it is a well known issue in the community hopefully with a well known solution.

Author:  TH-Soft [ Wed Nov 08, 2017 9:34 pm ]
Post subject:  Re: ximage not releasing source file

Hi!

IIRC there was a problem with the WPF build 1.32 not releasing image files. This problem was resolved with version 1.50.
So maybe try the WPF build.

If you are using images from temporary files: Why not use MemoryStream instead of a temporary file? No problem with file locks and better performance.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/