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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Save As and Close PDF

Thread ID:

Created:

Updated:

Platform:

Replies:

73198 Apr 24,2008 02:03 PM UTC Apr 28,2008 03:49 PM UTC ASP.NET Web Forms (Classic) 4
loading
Tags: PDF
Joe Hakooz
Asked On April 24, 2008 02:03 PM UTC

Hi,
I'm using Essential PDF 6.2.0.32, ASP.NET and VB.

I am tying to open an existing PDF, "stamp" it with text, then save the document to disk as a new document. I almost have this working but the starting document won't close properly. I have to wait several minutes before trying to repeat the process.

Here is my simplified VB:
Dim filename As String = Server.MapPath("certs/cert_template.pdf")
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument(filename)
Dim output As String = Server.MapPath("certs/unique_name.pdf")
ldoc.Save(output)
ldoc.Close()

This works fine the first time. If I fire the code a second time I receive the error "The process cannot access the file '......\cert_template.pdf' because it is being used by another process."

It appears that ldoc.Close() is not working properly.

Any idea how to fully close the PDF?
Thanks


Joe Hakooz
Replied On April 24, 2008 08:00 PM UTC

Ok, I found a hacktastic solution. I'd still appreciate a reply from the pros since my solution can't possibly be best practice... and it appears that "pdfLoadedDocument.close()" doesn't work.

Instead of loading a file string, I'm loading a Stream. Then I use ASP.NET code to close the Stream when done. Here is my updated code:

Dim filename As Stream = New FileStream(Server.MapPath("certs/cert_template.pdf"), FileMode.Open)
Dim ldoc As PdfLoadedDocument = New PdfLoadedDocument(filename)
Dim output As String = Server.MapPath("certs/unique_name.pdf")
ldoc.Save(output)
ldoc.Close() ' Not sure that this does anything
filename.Close() ' This one works

Hope this helps


Bhuvaneswari P [Syncfusion]
Replied On April 25, 2008 07:14 AM UTC

Hi Joe,

Thank you for your interest in Syncfusion products.

I can able to reproduce the issue. The issue mentioned here is suspected to be a defect and we have sent this to our development team for more analysis. We will update you once we get back from our development team.

Untill the issue fixed, please use the stream option.

Thank you for your patience.

Regards,
Bhuvana


Bhuvaneswari P [Syncfusion]
Replied On April 28, 2008 09:18 AM UTC

Hi Joe,

Use the below overload which will release all the objects.

ldoc.Close(true);

Please let me know if you need any further assistance.

Regards,
Bhuvana


Joe Hakooz
Replied On April 28, 2008 03:49 PM UTC

Hmmm... Thought I tried that but guess not.
It works!

Thanks for your help.


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

;