I would replace the text %Doctors% at the runtime by a table. The following code does not work.
private void ReplaceAllMatches(string Parameter, Telerik.Windows.Documents.Model.Table NewTable)
{
this.myViewer.Document.Selection.Clear(); // this clears the selection before processing
DocumentTextSearch search = new DocumentTextSearch(this.myViewer.Document);
List<Telerik.Windows.Documents.TextSearch.TextRange> rangesTrackingDocumentChanges = new List<Telerik.Windows.Documents.TextSearch.TextRange>();
foreach (var textRange in search.FindAll(Parameter))
{
Telerik.Windows.Documents.TextSearch.TextRange newRange = new Telerik.Windows.Documents.TextSearch.TextRange(new DocumentPosition(textRange.StartPosition, true), new DocumentPosition(textRange.EndPosition, true));
rangesTrackingDocumentChanges.Add(newRange);
}
foreach (var textRange in rangesTrackingDocumentChanges)
{
this.myViewer.Document.Selection.AddSelectionStart(textRange.StartPosition);
this.myViewer.Document.Selection.AddSelectionEnd(textRange.EndPosition);
this.myViewer.InsertTable(NewTable,true);
textRange.StartPosition.Dispose();
textRange.EndPosition.Dispose();
}
}