5

I am using Novacode DocX in C#. Using method InsertSectionPageBreak(). But it does not save the parameters of the default page. For example page should be in landscape format. When using InsertSectionPageBreak() the format changes to the book. I need that each table has been on every page with landscape format.

using (DocX doc = DocX.Create(fileName))
{
     doc.PageLayout.Orientation = Orientation.Landscape;
     var table = doc.AddTable(12, 2); 
     doc.InsertTable(table);
     doc.InsertSectionPageBreak();                           
}
Sergii Zhevzhyk
  • 4,074
  • 22
  • 28
Магжан Куан
  • 964
  • 2
  • 11
  • 20

1 Answers1

8

Instead of using the InsertSectionPageBreak method of the DocX class, use the InsertPageBreakAfterSelf of the Table class.

doc.InsertTable(table).InsertPageBreakAfterSelf();

It should keep the style from the previous page.

Sergii Zhevzhyk
  • 4,074
  • 22
  • 28
  • Using the section break method was causing the page size to revert to 'Letter' for subsequent sections. Using this method avoided this issue. Thanks! – Cameron Forward Jun 27 '17 at 00:32