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

ChangeParagraphLineSpacing breaks wordwrap

5 Answers 321 Views
RichTextEditor
This is a migrated thread and some comments may be shown as answers.
Shawn
Top achievements
Rank 1
Shawn asked on 02 Oct 2019, 02:59 PM

Hi,

I am reading an RTF string from a database and displaying it in a radRichTextEditor. Many of these are multi-line instructions, including many bullet point lists. In order to format this more nicely I wrote the following snippet

 

private void ConfigureDocumentEditor(RadRichTextEditor editor)
        {
            var docEditor = new Telerik.WinForms.Documents.Model.RadDocumentEditor(editor.Document);
             
            editor.Document.Selection.SelectAll();
            docEditor.ChangeFontSize(8);
            docEditor.ChangeParagraphLineSpacing(0.25);
            editor.Document.Selection.Clear();
            editor.IsReadOnly = true;
        }

 

I also set the LayoutMode to "Flow". The problem that I'm running into is that in some instances the data in the DB is just one long string. When I set ChangeParagraphLineSpacing to a value >= 1.0 the word wrap works nicely. When ChangeParagraphLineSpacing  < 1.0 it looks like the attached image. Is there any way to change the spacing so that it applies to paragraph breaks and lists but not the line spacing caused by word wrapping?

 

Thanks

 

5 Answers, 1 is accepted

Sort by
0
Tanya
Telerik team
answered on 07 Oct 2019, 11:28 AM

Hi Shawn,

The value applied for the line spacing is pretty small and causes the lines to appear one on the top of the other. Can you please share more details on why you need to apply such a small value and what is the end goal you need to achieve? I am trying to get a better understanding of the case so I can suggest you the most appropriate approach for achieving the desired result.

Looking forward to hearing from you.

Regards,
Tanya
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
Shawn
Top achievements
Rank 1
answered on 07 Oct 2019, 03:55 PM

Hi Tanya,

 

Thank you for getting back to me on this. I'm uploading 2 images which I think demonstrate the use case fairly well. 

I have a text field (RichTextEditor) with limited real estate. While there are exceptions, a typical item that gets displayed here is of this format:

 

Opening paragraph (often Very long)

* bulleted list of actions
* second action
* final action

Closing paragraph.

 

 

In BigBullets.png you see that I can fit most of this on the screen, but not the closing paragraph.The items are spaced out greatly with a lot of white space --  "docEditor.ChangeParagraphLineSpacing(1.0)"

In SmallBulletSpacing.png, you can see that I save a lot of real estate when the items are closer together "docEditor.ChangeParagraphLineSpacing(0.25)". However the paragraphs become unreadable because the word wrap is ruined.

 

Hopefully this explains what I'm trying to accomplish. Thanks for your help. 

0
Accepted
Tanya
Telerik team
answered on 10 Oct 2019, 09:04 AM

Hello Shawn,

As far as I understand, you need to minimize the space between the lines and ensure the whole space of the line is exactly as big as needed to accommodate the text. If this is correct, you can set the line spacing to 1 and remove the spacing after the paragraphs:

var docEditor = new Telerik.WinForms.Documents.Model.RadDocumentEditor(editor.Document);

editor.Document.Selection.SelectAll();
docEditor.ChangeFontSize(8);
docEditor.ChangeParagraphLineSpacing(1);
docEditor.ChangeParagraphSpacingAfter(0);
editor.Document.Selection.Clear();
editor.IsReadOnly = true;

Hope this suggestion fits your needs.

Regards,
Tanya
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
Shawn
Top achievements
Rank 1
answered on 10 Oct 2019, 02:19 PM

Thanks Tanya!

That's exactly the method I was looking for. For clarity, is the value accepted by those methods in pixels, is it a percentage of font size or something else?

 

0
Accepted
Vladislav
Telerik team
answered on 15 Oct 2019, 10:44 AM

Hello Shawn,

The value of the Line spacing is a bit complex. For example, ChangeParagraphLineSpacing(1) is equal to setting Single line spacing through the UI. The Single preset depends on the font size and the currently selected font. Basically, it is somewhere between 110% and 135% of the current font size. You can find additional information on line spacing in this article (it's for MS Word but it is still relevant).

As for the paragraph spacing it is measured in DIP (Device Independent Pixels). In order to set the value in points (pt), you will need to convert it using PointToDip method from the Unit class.

I hope you find this information sufficient.

Regards,
Vladislav
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
RichTextEditor
Asked by
Shawn
Top achievements
Rank 1
Answers by
Tanya
Telerik team
Shawn
Top achievements
Rank 1
Vladislav
Telerik team
Share this question
or