RadDocument Insert LineBreak in span

5 posts, 0 answers
  1. Thomas
    Thomas avatar
    4 posts
    Member since:
    May 2011

    Posted 02 Dec 2012 Link to this post

    I am inserting some text that conains linebreaks, "\n", into a new Span in a RadDocument based on a docx template and then I save the document as a PDF using the PDF provider.

    The problem is that there is everything is printed on the same line and the LineBreake itself i replaced by two Squares (i asume that is since the LineBreak character is not recognized).

    I have tried replacing the LineBreak with "FormattingSymbolLayoutBox.LINE_BREAK", but the text is still on one line and I get a ¬ character instead of the two Squares.

    Is it impossible to insert a LineBreak inside a Span, or is it possible to fix this?

    Please note that I am only using the RadDocument class and that I am not and do not want to use the actual RichTextBox Control!
  2. Petya
    Admin
    Petya avatar
    975 posts

    Posted 04 Dec 2012 Link to this post

    Hello Thomas,
    Generally, a span that contains "\n" in it is considered invalid, so you shouldn't be using this method when creating your document. The proper way to add a line break would be the second approach you mentioned - inserting FormattingSymbolLayoutBox.LINE_BREAK. The ¬ character, on the other hand, is the symbol used for adding line breaks in the document.
    So, a correctly structured document would look something like this:
    RadDocument document=new RadDocument();
    Section section = new Section();
    Paragraph paragraph1 = new Paragraph();
    Span span1 = new Span("Some text in the first span. ");
     
    paragraph1.Inlines.Add(span1);
    paragraph1.Inlines.Add(new Span(FormattingSymbolLayoutBox.LINE_BREAK));
    Span span2 = new Span("Some more text after the line break in the same paragraph.");
    paragraph1.Inlines.Add(span2);
     
    Paragraph paragraph2 = new Paragraph();
    Span span3=new Span("Last paragraph");
    paragraph2.Inlines.Add(span3);
     
    section.Blocks.Add(paragraph1);
    section.Blocks.Add(paragraph2);
     
    document.Sections.Add(section);
    and will indeed contain the ¬ character when exported to XAML, for example.

    I also tried exporting to PDF the document above and it all looks good on my end. Can you please verify that and contact us again if you are observing different behavior?

    Let me know how it goes.

     
    Greetings,
    Petya
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Doug
    Doug avatar
    6 posts
    Member since:
    Aug 2010

    Posted 21 Apr 2015 in reply to Petya Link to this post

    Using FormattingSymbolLayoutBox.LINE_BREAK within a Span worked for us until we recently upgraded to version 2015.1.401.45. Now our document literally displays the ¬ symbol. Please help!

    pragraph.Inlines.Add(new Span(FormattingSymbolLayoutBox.LINE_BREAK + "Some more text after the line break in the same paragraph");
        

  5. Tanya
    Admin
    Tanya avatar
    405 posts

    Posted 22 Apr 2015 Link to this post

    Hi Doug,

    In Q1 2015 we introduced a new Break element into the model of RadDocument. With the current version of RadRichTextBox, if you insert a line break symbol ("¬") or a page break symbol ("◊"), a break will not be inserted in the document. You can use the Break class, which is described in our documentation.

    All the changes introduced in our controls are listed in the Changes and Backward Compatibility section for the control.

    Hope this helps.

    Regards,
    Tanya
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  6. Ad
    Ad avatar
    3 posts
    Member since:
    Nov 2014

    Posted 22 May 2015 in reply to Tanya Link to this post

    Using the 'Break' class indeed solves the problem, thanks.
Back to Top
UI for WPF is Visual Studio 2017 Ready