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

Free Support Forum - aspose.com

HTML to PDF conversion creates additional blank page

The conversion of the attached HTML to PDF emptyPage.zip (50.8 KB)
using Aspose.Words 21.9. creates additional blank page.
Is there a way to avoid this empty page?

@dvtdaten

If you load the HTML in MS Word 2019, it will have two pages. Please check the attached output PDF file generated by Aspose.Words for Java 21.9.
21.9.pdf (50.8 KB)

MS Word and Aspose.Words’ outputs are same. Could you please share the code example that you are using? We will investigate this issue further and provide you more information on it.

It is worth mentioning, that I am changing the papersize to A4 the way you suggested in Cell Text is Rendered on Next Line after Changing Paper Size to A4 | HTML to PDF Conversion using Java
Two pages would not be a problem, but the empty page is.

@dvtdaten

We suggest you please wait for the fix of this issue WORDSNET-22749.

Regarding the issue reported in this thread, we have changed the paper size to A4 and saved the HTML to PDF using following code example. We have not faced the empty page issue. Please check the attached output PDF. 21.9.pdf (50.8 KB)

Document document = new Document(MyDir + "emptyPage.html");
for (Section section : document.getSections()) {
	PageSetup pageSetup = section.getPageSetup();
	if (PaperSize.A4 != pageSetup.getPaperSize()) {
		pageSetup.setPaperSize(PaperSize.A4);
	}
}

for(Table table :(Iterable<Table>)document.getChildNodes(NodeType.TABLE, true))
{
     table.autoFit(AutoFitBehavior.AUTO_FIT_TO_WINDOW);
}

document.updatePageLayout();
document.save(MyDir + "21.9.pdf");

For a test I used exactly your code above, but my pdf differs from yours. I am running out of ideas now.
Please compare input and output: emptyPage2.zip (50.7 KB)

@dvtdaten

We have logged this problem in our issue tracking system as WORDSNET-22813. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.