We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.Words V6.1.0.0- DocumentBuilder.InsertHtml problem for Asian languages

Hi there,

I'm encouterning problem when I use DocumentBuilder.InsertHtml to create tables for Chinese. This Html file contains table with Chinese text and table is good in layout. When converting into Doc file, the table cells becomes "no wrap", which contains too long text on one line. This only happens with Asian languages.

Here is my test code:

//Below does not work for html file with Asian languages

StreamReader sr = new StreamReader("c:\\temp\\wholetext_cn.htm");
string html = sb.ToString();

Aspose.Words.DocumentBuilder docBuilder = new Aspose.Words.DocumentBuilder();


Aspose.Words.Document doc = docBuilder.Document;
doc.Save("wholetext_cnnew.doc", Aspose.Words.SaveFormat.Doc, Aspose.Words.SaveType.OpenInWord, Response);

//Below works well for html file with Asian languages

Aspose.Words.Document newDoc = new Aspose.Words.Document("c:\\temp\\wholetext_cn.htm",LoadFormat.Html,null);

newDoc.Save("c:\\temp\\wholetext_cn.doc", SaveFormat.Doc);

newDoc.Save("wholetext_cn.doc", Aspose.Words.SaveFormat.Doc, Aspose.Words.SaveType.OpenInWord, Response);

Urgent help needed. Thank you very much.

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. I managed to reproduce the problem on my side and I create new issue #7413 in our defect database.

As a workaround you can try inserting Document instead HTML. Please see the following link to learn how to insert one document into another document.


Best regards.

Hello Mohammed!
Have you found a solution of this problem (#7413)? Naturally you can either insert one document at the specified position to another one. Or you can first import the HTML using Aspose.Words.Document constuctor and then process it (in particular insert to another one).
Technical reason of the difference between imported and inserted versions is in different document defaults. For instance you can see that page setup (margins) differs. This afftects table layout. And it doesn't matter whether Asian languages are used or not. I reproduced the same with a pure English sample. When you create a document from scratch, Aspose.Words applies some additional logic because the document cannot be "completely empty". Only after that you insert an HTML table.
If this issue is really so important for you then we'll investigate it further. But this is difficult (almost impossible) to obtain identical results after import and insertion. Please provide your expertise.

H Aspose Team,

Any update on this? Actualy, I must use InsertHtml method to generate Japanese PDF file because the html content is from a web page. Otherwise, if html content is from a file,I can use other method to save correct PDF file.

the code is like this:

StringBuilder builder = new StringBuilder();

StringWriter writer = new StringWriter(builder);

Server.Execute(string.Format("ClientQuote.aspx?HeaderNumber={0 }", HeaderNumber), writer);

string html = builder.ToString();


<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. You can create Document from html string. Please see the following code:

//Convert string to byte array

byte[] docBytes = System.Text.Encoding.UTF8.GetBytes(html);

//Create MemoryStream from byte array

MemoryStream docStream = new MemoryStream(docBytes);

//Now we can open Word document from stream

Document subDoc = new Document(docStream, baseUrl, LoadFormat.Html, string.Empty);

Hope this helps.

Best regards.

What does baseUrl stands for in you sample code? thanks.


<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. The baseUri parameter is used to resolve relative URIs found in the document to absolute URIs. Please see the following link for more information:


Best regards.

The issues you have found earlier (filed as WORDSNET-2057) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.