yammerade
yammerade

Reputation: 629

Page Layout of Sections with Novacode DocX

I am creating a document using Novacode DocX. I would like the entire document to be in landscape orienation, however I would also like to have several section breaks in the document. My code is laid out like this:

DocX doc = DocX.Create(fileName);
doc.PageLayout.Orientation = Novacode.Orientation.Landscape;
foreach (string page in pages)
{
    doc.InsertSection(false);
    Paragraph p = doc.InsertParagraph();
    p.Append(page);
}

doc.PageLayout.Orientation = Novacode.Orientation.Landscape;

doc.SaveAs(Path.Combine(folderPath, fileName));

I've also tried adding doc.PageLayout.Orientation = Novacode.Orientation.Landscape inside the loop after doc.InsertSection(false) and I can't get anything past the first page to turn to landscape.

Is there a way around this?

Upvotes: 1

Views: 2933

Answers (1)

Anthony Hayward
Anthony Hayward

Reputation: 2322

See this answer from Delford Chaffin: https://stackoverflow.com/a/33178151/316578

"Creating the different sections as separate documents and inserting them into the main document worked well and solved all my problems."

Upvotes: -1

Related Questions