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

Linking elements so they can't be split by a page break

8 Answers 52 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
ric
Top achievements
Rank 1
ric asked on 05 Nov 2013, 12:15 PM
Is this possible or supported? Are there any workarounds?

Essentially we might, for example, have a heading followed by an image. But occasionally the auto-page wrapping can split them up, so that the heading and images essentially have a page break in between. It'd be nice to be able to link them somehow to prevent this happening

8 Answers, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 08 Nov 2013, 12:01 PM
Hello,

You can try inserting a non-breaking space between the elements, for example with the Alt+0+1+6+0 shortcut. However, please note that at this point non-breaking spaces are not fully supported and they will not be preserved on export/import roundtrips to DOCX. You can track the availability of the feature here.

I hope this helps!

Regards,
Petya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
ric
Top achievements
Rank 1
answered on 08 Nov 2013, 05:14 PM
I've tried that and don't think it's what we need, while it does prevent items that are inline from being separated by a page break it won't help us force two items that are NOT inline (e.g. text, line break, then image) to always appear on the same page

EDIT: appears that MS-Word supports paragraphs (AKA block items) to have "keep with next" set, do you support something similar? http://support.microsoft.com/kb/233493
0
ric
Top achievements
Rank 1
answered on 11 Nov 2013, 02:55 PM
I've been working on a workaround. But am having trouble with document positions. Specifically I want to remember the caret position then refer to it later  (to see if I'm still on the same page) but if I do

dim startPosition as New DocumentPosition(editor.Document.CaretPosition) 

and then move the Caret the above variable changes! I want a snapshot so I can put the caret back when I've finished. How do I do that?

0
Petya
Telerik team
answered on 11 Nov 2013, 04:28 PM
Hi,

Keep with next functionality is not currently available in RadRichTextBox. The feature is in our to-do list, but it is not scheduled, so I cannot tell when it might be implemented.

As for your other questions, the method you are using to copy the caret position might indeed cause the observed problem. I suggest you create the copy as follows instead:
Dim startPosition As New DocumentPosition(editor.Document)
startPosition.MoveToPosition(editor.Document.CaretPosition)

Let us know if you have other questions.

Regards,
Petya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
ric
Top achievements
Rank 1
answered on 11 Nov 2013, 04:31 PM
Thanks, yes, that did the trick. I'm putting start and end marker strings in the document, using textsearch to find them then if both positions are on different pages inserting a page break. 
0
Petya
Telerik team
answered on 12 Nov 2013, 09:38 AM
Hello,

I'm glad to hear my answer was helpful!

I just wanted to follow-up on this and mention that RadRichTextBox's document model allows inserting elements which are not visually represented and can be used for semantic purposes - annotations. Moreover, you can easily create a custom annotation and will not have to insert marker strings in the document. For more information you can check this help article.

I hope this helps!

Regards,
Petya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
ric
Top achievements
Rank 1
answered on 12 Nov 2013, 10:27 AM
Thanks, that looks interesting, though I can't find a way of getting a DocumentPosition from a RangeStart instance?
0
Petya
Telerik team
answered on 12 Nov 2013, 03:07 PM
Hi,

Annotation markers are Inline document elements, so you can simply use the MoveToInline() method of DocumentPosition:
DocumentPosition pos = new DocumentPosition(this.radRichTextBox.Document);
pos.MoveToInline(annotationStart);

Do not hesitate to get back to us if you have other questions.

Regards,
Petya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
RichTextBox
Asked by
ric
Top achievements
Rank 1
Answers by
Petya
Telerik team
ric
Top achievements
Rank 1
Share this question
or