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

Free Support Forum - aspose.com

Set Maximum Width to word doc

How to set maximum Page Width to word document?

doc.FirstSection.PageSetup.Orientation = Aspose.Words.Orientation.Landscape;
doc.FirstSection.PageSetup.PaperSize = PaperSize.B4;
i.e word doc should take auto width based on the content


Hi,

Thanks for your inquiry. Please note that the maximum allowed width/height you can specify using MS Word 2016 is 22 inches (55.88 cm). Similarly, the minimum allowed width/height you can specify using MS Word 2016 is 0.1 inches (0.254 cm).

You can use the following code to specify maximum page width/height (22 inches):

Document doc = new Document(MyDir + @"in.docx");

foreach (Section sec in doc.Sections)

{

sec.PageSetup.PageWidth = (72 * 22); // 22 inches

sec.PageSetup.PageHeight = (72 * 22); // 22 inches

}

doc.Save(MyDir + @"17.2.0.docx");


Hope, this helps.

Best regards,