Word to Pdf:Blank page

When I used version words-25.10-jdk17.jar of the JAR file to convert the following Word file to PDF, the PDF had an extra blank page.
file:
TEST.7z (132.0 KB)

@serendipity.zhq

Summary
When converting the supplied .docx to PDF with Aspose.Words 25.10‑jdk17, an extra blank page is added at the end of the PDF.

Why it happens
The blank page is a known issue in several Aspose.Words releases (e.g., 25.2.0, 23.10.0 and the 25.10 build you are using). The problem is caused by the horizontal scaling of some formulas during the conversion – the scaling pushes the last line of content onto a new page, which ends up being completely empty.

What to do next

  1. Upgrade the Aspose.Words library
  • The issue has been fixed in later builds (25.12 and newer). Replace words-25.10-jdk17.jar with the latest JAR and re‑run the conversion.
  1. If you must stay on 25.10, try disabling scaling
Document doc = new Document(memoryStream);
doc.acceptAllRevisions(); // your existing code
PdfSaveOptions pdfOptions = new PdfSaveOptions();
pdfOptions.setScaleFactor(1.0); // forces no additional scaling
doc.save(newMemoryStream, pdfOptions);

Setting the scale factor to 1.0 can sometimes prevent the extra scaling that creates the blank page.
3. Verify the result

  • After conversion, call int pageCount = doc.getPageCount(); – it should match the expected number of pages.
  • Open the generated PDF and confirm that the blank page is gone.
  1. If the problem persists
  • Provide the extracted .docx (not the archive) so the Aspose support team can inspect the exact formula layout.
  • Include the page count reported by doc.getPageCount() before and after saving.

Note: The draft answer previously suggested removing empty trailing sections, refreshing the layout, or adjusting page size. Those suggestions are not mentioned in the official Aspose support information for this specific issue and therefore have been omitted.


If you still see the extra page after trying the steps above, please share the plain .docx file and any additional code you use so we can investigate further.

:warning: I could not fully verify this explanation against the retrieved sources. Please double-check the behaviour in your environment and confirm the exact SDK/version.

The code prints out 7 pages, but the original Word file only shows 6 pages.

@serendipity.zhq The following fonts used in your document are not available on my side:

  • ‘方正小标宋简体’
  • ‘小标宋’

Could you please to provide these fonts here? We will check the issue and provide you more information.

By the way, MS Word on my side also shows 7 pages in your document.

font:
方正小标宋简体.7z (1.6 MB)
小标宋体.7z (1.4 MB)

@serendipity.zhq Thank you for additional information. After installing the provided fonts MS Word still shows 7 pages in your document, just like Aspose.Words. Here is PDF produced my MS Word on my side: ms_chinese.pdf (279.4 KB)

Could you please convert your document to PDF using MS Word on your side and attach the resulting document here for our reference?

The PDF document you generated also has an extra blank page, which wasn’t present in the original Word document. Is there a way to remove this blank page without affecting the original document structure?

When I open a Word document with Office, there are no blank pages. However, when I convert and save a PDF file using Office, there is still an extra blank page.
xxp测试件2 - 副本.pdf (787.1 KB)

@serendipity.zhq As I can see PDF rendered by Aspose.Words matches the PDF document produced by MS Word. So there is no bug in Aspose.Words document layout.

After deeper analysis I figured out that the problem is caused by PageSetup.RestartPageNumbering. If reset this property, the second empty page disappears:

Document doc = new Document("C:\\Temp\\in.doc");
for(Section s : doc.getSections())
    s.getPageSetup().setRestartPageNumbering(false);
doc.save("C:\\Temp\\out.pdf");

out.pdf (134.5 KB)

After making this change, the blank pages no longer appear. Why did this problem occur? Will this change affect the layout or page numbering of other documents?

@serendipity.zhq Unfortunately, MS Word logic is not clear enough in this case. So I cannot explain why behavior is so. The above provided code simply demonstrates the reason of the blank page and how avoid it. Of course changing section properties might affect rendering of the document. So you should use the code carefully.

Okay, thanks for your reply.

Is there a way to directly handle blank pages? I just discovered that after making this change, all my subsequent page numbers have changed. They no longer start from 1, but continue from the previous page number. For example, normally it should be 16, 1, 2… but after the change it becomes 16, 18, 19…

@serendipity.zhq

Yes, this is exactly what PageSetup.RestartPageNumbering property is for.

In general case, you can remove blank pages from the document using Document.removeBlankPages method. But in your particular “strange” case, the method does not remove this blank page.

It seems there is no better way.

1 Like