Orientation And PaperSize Option Not applied on Already Created Doc

Sample Code:

Aspose.Words.License wordsLicense = new Aspose.Words.License();
wordsLicense.SetLicense("Aspose.Total.NET.lic");
try
{
    Aspose.Words.Document doca = new Aspose.Words.Document(@"Landscape_A4.doc");
    try
    {
        for (int index = 0; index < doca.Sections.Count; index++)
        {
            doca.Sections[index].PageSetup.Orientation = Aspose.Words.Orientation.Portrait;
            doca.Sections[index].PageSetup.PaperSize = Aspose.Words.PaperSize.Letter;
        }
    }
    catch (Exception ex)
    { }
    doca.UpdatePageLayout();
    doca.Save(@"Aspose_Output_Portrait_Letter.doc");

Issue:
Expect Leater.

Expect Portrait

Required Files: Orientation And PaperSize Issue.zip (237.0 KB)

@hemalp This occurs because page orientation is already changed in your document using revision. You can set the required page size and orientation after applying revisions in your document:

Document doc = new Document(@"C:\Temp\in.doc");
            
doc.AcceptAllRevisions();

foreach (Section s in doc.Sections)
{
    s.PageSetup.Orientation = Orientation.Portrait;
    s.PageSetup.PaperSize = Aspose.Words.PaperSize.Letter;
}

doc.Save(@"C:\Temp\out.docx");

@alexey.noskov
Can you provide any other way, because we need to generate an Image with Revisions.

@hemalp Unfortunately, I do not see other way to resolve this. As I have mentioned, page size and orientation is already changed in your document and changes are stored as a revision. MS Word shows the changed values of the page size and orientation. When you change page size and orientation in the code, the value before revision is changed, so the changes made in the code are not reflected in the visual document representation in MS Word.