We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Essential pdf does not release file handle after save

I have downloaded and installed the latest version of essential back office. I have created a simple asp.net project in visual studio 2005, and using .net framework 2.0. All necessary references have been added. The pdf I am generating is a simple pdf with some text, border and images. The pdf generates fine. When I run the project, visual studio creates an ad-hoc webserver to run, test and debug the asp.net web application. The pdf is created as expected and I can open and view the pdf fine. Pages on iis is created on client connect/request and destroyed as soon as the response is sent to the client browser. The PDFDocument is created within the asp.net page in this project. However, after generating the pdf, and after the asp.net page has been destroyed, there are unclosed handles to the image files used in the pdf!! This is a problem! I cannot understand why the webserver/essential pdf still keeps open handles to the image files used for a pdf that is already written to disk and finished. And also after the page has been destroyed. This causes a problem because now it is not possible to delete the images because of the open handles, windows generates an error if a delete is attempted (because of the open handles).
Is there something I should do to have essential pdf close the handles? Is this a bug? What can I do to work around the issue? Calling dispose on the System.Drawing.Image has no effect, and the issue remains. This is a big problem for me! I would greatly appreciate an answer to this soon.

3 Replies

MW Melba Winshia Syncfusion Team September 5, 2007 01:59 PM UTC

Hi Steiner,

Sorry for the delay in responding.

The problem here is that Essential PDF holds reference to the image till the PDF document is saved to disk but fails to dispose it after that. You could avoid this problem by manually disposing the image after saving the PDF document.

[C#]

//Create a new PDF Document. The pdfDoc object represents the PDF document.
//This document has one page by default and additional pages have to be added.
PDFDocument pdfDoc = new PDFDocument();

//Adding a font that can be used to draw Text inside the PDF document.
//Using the Predefined fonts to draw the text.
IPDFFont pdfFont = pdfDoc.Fonts.Add( FontBaseFamily.Courier );

//Access the first page in the PDFDocuments''s pages collection
IPDFPage firstPage = pdfDoc.Pages[0];

Bitmap bmp = new Bitmap("sunset.bmp");
firstPage.Graphics.DrawImage(new PointF(0,0),bmp);

//Save the PDF Document to disk
pdfDoc.Save("Sample.pdf",Response,HttpReadType.Open);

bmp.Dispose();

And also, please refer the below document to get more details regarding this issue.

http://support.microsoft.com/?id=814675

Please try this and let me know if the problem still exists.

Thanks,
Melba




ST Steinar September 5, 2007 04:29 PM UTC

Thank you for your response. This is the same approach I arrived at. However, I must say that the syncfusion pdf component should release it's resources properly. Will poor resource management be corrected in future releases?


MW Melba Winshia Syncfusion Team September 7, 2007 01:24 PM UTC

Hi Steiner,

Thank you for the update.

The question you’ve posted has raised some very significant issues, as this might be a Feature Request. We will get back to you within 2 business days with a complete response after due analysis of these issues.

Thank you for your patience.

Regards,
Melba

Loader.
Live Chat Icon For mobile
Up arrow icon