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

Free Support Forum - aspose.com

Tables coming outside paper & printarea


I have created a book from a mass of html articles. I used the inserthml function to insert everything into the worddocument.

The problem i’m still facing is that some tables are to wide to fit the paper. I tried to remove the width property in the html before inserting, but then, lots of tables are very ugly looking.

Is there a possibility to check all tables in the document who are to large and fit them on the page?
It is no problem for me if the fontsize will be reduced.

for example, you can export just 1 article on this page, by clicking the MSWord image: http://vademecum3.vandenbroele.be/entity.aspx?id=122

Most articles are okay, but some of them like this one, are causing lots of troubles.



Thanks for your request. Could you please attach simple HTML document and your code, which you use to insert html? I will try to reproduce the issue on my side and provide you more information.

Best regards,


Please find the code attached.
Export.cs is the class containing all functions to export the book.
It’s actually just the inserthtml function that does it. The rest is other stuff related to the book.

You’ll see that the html tables are containing a width property, i know this should be smaller, but it is also used to display on a webpage and if the totalwidth is smaller than the page, the width-property is no problem.

So, i just want to fit tables on the page who are to large. Possible ?


Thank you for additional information. I managed to reproduce the problem on my side. Your request has been linked to the appropriate issue. You will be notified as soon as it is resolved. As a workaround, please try using the following code:

//Read HTML form file.
string html = File.ReadAllText("html.html");
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, "", LoadFormat.Html, string.Empty);

Hope this helps.

Best regards,


Thanks for the reply, but i don’t understand your workaround, i think the given code has nothing to do with the problem.

Is it possible to show how i can loop in al tables en see if the total width is to large, and decrease it ?
Any ideas?


Thanks for your request. As I can see, you read HTML string then insert this string into the document and save this document. The code above you can use instead InsertHtml method. In my code I read HTML to stream and load to the document. If you have lot of HTML documents you can load each of them to documents and then concatenate these documents using AppendDocument method.

There is no direct way to set width of a table using Aspose.Words.

Best regards,


So, it seems to me that the given code is not the solution i search for.
If i can’t read and reset the width of the table, maybe i can loop in the tables and give them a smaller font ?

I tried to use this code, but i can’t find the properties to reduce the font size in the table:
Is it possible to reduce the font size in all tables ?

TableCollection tables = section.Body.Tables;
foreach (Table table in tables)
    table. somefontsizeproperty = 10 ??


Thanks for your request. In this case, it is better to use DocumentVisitor to achieve this. Here is code:

//Open document
Document sourceDoc = new Document(@"Test\yourDoc.doc");
// Create an object that inherits from the DocumentVisitor class.
FontSizeChanger changer = new FontSizeChanger(8);
//Get the model to accept a visitor.
// The model will iterate through itself by calling the corresponding methods
// on the visitor object (this is called visiting).
//Save output document

FontSizeChanger class is attached.

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.