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

Free Support Forum - aspose.com

Table renders outside the page after Html to docx conversion using .NET

html formatting gets disturbed , header bar goes outside the page width when html gets converted to docx. The issue is strange because when there are less number of pages the converted docx is fine but when the html length (no of pages ) increases the docx formatting gets very disturbed.htmlToWordFormatting.PNG (14.9 KB)


Could you please attach your input HTML document here for testing? We will investigate the issue on our side and provide you more information.

The Html and respective docx has been attached

html&docx.zip (39.4 KB)


In your case, we suggest you please use the following code example to achieve your requirement.

Document doc = new Document(MyDir + "Document.html");
foreach (Table table in doc.FirstSection.Body.Tables)
doc.Save(MyDir + "20.3.docx");

Moreover, you can change the orientation of page to landscape for better output.

doc.FirstSection.PageSetup.Orientation = Orientation.Landscape;

We cannot change the code, can you tell anything in Html / Css which can resolve this issue?


Please note that Aspose.Words mimics the behavior of MS Word. If you open your HTML in MS Word and convert it to DOCX, you will get the same output. To get the desired output, please use the shared code in my previous post.

If you do not want to use the shared code, please modify the table’s and cells’ width according to your requirement.

I am facing the similar issue after conversion to docx, the html has the spaces but these spaces do not reflect in the respective docx.The files has been attached for the reference.Kindly suggest the possible solution.

CoverPage.zip (26.6 KB)


You are facing the space issue because there is no page concept in HTML document. We suggest you please convert your document to HtmlFixed format instead of HTML format. Hope this helps you.