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

How to add RadDocument(template) to another RadDocument

1 Answer 77 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Fredrik
Top achievements
Rank 2
Fredrik asked on 11 Jan 2016, 07:13 PM

Here is the rub:

Basicly i work on a RadDocument within a RichTextBox. With the help of a combobox the user can insert templated documents within his current document.

This is allready storred as DocxFormat bytestream.

I have the following code: 

       private async Task DoInsertTemplate(DocumentGroups template, object par,byte[] templateContent )
        {
            byte[] contentarray = templateContent;
     

            var provider = new DocxFormatProvider();
            var documentTemplate = provider.Import(contentarray);

            var radRichTextBox = par as Telerik.Windows.Controls.RadRichTextBox;

            var documentOrginal = radRichTextBox.Document;

        }

So i have 2 diffrent RadDocuments, and i want to insert the documentTemplate at my current caret position, so that the documentTemplate can sometimes be "pasted" in the middle of my documentOrginal .

I have seen a post on how to merge documents after eachother(http://www.telerik.com/forums/how-to-merge-multiple-raddocuments-into-one-raddocument)

But that is not what i want.

How can i acheive the RadDocument "paste" at the current carret position?

 

1 Answer, 1 is accepted

Sort by
0
Fredrik
Top achievements
Rank 2
answered on 12 Jan 2016, 07:26 AM

Found the solution

One simple line

radRichTextBox.Document.InsertFragment(new DocumentFragment(templateDocument));

Tags
RichTextBox
Asked by
Fredrik
Top achievements
Rank 2
Answers by
Fredrik
Top achievements
Rank 2
Share this question
or