Hello,
I am adding images to pages using the PageElements.Image constructor which accepts the file name of an image file. Long after the document has been drawn (and all objects have fallen out of scope) I find that the image file previously loaded is still "open" and can't be deleted. After the application is terminated, the file is finally closed. I've tried to find some kind of "close", "dispose", or any other way to get documents, pages, or images to free themselves but have not found anything.
Thanks!
Image files staying open
Re: Image files staying open
Support · Dec 20, 2006Hello,
If you are using JPEG, PNG or GIF images you should not a problem deleting the file after it is used within the Image constructor. Can you please let us know what image format are you using?
Thanks,
ceTe Software Support Team
Re: Image files staying open
Forum member · Dec 20, 2006Sorry, I should have included that information. I am loading TIFF files.
Re: Image files staying open
Support · Dec 20, 2006Hello,
In case of TIFF files, you will have to load the TIFF image using the TiffFile object and then call the FirstImage property of the TiffFile object in the Image constructor and then you can call the close() method of the TiffFile object. Below is the sample C# code that will fix your problem:
TiffFile file = new TiffFile(@"C:\Temp\TIFF\test.tif");
Image image = new Image( file.FirstImage,0,0 );
page.Elements.Add(image);
document.Pages.Add( page );
document.DrawToWeb( "HelloWorld.pdf" );
file.Close();
File.Delete(@"C:\Temp\TIFF\test.tif");
Thanks,
ceTe Software Support Team
Re: Image files staying open
Forum member · Dec 20, 2006That worked. Thank you very much. Are there any other resources (that you can think of) that need to be "closed" explicitly?
Re: Image files staying open
Support · Dec 20, 2006Hello,
No, I can not think of any other resources in particular that required to be closed.
Thanks,
ceTe Software Support Team