Disabling page break for paragraph

4 posts, 1 answers
  1. Vitalij
    Vitalij avatar
    37 posts
    Member since:
    Dec 2010

    Posted 07 Aug Link to this post

    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

  2. Answer
    Boby
    Admin
    Boby avatar
    714 posts

    Posted 12 Aug Link to this post

    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.
  3. Vitalij
    Vitalij avatar
    37 posts
    Member since:
    Dec 2010

    Posted 14 Aug Link to this post

    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

  4. Boby
    Admin
    Boby avatar
    714 posts

    Posted 16 Aug Link to this post

    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.
Back to Top