Merging TIF files leaves an open file handle and keeps the TIF locked

Merging TIF files leaves an open file handle and keeps the TIF locked

Forum member · Mar 9, 2010
Hi there, I am noticing a problem when merging TIF files into a PDF. If I use the following lines of code: MergeDocument document = new MergeDocument(); TiffFile tiffDoc = new TiffFile(fullpath); document.Pages.Append(tiffDoc.GetDocument().Pages); the tif file that is being merged remains locked after the code executes. This means you cant do anything with the original TIF file until your program is shutdown. When you merge jpgs or bitmaps or other pdfs, those files are not locked, you can do whatever you want with them immediately after you append them. I am running into this problem with ceTe.DynamicPDF.35.dll file version 5.1.2.35 (build 14896).

Re: Merging TIF files leaves an open file handle and keeps the TIF locked

Support · Mar 10, 2010
Hello, Yes, the TiffFile will keep the resources and it is not possible to delete the image immediately. In order to increase the performance to access a specific page from a multi page tiff image we use the image when required. You can use the TiffFile constructor which takes the byte array of the image. You will have to get the byte data of the image and use it in TiffFile. This will allow you to delete the image as the total image is in memory. byte[] data = File.ReadAllBytes(@"C:\Temp\fw9_03.tif"); TiffFile tFile = new TiffFile(data); Document doc = tFile.GetDocument(); File.Delete(@"C:\Temp\fw9_03.tif"); Thanks, ceTe Software Support Team.