Using a RadFlowDocumentEditor to add a page break and then insert a table, adds an additional paragraph in between.
As a workaround you can call the CleanParagraphsBeforeTablesOnNewPage() method:
private void CleanParagraphsBeforeTablesOnNewPage()
{
List<Paragraph> paragraphs = this.flowDocument.EnumerateChildrenOfType<Paragraph>().ToList();
foreach (var paragraph in paragraphs)
{
BlockContainerBase parent = (BlockContainerBase)paragraph.Parent;
int paragraphIndex = parent.Blocks.IndexOf(paragraph);
int blocksCount = parent.Blocks.Count;
bool isAfterPageBreak = paragraphIndex > 0 && this.PreviousBlockEndsWithPageBreak(parent.Blocks[paragraphIndex - 1]);
int nextIndex = paragraphIndex + 1;
bool nextBlockIsTable = nextIndex < blocksCount && parent.Blocks[nextIndex] is Table;
if (isAfterPageBreak && nextBlockIsTable)
{
parent.Blocks.Remove(paragraph);
}
}
}
private bool PreviousBlockEndsWithPageBreak(BlockBase blockBase)
{
bool isLastInlinePageBreak = false;
bool isParagraph = blockBase is Paragraph;
if (isParagraph)
{
Paragraph paragraph = (Paragraph)blockBase;
InlineBase lastInline = paragraph.Inlines.Last();
bool isBreak = lastInline is Break;
if (isBreak)
{
isLastInlinePageBreak = ((Break)lastInline).BreakType == BreakType.PageBreak;
}
}
return isLastInlinePageBreak;
}