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?
NovacodePageLayout.Orientationafter you append paragraphs larger then a page. You might be able to work around it but I need to know more of what you are trying to accomplish. - PhillipInsertParagraphyAfterSelf()andInsertTableAfterSelf()do not affect page orientation, when extending past one page. It sounds like you are inserting paragraph text as a header, then a table, and finally another paragraph of explanation? Does this happen consistently? I think you may be able to useInsertParagraphyAfterSelf()andInsertTableAfterSelf()after last table or paragraph on page instead of Append(). You will need to know what was the last thing inserted. - PhillipMicrosoft.Office.Interop.Wordto change orientation after usingNovacode. After, each of the pages on the document are set to landscape, but they do not display as landscape(issue still exists). I don't know if you will be able to get around this withNovacode. - Phillip