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

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

1 Answer 273 Views
WordsProcessing
This is a migrated thread and some comments may be shown as answers.
Kittipong
Top achievements
Rank 1
Kittipong asked on 23 Dec 2015, 09:46 AM

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);


 

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 23 Dec 2015, 02:18 PM
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
Tags
WordsProcessing
Asked by
Kittipong
Top achievements
Rank 1
Answers by
Todor
Telerik team
Share this question
or