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

Free Support Forum - aspose.com

Document with pages in landscape and portrait set up

Hi,

I am creating a document with aspose.words in .net some of the pages are in portrait and some are in landscape mode. However, the pages I am setting to landscape mode are still showing in portrait mode. I am using the code below. I have tried using builder.PageSetup also,

Aspose.Words.PageSetup ps = builder.CurrentSection.PageSetup;
ps.Orientation = Orientation.Landscape;

thanks,

Brian

Hello

Thanks for your request. I cannot reproduce the problem on my side using the latest version of Aspose.Words (9.4.0).

You can download the latest version from here:

Best regards,

Hi,

thanks for your reply.
I am able to set the whole document to either portrait or landscape mode, but not individual pages. What I am looking for is most of the document in portrait and just some pages in landscape. So during processing I am invoking ps.Orientation = Orientation.Landscape, adding some html content and then ps.Orientation = Orientation.Portrait. However the whole document seems to have the mode of the last orientation mode set.
Can individual pages be set to a different orientation than the rest of the doc?

thanks,

Brian

Hi

Thank you for additional information. Yes you can achieve this, in case of using sections. I mean if each page inside your document will be separate section, you will be able to set page orientation for current section.

Please see the following link to learn more about sections in MS Word:

Best regards,

Hi,

Thanks for that link, the changing of portrait mode now works, using the code below. However, the headers and footers are no only appearing on the last page i.e last section.
Any idea how to ensure headers/footers appear in all pages,

thanks,

Brian

Section sectionToAdd = new Section(builder.Document);
builder.Document.Sections.Add(sectionToAdd);
Aspose.Words.PageSetup ps = sectionToAdd.PageSetup;
if (orientation == "landscape")
{
    ps.Orientation = Orientation.Landscape;
}
else
{
    ps.Orientation = Orientation.Portrait;
}
builder.MoveToDocumentEnd();

Hi

Thanks for your request. I think you can try specifying LinkToPrevious property of section to True. Please see the following link:

In additional, each separate section of the document can have different header/footer. So you can add the same header/footer for each section.

Please see the following link to learn more about creating headers and footers in Aspose.Words:

Hope this helps.

Best regards,