Importing HTML using HtmlFormatProvider changes formatting

6 posts, 0 answers
  1. Vic
    Vic avatar
    40 posts
    Member since:
    Mar 2009

    Posted 21 Feb 2014 Link to this post

    Hi,

    I'm using version 2013.3.1316.1050, the previous versions did not have this issue.

    When I import simple html it now increases the line height and I can't figure out how to shorten it..

    var htmlProvider = new HtmlFormatProvider();
    RadDocument document = htmlProvider.Import(html);
    RichText.InsertFragment(new DocumentFragment(document));

    Test HTML: "<ul><li>Test1</li><li>Test2</li><li>Test3<ul><li>Test 4</li></ul></li></ul>"

    After I call InsertFragment I tried:

    document.LineSpacingType = LineSpacingType.Auto;
    document.LineSpacing = .75;
    document.ParagraphDefaultSpacingBefore = _.25;
    document.ParagraphDefaultSpacingAfter = .25;

    Is there anyway to control this?

    If I use binding to the same HTML its fine, just when calling Import.

    Any help is appreciated, thanks,
    Vic
  2. Mihail
    Admin
    Mihail avatar
    192 posts

    Posted 24 Feb 2014 Link to this post

    Hello Vic,

     Thank you for contacting us about this issue.

    It is related to the automatic spacing. I will explain in few words how the automatic spacing works.

    The automatic spacing is implemented to match the spacing which will be applied to the paragraph in an HTML document where no explicit spacing before or after is specified. The AutomaticSpacingAfeter and AutomaticSpacingBefore are properties of the paragraph and are set to true in the default style "Normal Web", which is the default style when importing HTML document.

    The problem you have observed is a bug in the implementation of automatic spacing after related to lists. I will log this issue to our to do list for investigation and fix.

    Meanwhile as workaround you can set the desired spacing to the default paragraph style when importing from HTML, the "Normal Web". Here is example on how to do it:
    this.radRichTextBox.Document.StyleRepository["NormalWeb"].ParagraphProperties.SpacingAfter = 0;
    this.radRichTextBox.Document.StyleRepository["NormalWeb"].ParagraphProperties.AutomaticSpacingAfter = false;

    Please notice that this will affect all paragraphs with this style applied. 
    You could apply it only to the paragraphs in list. Here is how you could do it:
    foreach (Paragraph paragraph in this.radRichTextBox.Document.EnumerateChildrenOfType<Paragraph>())
    {
        if (paragraph.IsInList)
        {
            paragraph.AutomaticSpacingAfter = false;
            paragraph.SpacingAfter = 0;
        }
    }

    In appreciation for your involvement I have updated your Telerik points. If you have further questions please do not hesitate to contact us again.

    Regards,
    Mihail
    Telerik
  3. DevCraft banner
  4. Vic
    Vic avatar
    40 posts
    Member since:
    Mar 2009

    Posted 24 Feb 2014 in reply to Mihail Link to this post

    Hi Mihail,

    Thanks for your reply, tweaked your fix for my needs and is now working!

    Thanks for the points :)

    Regards,
    Vic
  5. bhargava
    bhargava avatar
    14 posts
    Member since:
    Feb 2015

    Posted 18 Jun 2015 Link to this post

    hi,

    I am using RadRichTextBox  which has the document property is set to HtmlFormartProvider. I don't have any problem with spacing when loading but, when I want to increase the spacing between two items (td's)  vertically , I can't control the space .It takes quite a lot of empty space.I don't have this problem with horizontal spacing.

     

                  HtmlFormatProvider prdf = new HtmlFormatProvider();
                     var document = prdf.Import(result);
                        this.RichTextBox.Document = document;

     

    this is how my o/p looks:

     

    1.name 

    2.dob

    3.age

    4.height

    I want to increase the height b/w age and height after loading using the mouse as I am using HtmlFormartProvider , I have a table like structure .So, when I hover over the age I get a up and down arrow to adjust the height. But, I can't control the height .

     

    Any suggestions.

     

    Thanks,

    Bhargava 

  6. bhargava
    bhargava avatar
    14 posts
    Member since:
    Feb 2015

    Posted 22 Jun 2015 Link to this post

    Hi Mihail,

    ​Can you please suggest a solution..

  7. Petya
    Admin
    Petya avatar
    975 posts

    Posted 23 Jun 2015 Link to this post

    Hi Bhargava,

    Could you send over some images of the visual result you get and the source HTML you are passing to the control. I'm having a hard time understanding what exactly you are trying to achieve. You mentioned tables and td elements, but the example you gave looks like a list and I am not sure I entirely understand your scenario.

    Regards,
    Petya
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
DevCraft banner