Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Thu Dec 14, 2017 2:15 pm

Hi, I get a strange error during converting to HTML

using (MemoryStream memoryStream = new MemoryStream())
{
using (MemoryStream outStream = new MemoryStream())
{
memoryStream.Write(templateContent, 0, templateContent.Length);
Document document = new Document();
document.HtmlExportOptions.ImageEmbedded = false;
document.LoadFromStream(memoryStream, FileFormat.Docx);
document.SaveToStream(outStream, FileFormat.Html); <----Line throw error
}
}

System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
at spr⍰.ᜀ(Image A_0, String A_1, Int32 A_2, Int32 A_3, Boolean A_4, ImageFormat A_5)
at spr⍰.ᜀ(DocPicture A_0, Paragraph A_1)
at spr⍰.ᜀ(ParagraphBase A_0, Boolean& A_1, ParagraphBase& A_2)
at spr⍰.ᜄ(Paragraph A_0)
at spr⍰.ᜀ(Section A_0)
at spr⍰.ᜂ(Document A_0)
at spr⍰.ᜁ(Document A_0, String A_1)
at spr⍰.ᜀ(Document A_0, Stream A_1)


How to solve it?

svendelboe
 
Posts: 4
Joined: Wed Dec 13, 2017 8:37 am

Fri Dec 15, 2017 2:01 am

Hello,

Thanks for your inquiry. After an initial test, I was unable to reproduce the issue on my side. To help us investigate further, please share us with your Word file? You could attach it here or send to support@e-iceblue.com.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Fri Dec 15, 2017 9:24 am

I have 2 MVC applications which run on the same IIS server. One application has no problems with this code, where another one has. Both applications reading the same word document. When I am reading error I can se that it happends her
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
It look like spire.doc tries to save something to the fysical location, because method takes as parameter filename. So it could be problem with service user rights? Where does spire.doc saves data?

svendelboe
 
Posts: 4
Joined: Wed Dec 13, 2017 8:37 am

Fri Dec 15, 2017 10:22 am

Hello,

Please tell us if the two applications will both save the Word document to Html stream and one of them has no problem.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Fri Dec 15, 2017 11:01 am

One of my application is for testing and another for production. They both works with the same data, but each application runs under own user. Documents are the same and are at the same location. Application should load the word document from drive convet it to html and show in a view to user. So they both loading it to memorystream. Basicly to be sure I copied whole test folder to production, so the code is 100% the same. But the error comes only in production and no problem in test.

svendelboe
 
Posts: 4
Joined: Wed Dec 13, 2017 8:37 am

Mon Dec 18, 2017 3:59 am

Hello,

Sorry for the late reply. Actually, the images in the document will be saved under a relative path while setting ImageEmbedded = false, it seems that the path is not correct or you don't have the write permission under the path. Please set the saving path of the images and try again.
Code: Select all
                    Document document = new Document();
                    document.LoadFromStream(memoryStream, FileFormat.Docx);
                    document.HtmlExportOptions.ImageEmbedded = false;
                    document.HtmlExportOptions.ImagesPath = @"C:\";
                    document.SaveToStream(outStream, FileFormat.Html);


Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Mon Dec 18, 2017 8:32 am

Than you very much for help. It worked!!!

svendelboe
 
Posts: 4
Joined: Wed Dec 13, 2017 8:37 am

Mon Dec 18, 2017 9:55 am

Hello,

Glad to hear that. If there is any other question, please feel free to contact us.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Return to Spire.Doc