Unplanned
Last Updated: 07 Dec 2016 11:56 by ADMIN
ADMIN
Tanya
Created on: 10 Oct 2016 08:44
Category: WordsProcessing
Type: Feature Request
15
WordsProcessing: Introduce a way to replace text with other document elements
Introduce an option to replace a Run text with line breaks and/or new lines or with other document elements such as Table, Image, Paragraph and etc. 

The following code snippet shows how a Run can be replaced with another inline element:

RadFlowDocument document = new RadFlowDocument();
RadFlowDocumentEditor editor = new RadFlowDocumentEditor(document);
 
editor.InsertText("text");
editor.InsertText("REMOVE");
editor.InsertText("text");
 
foreach (Run run in document.EnumerateChildrenOfType<Run>().ToList())
{
    if (run.Text == "REMOVE")
    {
        Paragraph paragraph = run.Paragraph;
        int childIndex = paragraph.Inlines.IndexOf(run);
 
        ImageInline image = new ImageInline(document);
        using (Stream stream = File.OpenRead("example_image.png"))
        {
            image.Image.ImageSource = new Telerik.Windows.Documents.Media.ImageSource(stream, "png");
        }
 
        paragraph.Inlines.Insert(childIndex, image);
        paragraph.Inlines.Remove(run);
    }
}
0 comments