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

Free Support Forum - aspose.com

Conversion from HTML to DOC render issue


I have a code block which converts HTML data to DOCX file using aspose. The entire html is being rendered in the doc. But it being truncated. Means the html design is not wrapping up inside a page properly.

Please find the attached files for better understanding my issue.

Code used to convert:

public static void DownloadDoc(string ResponseString, string DownloadDocName)

    License license = new License();

    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);

    MemoryStream stream = new MemoryStream();
    doc.Save(stream, SaveFormat.Docx);
    HttpContext.Current.Response.Buffer = true;
    HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + DownloadDocName.Trim().Replace(" ", "") + "" + DateTime.Now.ToShortDateString().Replace("/", "_") + ".docx");
    HttpContext.Current.Response.ContentType = "application/vnd.ms-word";

Waiting for your response.

Thank You.

Hi Susanna,

Thanks for your inquiry. We have tested the scenario using latest version of Aspose.Words for .NET 17.4 and have not found the shared issue. Please use Aspose.Words for .NET 17.4. We have attached the output document with this post for your kind reference.


Thanks for you reply.

I have downloaded the attached docx file you have sent and opened with Microsoft Word 2007. Still the same problem. Additionally go to print preview and you will see that the contents are truncated. There is one more oddity noticed. If the file is opened with WPS office then it is rendering perfectly but in MS word the problem is occurring.

What we need is that the entire content of the table must wrap inside a A4 sheet. [Check the attached file.]

Please tell us what change is required in the code I have sent previously.

Waiting for your reply.

Hi Susanna,

Thanks for sharing the detail.

We have tested the scenario and have managed to reproduce the same issue at our side. MS Word 2016 displays the table correctly. Please check the attached image. However, MS Word 2007 displays the table incorrectly.

For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-15181. You will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.


Thanks for the reply. I am eagerly waiting for this issue to be resolved.

Hi Susanna,

We will inform you via this forum thread once this issue is resolved. Thanks for your patience.

Hi Susanna,

Thanks for your patience. It is to update you that we have closed the issue (WORDSNET-15181) with “Won’t Fix” resolution. Please use Table.AllowAutoFit property as shown below to get the desired output.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertHtml(File.ReadAllText(MyDir + "htmltoconvert.html"));
doc.FirstSection.Body.Tables[0].AllowAutoFit = false;