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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Freeing document resources

Thread ID:

Created:

Updated:

Platform:

Replies:

78676 Dec 23,2008 11:38 AM UTC Dec 23,2008 12:56 PM UTC WinForms 4
loading
Tags: PDF
Lukasz Dejneka
Asked On December 23, 2008 11:38 AM UTC

Hi

I'm evaluating the trial version of Essential PDF for usage with our tool for software integration.

I need to write a proof of concept dll which will serve as a translator between your dll's and our app.

One of the problems that came up is freeing resources used by Essential PDF.

C# code example:

public string GetFieldNameByIndex(int index)
{
//load document
PdfLoadedDocument doc = new PdfLoadedDocument(_pdfLoadPath);
string name = doc.Form.Fields[index].Name;
doc.Close();
return name;
}
public int GetFieldCount()
{
//load document
PdfLoadedDocument doc = new PdfLoadedDocument(_pdfLoadPath);
int count = doc.Form.Fields.Count;
doc.Close();
return count;
}


Above 2 public methods are visible in our application. I can invoke any of them once and they run as intended. But when I try to run them one after another first runs correctly, but second one gives an error:

The process cannot access the file 'C:\newformform.pdf' because it is being used by another process.

How do I free the document handled by Essential PDF libraries?

Thank you.



Geetha M [Syncfusion]
Replied On December 23, 2008 11:55 AM UTC

Hi Lukasz,

Thank you for your interest in Syncfusion products.

When you load a file, it actually loads in the memory and be there till the operations are performed and will be free from the memory only when you call doc.Close();. So you may not allowed / it is not possible to open the file that is already opened. This is equivalent to open a file when it is already opened using a different application. In order to avoid the problem, you could open the file once and close it after manipulation; and then open it again for the second call.

Please let me know if you have any other questions.

Regards,
Geetha


Lukasz Dejneka
Replied On December 23, 2008 12:13 PM UTC

Hi

Thank you for your answer.

The problem is that I already call doc.close() after operations are finished, as you can see from the code snippet I included. Apparently even when I call it, the resource is still unavailable.





Geetha M [Syncfusion]
Replied On December 23, 2008 12:26 PM UTC

Hi Lukasz,

Thank you for the update.

I was able to see the issue.

Please use doc.Close(true); instead of doc.Close(); to solve it.

Regards,
Geetha


Lukasz Dejneka
Replied On December 23, 2008 12:56 PM UTC

Hi

Thank you kindly for your help. Resources are freed now properly.

With regards and holiday best wishes.

Lukasz


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;