Aspose words - page settings

Hi
Can you let us know how to set page width and height as per contents available, using aspose words?
Documents are attached.
Thank you.

Hi Sonali,
Thanks for your query. Please use the following code snippet for your requirement.
Please read documentation of PageSetup class. PageSetup object contains all the page setup attributes of a section (left margin, bottom margin, paper size, and so on) as properties.
https://reference.aspose.com/words/net/aspose.words/pagesetup/

Document doc = new Document();

foreach(Section section in doc.Sections)
{
    section.PageSetup.PageHeight = 100;

    section.PageSetup.PageWidth = 100;
}
doc.Save(MyDir + "AsposeOut.docx");

Please let us know if you have any more queries.v

No. I do not want to set any fixed height , width. I want to resize page as per content available . The contents can be less or more and the code should calculate the required height and width. Let us know how to calculate using aspose words Java.

Hi Sonali,

Thanks for your query. Aspose.Words mimics the same behavior as MS Word do. I would like to share with you that MS Word document is flow document. It means that it does not contain any information about its layout into lines and pages. So there is no way to get the height of contents in a page.

Please let us know if you have any more queries.

Hi there,

Thanks for your inquiry.

Just to let you know that Aspose.Words has exposed the page layout details of page elements in the API. What you are looking to do may be possible now.

Please check out the most recent samples and let me know if we can help with anything.

Thanks,