Word To Pdf:Page number orientation is incorrect

When I convert a Word document to PDF, the page number orientation is incorrect.
version:words-25.10-jdk17.jar
file:
TEST.7z (9.9 MB)

@serendipity.zhq

Summary
When a Word document contains sections with different orientations (portrait ↔ landscape), the footers – including page numbers – can appear rotated or misplaced after conversion to PDF with Aspose.Words (e.g., version 25.8‑jdk17.jar). This is a known issue reported in the Aspose support forum.

Why it happens

  • Aspose.Words builds the layout of each page when the document is loaded. If the document mixes portrait and landscape sections, the layout information for headers/footers may not be refreshed for the new orientation before the PDF is rendered.
  • As a result, the { PAGE } field (or any footer content) can be drawn with the wrong rotation in the PDF.

What to do next

  1. Upgrade the library
  • Use the latest Aspose.Words for Java build (newer than 25.8). Later releases contain fixes for several orientation‑related rendering problems, and many users have reported that the footer issue disappears after upgrading.
  1. Force a layout refresh before saving (a common workaround)
import com.aspose.words.*;

public class WordToPdf {
public static void main(String[] args) throws Exception {
Document doc = new Document("TEST.docx");

// Re‑calculate page layout – helps when the document has mixed orientations
doc.updatePageLayout();

// Save as PDF (you can also configure PdfSaveOptions if needed)
doc.save("TEST.pdf", SaveFormat.PDF);
}
}

Calling doc.updatePageLayout(); forces Aspose.Words to recompute the geometry of headers, footers, and page‑number fields for each section. In many cases this resolves the rotation problem.

  1. Verify the source document
  • Ensure page numbers are inserted as a field ({ PAGE }) in the footer (or header) and not as static text.
  • Confirm that the document uses section breaks to switch between portrait and landscape.
  1. If the problem persists, provide a minimal reproducible sample
  • Create a small Word file with at least one portrait and one landscape section, each containing a page‑number field.
  • Share the file together with the exact conversion code. This will help the Aspose support team determine whether the behavior is a remaining library limitation.

Following these steps should resolve the incorrect footer/page‑number orientation in most scenarios. If the issue remains after trying the above, the minimal sample will allow further investigation.

Note: The specific fix (doc.updatePageLayout()) is a recommended workaround based on Aspose documentation, but the original forum post only confirms the problem. Upgrading to a newer version is the most reliable way to address known bugs.

: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.

Even after calling the code, it still had no effect.

@serendipity.zhq As I can see MS Word renders the document the same way as Aspose.Words does on my side.
MS Word: ms.pdf (56.4 KB)
Aspose.Words: out.pdf (21.0 KB)

Could you please save your document to PDF using MS Word on your side and attach the resulting document here?