I can't add the HTML in a table for wordsporcessing

2 posts, 0 answers
  1. Kittipong
    Kittipong avatar
    5 posts
    Member since:
    Sep 2013

    Posted 23 Dec 2015 Link to this post

    First I create the table by editor like this

    RadFlowDocument tableDoc = new RadFlowDocument();
    RadFlowDocumentEditor editor = new RadFlowDocumentEditor(tableDoc);
    Telerik.Windows.Documents.Flow.Model.Table newTable = editor.InsertTable(1, 2);

         newTable.Rows[0].Cells[0].Borders = new TableCellBorders(
                   new Telerik.Windows.Documents.Flow.Model.Styles.Border(1, Telerik.Windows.Documents.Flow.Model.Styles.BorderStyle.Single, ThemableColor.FromArgb(100, 0, 100, 0)),
                   new Telerik.Windows.Documents.Flow.Model.Styles.Border(1, Telerik.Windows.Documents.Flow.Model.Styles.BorderStyle.None, ThemableColor.FromArgb(100, 0, 100, 0)),
                   new Telerik.Windows.Documents.Flow.Model.Styles.Border(1, Telerik.Windows.Documents.Flow.Model.Styles.BorderStyle.Single, ThemableColor.FromArgb(100, 0, 100, 0)),
                   new Telerik.Windows.Documents.Flow.Model.Styles.Border(1, Telerik.Windows.Documents.Flow.Model.Styles.BorderStyle.Single, ThemableColor.FromArgb(100, 0, 100, 0)));

     and prepare  the html string (with convert function) like this

    string html = "<p>HTML STR   1234<span style=\"line-height:20px;\">1234   1234  </span></p>";
               HtmlFormatProvider providerHtml = new HtmlFormatProvider();
               RadFlowDocument document = providerHtml.Import(html); 

    but I don't know how to put " RadFlowDocument " into table I 'm already try this but it show some error "The document element is associated with another document.
    Parameter name: item"  . Please Help!!

    Paragraph paragraph = new Paragraph(document);
     newTable.Rows[0].Cells[0].Blocks.Insert(0, paragraph);


     

     

     

     

     

     

  2. Todor
    Admin
    Todor avatar
    168 posts

    Posted 23 Dec 2015 Link to this post

    Hi Kittipong,

    Thank you for your interest in RadWordsProcessing.

    In order to insert whole documents at a specific position into a RadFlowDocument, you could use the RadFlowDocumentEditor's InsertDocument() method. More about it, you can read in this help article. However, with this approach, you wouldn't be able to insert the document into a table. You can see what will be the results when documents are inserted in specific positions in the mentioned help article.

    Fortunately, when the scenario requires elements to be inserted from one to another RadFlowDocument objects, the DocumentElementImporter class can be used.

    I hope this helps.
    If you need further assistance, please get back to us again.

    Regards,
    Todor
    Telerik
Back to Top