Free Support Forum - aspose.com

Inserting a pagebreak at end of section with tables

How can I insert a pagebreak at the end of a section containing a table?

The following code works if there are no tables in the section, but with tables, content is appended on the same page and no pages are added to the document.

curSection = _builder.CurrentParagraph.ParentSection

sectionTemplate = curSection.Clone(True)

lastParaIndex = curSection.Body.Paragraphs.Count - 1

builder.MoveToParagraph(lastParaIndex, -1) '// is this right way to move to EOSection?

'//builder.Write("XXX") '//inserts in 1st cell of table vs. section end- even if more paras after table

builder.InsertBreak(BreakType.PageBreak)

curSection.AppendContent(sectionTemplate.Clone(True))

Maybe the question I need answered is:

How can I accomplish: DocBuilder.MovetoSection(SectionEnd)?

Thanks.

Charu Tevari

OK, I can see one roundabout way of adding a pagebreak between two copies of the original section content [my table templates], but is there a better way? It would be nice to be able to do something like: builder.MoveToSection(sectionNo, SectionPositionEnum.EndOfSection); builder.InserBreak(..)

currentSection = _builder.CurrentParagraph.ParentSection

sectionTemplate = currentSection.Clone(True)

doc.Sections.Add(sectionTemplate)

builder.MoveToSection(doc.Sections.Count - 1)

builder.InsertBreak(BreakType.PageBreak)

currentSection.AppendContent(sectionTemplate.Clone(True))

sectionTemplate.Remove()

-Charu Tevari

do builder.MoveToSection(sectionIdx)

followed by builder.MoveToParagraph(-1, -1);

MoveToParagraph works within the currently selected section and -1 indicates first paragraph from the end.