ODT to PDF conversion adds blank page

The following ODT when rendered to PDF includes a blank last page when none is present in the original document.
It is a 2 page document with a table on the last page. Turning on non-printing characters indicates that the only thing after the table is a terminating paragraph mark that cannot be removed.

This is demonstrated in the attached zip: Test Chart 2.zip (129.3 KB)

  • Test Chart 2.odt is the original ODT file
  • Test Chart 2 - OpenOffice.pdf is the ODT file exported to PDF using OpenOffice
  • Test Chart 2 - Aspose.pdf is the ODT file exported to PDF using Apose Words for Java

To reproduce, upload Test Chart 2.odt to the online converter at Convert Files Online - Word, PDF, HTML, JPG And Many More

How can we avoid the blank page being generated?

NOTE: the table has been shrunk and the styles changed to avoid ODT to PDF conversion renders table row heights incorrectly
This causes the row heights to be too small when rendered using OpenOffice

@unb This looks like the same problem you have reported in your another thread. Table height in the document rendered by Aspose.Words is bigger than height of the same table in OpenOffice. The is why the empty paragraph after the table is moved to the next page and that is why an empty page is rendered. You can set the last paragraph break font size to zero to work the problem around:

Document doc = new Document("C:\\Temp\\in.odt");
doc.getLastSection().getBody().getLastParagraph().getParagraphBreakFont().setSize(0);
doc.save("C:\\Temp\\out.pdf");

The code above produces the following output on my side: out.pdf (84.2 KB)

Excellent. Thanks for that, the workaround resolves the problem.

1 Like