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

Free Support Forum - aspose.com

Table layout issues when converting to PDF -- columns too narrow

We are converting the attached html file to PDF, but the generated table columns are too narrow.
Any ideas?

This is what we link against:

<groupId>com.aspose.words</groupId>
<artifactId>Aspose.Words.jdk16</artifactId>
<version>15.5.0</version>

Thanks,
–Margaret

Hi Margaret,

Thanks for your inquiry. Please note that Aspose.Words mimics the same behavior as MS Word does. If you load the same html in MS Word, table’s contents are moved outside the page. There are some tables in your input Html which have size greater then normal page size. In your case, we suggest you please increase the page size and set table’s width to 100% as shown in following code example.

Hope this helps you. Please let us know if you have any more queries.

Document doc = new Document(MyDir + "in.html");
doc.getFirstSection().getPageSetup().setPageWidth(800);
for (Table table : (Iterable)doc.getChildNodes(NodeType.TABLE, true))
{
    table.setPreferredWidth(PreferredWidth.fromPercent(100));
    table.autoFit(AutoFitBehavior.AUTO_FIT_TO_CONTENTS);
    table.setLeftIndent(-10);
}
doc.updateTableLayout();
doc.save(MyDir + "Out.pdf");