Free Support Forum - aspose.com

Issue with table column widths in HTML page

Hi, I really need some help. Any Aspose aficionados out there who know this stuff? J<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

We’re upgrading our web app’s use of Aspose Words from v10.4 to v11.3 but we’ve hit a sticky problem and I can’t find a solution. Can you help?

How we use Aspose Words

Our web application delivers a set of reports online and offline and we use Aspose Words as a key part of this.

We’re only having issues with the online set and these must be delivered as HTML or a Word or PDF document.

To do this we always initially create our reports using Aspose into a Word document.

For an online report the Word document is saved as an HTML file and embedded in to a container element on the web page. A web page then invokes a download of the Word file.

If the report is required in PDF then it is saved as a PDF and again a web page invokes a download of the PDF file

In each case, the reports are made up of a combination of reporting sections including word tables and this is where the main problem arises under the 2 different versions of the product.

Here’s how we used Word tables in v10.4

The report when built through the API uses an A4 page setup with default margins.

Tables are created in this report generally with several columns using a simple ratio to define column widths.

To work out each output width of a column (simplified example):

Table A has 6 columns with a ratio of 1 for each column. Page width (A4) = 700, Left Margin = 50, Right Margin = 50

So Column Width = 600 div 6 = Each table column is 100 pixels wide. Simples.

Now, when I output numerous rows of data into the table, the columns widths are maintained in the Aspose Word document so it stays nice and uniform.

When I then save this doc as HTML output for our online reports, the table column widths all stay within the confines of the defined widths.

Sometimes column content is added using the InsertHTML method and this can alter the column widths, however in most cases the defined widths are upheld.

Word tables in v11.3 – here’s the problem

Using the same example, when I output the online HTML report using v11.3, the table now uses the whole page width and the 6 column widths seem forced to percentage-based widths.

Now this is not a problem provided I do not use the InsertHTML method. When I do this the column widths are ignored, even if the inserted HTML content does not use the whole width.

It just seems to do it own thing.

So, I’m stuck. I can’t avoid using InsertHTML and I don’t want to revert back to v10.4. So, is there:

a) Any way of forcing the Save to HTML format of Aspose Word in v11.3 to adopt a similar output as used successfully in v10.4 or

b) Somehow preventing the InsertHTML method from filling the column width

c) Any other genius solutions that might just work?

Thanks in anticipation ! Mattv

Hi Matthew,


Thanks for your inquiry. Please note that Aspose.Words tries to mimic the same behavior as MS Word do. Upon processing HTML, some features of HTML might be lost. You can find a list of limitations upon HTML exporting/importing here:
http://www.aspose.com/docs/display/wordsnet/Load+in+the+HTML+%28.HTML%2C+.XHTML%2C+.MHTML%29+Format
http://www.aspose.com/docs/display/wordsnet/Save+in+the+HTML+%28.HTML%2C+.XHTML%2C+.MHTML%29+Format

I would suggest you please upgrade to the latest version (v13.2.0) from here and let us know how it goes on your side. If the problem still remains, please share following detail for investigation purposes.

What environment are you running on?

  • OS (Windows Version or Linux Version)
  • Architecture (32 / 64 bit)
  • .NET Framework version
  • Please supply us with the code from your application that is causing the issue
  • Please supply us with the input document that is causing the issue
  • Please supply us with the output document showing the undesired behavior
  • Please supply us with the expected document showing the desired behavior