problem using odd and even headers and footers

Jul 16, 2013 at 5:47 PM
I want to have a header and footer on the odd pages of my document and a blank header on every even page of my document.

Currently I'm just trying to get it working so I have generic text for the 2 headers and footers but they just won't alternate and I've read the Cathals Corner post on exactly this and still can't get it to alternate. Currently it only uses the odd header and footer on every page. Here is a bit of the code I have so far:
MemoryStream ms = new MemoryStream();
            DocX document = DocX.Create(ms);
            document.PageLayout.Orientation = Novacode.Orientation.Landscape;
            
            document.AddHeaders();
            document.AddFooters();
            
            Header header = document.Headers.odd;
            Header header2 = document.Headers.even;

            Footer footer = document.Footers.odd;
            Footer footer2 = document.Footers.even;

            Paragraph h = header.InsertParagraph();
            h.Append("first header");

            Paragraph h2 = header2.InsertParagraph();
            h2.Append("Page 2").Font(new FontFamily("Times New Roman")).FontSize(22);
adding content to the pages which works fine
Paragraph m = footer.InsertParagraph();
            m.Append(this.course + (this.section != null && this.section != string.Empty ? " Section " : string.Empty) + this.section).Font(new FontFamily("Times New Roman")).FontSize(22);

            Paragraph f2 = footer2.InsertParagraph();
            f2.Append("Page 2").Font(new FontFamily("Times New Roman")).FontSize(22);


            document.DifferentOddAndEvenPages = true;
            document.SaveAs(ms);
            return ms;