Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Fri Aug 13, 2021 2:12 pm

Hello Team,

I would like to know if there is a way I can force 1st page to be in portrait mode and rest all to be in landscape mode in Word Document.
Please note, it is a dynamically generated document so I won't know in advance how many sections or what content are there in the doc.

Thanks & Regards,
Nikita

nikki0512
 
Posts: 1
Joined: Fri Aug 13, 2021 2:08 pm

Mon Aug 16, 2021 2:28 am

Hello,

Thanks for your inquiry.
Please note that in a Word document, the page layout is set according to the section, not according to the page. The page layout settings in the same section are the same. I am sorry that there is no way to force 1st page to be in portrait mode and rest all to be in landscape mode in a Word Document.

Sincerely,
Brian
E-iceblue support team
User avatar

Brian.Li
 
Posts: 1271
Joined: Mon Oct 19, 2020 3:04 am

Mon Oct 31, 2022 1:25 pm

Hi Brian,
Mixed orientation actually exists in Word.
See MS page:
Search for "word add landscape page" in google (can't add urls here)

Is this functionality available via Spire.Doc library?

Thanks,
Rafael.

inheritaustralia
 
Posts: 5
Joined: Wed Nov 24, 2021 6:25 am

Tue Nov 01, 2022 3:20 am

inheritaustralia wrote:Hi Brian,
Mixed orientation actually exists in Word.
See MS page:
Search for "word add landscape page" in google (can't add urls here)

Is this functionality available via Spire.Doc library?

Thanks,
Rafael.


Hello,

Thanks for your inquiry.
This is Abel from E-iceblue support team. For your requirement, you can refer to the following code snippet, and I put the input file and output file of the code below for your reference.
If you have any issue, just feel free to contact us.
Code: Select all
  //Load the word file
            Document doc = new Document();
            doc.LoadFromFile(@"../../data/input.docx");

            //Add a new section
            Section newSection = doc.AddSection();

            //Set the orientation for the new section
            newSection.PageSetup.Orientation = PageOrientation.Landscape;

            //Add a new paragraph in the new section
            Paragraph para = newSection.AddParagraph();
            para.AppendText("2.This is landscape page in a new section");
           
            //Save the result word file
            doc.SaveToFile(@"../../output/output.docx", FileFormat.Docx);

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Wed Nov 02, 2022 2:41 am

Thanks. This is working not. Note to other users. You will have to set the next Section as portrait otherwise the rest of the document remains in landscape.

inheritaustralia
 
Posts: 5
Joined: Wed Nov 24, 2021 6:25 am

Wed Nov 02, 2022 3:26 am

Hello,

Thanks for your notice.
Yes, if you continue to add section without setting the page orientation, the new page will default to landscape.
If you have any issue, just feel free to contact us.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 1010
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.Doc