Spire.Doc for .NET is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files from any .NET platform (C#, VB.NET, ASP.NET, .NET Core) with fast and high quality performance.

Thu Apr 04, 2013 8:45 am

Hi,
we are having problems with image files that are blocked by the process of our web application.

After several tests we are almost sure that this is often caused by the export process in Word and PDF (spire.doc) in this point:

Code: Select all
p_prod_foto_desc.AppendPicture(System.Drawing.Image.FromFile(path_foto));


We have therefore better to rewrite the method to be able to impose the release of the resource:

Code: Select all
Image im = System.Drawing.Image.FromFile(path_foto);
p_prod_foto_desc.AppendPicture(im);
im.Dispose();


The problem is that the method "Dispose ()" does go wrong your library (exporting both in word and in pdf):

Exception Details: System.ArgumentException: Parameter is not valid.

Source Error: document.SaveToFile(codice_offerta.Replace("/", "_").Replace(".", "") + ".docx", FileFormat.Docx2010, Response, HttpContentType.Attachment);


We need to use this method in order to avoid that the application takes locked system resources (image file). Or you have some alternative method to achieve the same result? Thanks

info@isis.it
 
Posts: 20
Joined: Thu Sep 27, 2012 9:01 am

Thu Apr 04, 2013 9:41 am

Hello,

Thanks for your inquiry.
Please try the code snippet below. Hope it can help you.
Code: Select all
              MemoryStream ms = new MemoryStream(File.ReadAllBytes(path_foto));       
              Image im = System.Drawing.Image.FromStream(ms);
              p_prod_foto_desc.AppendPicture(im);


If you still have this issue, please tell us.

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2275
Joined: Wed Jun 27, 2012 8:50 am

Fri Apr 05, 2013 11:12 am

Hi,
thanks for the support. Let's try it this way and test if everything is working correctly.

Best Regards

info@isis.it
 
Posts: 20
Joined: Thu Sep 27, 2012 9:01 am

Wed Apr 10, 2013 2:13 am

Hello,

Do you try the code? Does it solve your issue?
Please give us a feedback at your early convenience. Thanks!

Best Regards,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2275
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Doc