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

Free Support Forum - aspose.com

HTML to PDF Conversion - Table-layout: fixed is not working

Hello,
has there been progress on PDFNET-42356? I am running into the same issue in Aspose Java. The tables in my HTML have fixed width which renders just fine in browsers but is ignored by Aspose.
If there is another way to force Aspose to respect the fixed col width please let me know.

Best Regards

See attached zip, the expected result is as Chrome would show it. I’ve tested with 22.3 and it does not change anything.
aspose-tests.zip (57.2 KB)

@yvesb I am afraid it is not always possible to retain HTML formatting in MS Word document. It seems in your code you use code like the following to convert your document tp PDF:

Document doc = new Document("C:\\Temp\\aspose-table-col-size.html");

Iterable<Table> tables = doc.getChildNodes(NodeType.TABLE, true);
for (Table t : tables)
    t.autoFit(AutoFitBehavior.FIXED_COLUMN_WIDTHS);

doc.save("C:\\Temp\\out_FIXED_COLUMN_WIDTHS.pdf");

Here is output produced by this code on my side: out_FIXED_COLUMN_WIDTHS.pdf (26.9 KB)
The output is similar to what MS Word produces: msw.pdf (7.2 KB)

If do not set additional properties upon conversion to PDF, Aspose.Words produces the following output: out.pdf (27.1 KB)

Document doc = new Document("C:\\Temp\\aspose-table-col-size.html");
doc.save("C:\\Temp\\out.pdf");

In your HTML you use column width, but in MS Word table there is no concept of column, each row in the table is independent and can contain any number of cells of any width. In your case, Aspose.Words by default takes <table style="width: 100%; table-layout: fixed;"> in account and fits the whole table with to page. Which is an expected behavior.