Aspose.Words should preserve the Paper Size during converting Word document to PDF format. Please ZIP and upload your input Word document and Aspose.Words generated PDF file showing the undesired behavior here for testing. We will then investigate the issue on our end and provide you more information.
According to MS Word 2019, A4 paper size is actually equal to 8.27" x 11.69" inches (see A4 Paper Size.png (26.0 KB)). I have also converted your “Testing_Doc_Template.docx” file to PDF format manually by using the “Save As” command of MS Word 2019 and attached the PDF file here for your reference (see msw-2019.pdf (293.0 KB)). So, this is the expected behavior and Aspose.Words for Java mimics the behavior of MS Word in this case.
Please also provide a comparison screenshot highlighting (encircle) the problematic area(s) in Aspose.Words generated output PDF and attach it here for our reference. Also, you are using an old 20.8 version of Aspose.Words for Java on your end; we suggest you to please upgrade to the latest 21.5 version and provide 21.5 version generated PDF file here for further testing.
Also, you can customize the paper size by using the following Java code:
Document doc = new Document("C:\\Temp\\Aspose_PDF\\Testing_Doc_Template.docx");
for (Section section : doc.getSections()) {
section.getPageSetup().setPageWidth(8.3 * 72); // 1 inch equals to 72 points
section.getPageSetup().setPageHeight(11.7 * 72);
}
doc.save("C:\\Temp\\Aspose_PDF\\awjava-21.5.pdf");
It is great that you were able to resolve this issue on your end. In case you have further inquiries or may need any help in future, please let us know by posting a new thread in Aspose.Words’ forum.