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

Free Support Forum - aspose.com

How to set A2 paper size for aspose words (java)?

com.aspose.words.PaperSize does not contain a value for A2 paper size. Is there a workaround for setting this paper size?

Thanks!

@andrhahn1

Thanks for your inquiry. You can iterate through sections in document and specify page width and height of A2 paper size as following code. Hopefully it will help you to accomplish the task.

com.aspose.words.Document doc = new com.aspose.words.Document("input.docx");

for (Section sec : (Iterable<Section>) doc.getSections()){
	// set Page width and height for A2 papersize
    sec.getPageSetup().setPageWidth(72 * 16.5);
    sec.getPageSetup().setPageHeight(72 * 23.4);
    
}

doc.save("output_176.docx");

Best Regards,

Ok great thanks!

Hi, I think I found a bug. Can you please confirm?

To reproduce:

    com.aspose.words.Document document = new com.aspose.words.Document();
    for (com.aspose.words.Section sec : (Iterable<com.aspose.words.Section>) document.getSections()){
        // set Page width and height for A2 papersize
        sec.getPageSetup().setPageWidth(72 * 16.5);
        sec.getPageSetup().setPageHeight(72 * 23.4);
    }
    document.save("C:\\temp\\result.docx");

When I open to result doc, Word tries to open the file but just hangs.

Thanks-

@andrhahn1,

Thanks for your inquiry. It looks like MS Word does not support A2 paper size (16.5 x 23.4 in). We checked with MS Word 2016 and earlier versions on our end. Please note that the maximum allowed Page width/height you can specify using MS Word 2016 is 22 inches (55.88 cm). Similarly, the minimum allowed Page width/height you can specify using MS Word 2016 is 0.1 inches (0.254 cm). If we can help you with anything else, please feel free to ask.

Best regards,
Awais Hafeez

Ok good to know. Thanks!