It seems that you need the "Keep lines together" layout functionality, which is currently not implemented. You can cast a vote for the item on our feedback portal:
RichTextBox: Add Line and Page Break properties of Paragraph
If I understand you correctly, you are trying to achieve a workaround by detecting that the paragraph is split between two pages, and add content (e.g. empty paragraphs) before him. If this is the approach, it seems achievable, and I will list the main steps here:
- Ensure that the LayoutMode for the document is Paged.
- Ensure that the layout is being performed for the document, e.g. using RadDocument.EnsureDocumentMeasuredAndArranged() method.
- Once the layout is done (or updated after document model change), the layout boxes for the document elements could be expected. If the target paragraph has more than one layout box, it's split between pages, example:
.radRichTextBox.Document.EnumerateChildrenOfType<Paragraph>().Last().GetAssociatedLayoutBoxes().Count() > 1;
- If needed add paragraph(s) before. After the addition, you should ensure that the layout is performed again before checking the new number of associated layout boxes. In RadDocumentEditor
is used for editing, layout is updated automatically; if direct updates to the document model are used (e.g. Section.Blocks.Add(new Paragraph()) the layout should be updated manually as mentioned above.
For the additional suggestion, it seems it's again a currently unsupported layout feature, namely RichTextBox: Add support for vertical alignment of page content
, but it's currently not scheduled for a specific release. Make sure to case a vote and follow the item to get notified on potential status updates.
Get quickly onboarded and successful
with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.