I've been interested in ways to add section breaks to Export to Word, both to do Landscape Orientation and also to reset page numbering. Thank you for posting this.
So far, however, I haven't gotten the above code to work for me. What I have been asked to do is switch to landscape orientation based off of a <div> class attribute, similar to how page breaks are done. For instance, HtmlToOpenXml supports the following for page breaks:
So far, however, I haven't gotten the above code to work for me. What I have been asked to do is switch to landscape orientation based off of a <div> class attribute, similar to how page breaks are done. For instance, HtmlToOpenXml supports the following for page breaks:
<div style="page-break-after:always"> </div>
I've been asked to support something similar for landscape, like:<div class="SectionBreakLandscape"> </div>
I tried to take the above code and apply it to HtmlConverter.ProcessContainerAttributes, where page breaks are set: string classValue = en.Attributes["class"];
if (classValue == "SectionBreakLandscape")
{
paragraphs.Add(new Paragraph(new ParagraphProperties(new SectionProperties(ChangeOrientationToLandscape()))));
newParagraph = true;
}
However, no section break occurs and the page does not switch to landscape. What am I missing to make this work?