This is a migrated thread and some comments may be shown as answers.

Disabling page break for paragraph

3 Answers 204 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Vladimir
Top achievements
Rank 1
Vladimir asked on 07 Aug 2019, 04:16 PM

I'm adding a system generated paragraph with 3-4 lines to the end of every XAML document on the server side and I want to make sure that these lines are always on the same page. Either they all fit or they should be moved to the next page.
I’ve tried to detect this overlap by checking number of pages before and after this addition via DocumentLayoutBox, but PageNumber of last ChildLayoutBoxes is not changing.
Additionally, it would be nice to have a feature to allow paragraph alignment to the bottom of the page.

 

Regards,

Vitalij

3 Answers, 1 is accepted

Sort by
0
Accepted
Boby
Telerik team
answered on 12 Aug 2019, 08:26 AM
Hi Vitalij,

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:
this.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.

Regards,
Boby
Progress Telerik
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.
0
Vladimir
Top achievements
Rank 1
answered on 14 Aug 2019, 12:41 PM

Thank you Boby, your approach works as expected. I've added Break as a first inline and kept reference to it. In case a split is detected I simply change the type of this break to page break and the entire following paragraph is moved to a new page.

Meanwhile, the feature request you mentioned is turning 8 years old soon...

Regards,

Vitalij

0
Boby
Telerik team
answered on 16 Aug 2019, 08:26 AM
Hi Vitalij,

I am glad to you managed to find a decent workaround!

The features in the layout are extremely complex and tricky, and we are looking for significant demand before deciding to implement them. Otherwise we are re-prioritizing and considering the features in the backlog on a regular basis, so this particular feature request could be implemented at some point in the future - I've already increased its priority based on your demand.

Regards,
Boby
Progress Telerik
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.
Tags
RichTextBox
Asked by
Vladimir
Top achievements
Rank 1
Answers by
Boby
Telerik team
Vladimir
Top achievements
Rank 1
Share this question
or