Aspose Word conversion to PDF adds a blank page at the end

Hello.
We encountered an issue when creating PDF document from Word Table of content. After conversion generated pdf has three pages with the third page completely blank.
Attached is the zip archive containing the input Word document TocWithUpdatedPageNumbers.docx and generated PDF TocWithUpdatedPageNumbers_2401.pdf (used Aspose.Word for Java version 24.1) and the following sample code snippet:

final static String FILE_FOLDER = "/scratch/tmp/testAsposeWords/";

final Document doc = new Document(FILE_FOLDER + "TocWithUpdatedPageNumbers.docx");
			
// save the base Doc as PDF
final String pdfFile = FILE_FOLDER + "TocWithUpdatedPageNumbers_2401.pdf";
Files.deleteIfExists(Paths.get(pdfFile));
		
doc.updatePageLayout();
doc.save(pdfFile, new PdfSaveOptions()); 

System.out.println("Created merged PDF File: " + pdfFile);

Is there any setting that allows to detect if there is blank page at the end of generated PDF, and if so - to remove it?

Thanks in advance.
TocWithUpdatedPageNumbers.zip (55.2 KB)

@oraspose The empty page is there in the input document. It is caused by an empty paragraph at the end of the document:

You can try setting paragraph break size of the last paragraph to zero to eliminate the empty page:

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

out.pdf (50.2 KB)