DocumentUpdatePageLayout Method |
Namespace: Aspose.Words
This method formats a document into pages and updates the page number related fields in the document such as PAGE, PAGES, PAGEREF and REF. The up-to-date page layout information is required for a correct rendering of the document to fixed-page formats.
This method is automatically invoked when you first convert a document to PDF, XPS, image or print it. However, if you modify the document after rendering and then attempt to render it again - Aspose.Words will not update the page layout automatically. In this case you should call UpdatePageLayout before rendering again.
Document doc = new Document(MyDir + "Rendering.docx"); // Saving a document to PDF or to image or printing for the first time will automatically // layout document pages and this information will be cached inside the document doc.Save(ArtifactsDir + "Rendering.UpdatePageLayout.1.pdf"); // Modify the document in any way doc.Styles["Normal"].Font.Size = 6; doc.Sections[0].PageSetup.Orientation = Aspose.Words.Orientation.Landscape; // In the current version of Aspose.Words, modifying the document does not automatically rebuild // the cached page layout. If you want to save to PDF or render a modified document again, // you need to manually request page layout to be updated doc.UpdatePageLayout(); doc.Save(ArtifactsDir + "Rendering.UpdatePageLayout.2.pdf");