I am creating a document using the C # and Open XML SDK. I want to change the orientation of some paragraphs and their containing pages to the landscape, while preserving the others in portrait orientation.
I tried some solutions, but they did not reach what I am looking for, and instead the orientation of all pages was changed to landscape except the first. These solutions include:
- Adding SectionProperties to the paragraph that I want to change its orientation to landscape:
WordprocessingDocument WordDocument = WordprocessingDocument.Open(ReportFile, true)
Paragraph paragraph = new Paragraph(new ParagraphProperties(
new SectionProperties( new PageSize()
{ Width = (UInt32Value)15840U, Height = (UInt32Value)12240U, Orient = PageOrientationValues.Landscape })));
WordDocument.MainDocumentPart.Document.Body.Append(paragraph);
- Adding a new body to the main document and adding it to it:
WordprocessingDocument WordDocument = WordprocessingDocument.Open(ReportFile, true)
Body body = new Body();
Paragraph paragraph = new Paragraph(new ParagraphProperties(
new SectionProperties( new PageSize()
{ Width = (UInt32Value)15840U, Height = (UInt32Value)12240U, Orient = PageOrientationValues.Landscape })));
body.Append(paragraph);
WordDocument.MainDocumentPart.Document.Append(body);
- Adding a new body to the main document and directly attaching the sectionProprties to it:
WordprocessingDocument WordDocument = WordprocessingDocument.Open(ReportFile, true)
Body body = new Body();
Paragraph paragraph = new Paragraph();
SectionProperties sectionProp = new SectionProperties(new PageSize() { Width = (UInt32Value)15840U, Height = (UInt32Value)12240U, Orient = PageOrientationValues.Landscape });
body.Append(paragraph);
body.Append(sectionProp);
WordDocument.MainDocumentPart.Document.Append(body);
So, is there a way to change the orientation of a single paragraph / page?