The RichTextBox internal logic that imports .docx documents (DocxFormatProvider) doesn't support elements that don't need direct content, but have both start and end tags. Instead such elements should use self-closing tags.
For example, instead of <w:vertAlign w:val="baseline"></w:vertAlign> it should be <w:vertAlign w:val="baseline"/>
When such element is read during import, issues may occur. Two main known issues here are with the w:vertAlign and Relationship tags.
Using
<w:vertAlign w:val="baseline"></w:vertAlign>
instead of
<w:vertAlign w:val="baseline"/>
throws NullReferenceException with the following stack trace:
System.NullReferenceException: 'Object reference not set to an instance of an object.' Telerik.Windows.Documents.FormatProviders.OpenXml.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.OpenXmlHelper.ConvertStringToBaselineAlignment(string value) Line 168 C# Telerik.Windows.Documents.FormatProviders.OpenXml.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.SpanStyleImporter.ReadBaselineAlignment(Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Parsing.Style style) Line 243 C# Telerik.Windows.Documents.FormatProviders.OpenXml.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.SpanStyleImporter.ReadStyle(Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Parsing.Style style) Line 88 C# Telerik.Windows.Documents.FormatProviders.OpenXml.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.StyleDefinitionsImporter.ReadSpanStyleProperties(Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Parsing.Style style) Line 278 C# Telerik.Windows.Documents.FormatProviders.OpenXml.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.StyleDefinitionsImporter.ReadStyle() Line 188 C# Telerik.Windows.Documents.FormatProviders.OpenXml.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.StyleDefinitionsImporter.Import() Line 67 C# Telerik.Windows.Documents.FormatProviders.OpenXml.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.DocxImporter.ReadXmlContentFromPackage(Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.DocxPartImporterBase importer) Line 430 C# Telerik.Windows.Documents.FormatProviders.OpenXml.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.DocxImporter.ReadXmlContentAndRelationsFromPackage(Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.DocxPartImporterBase importer) Line 406 C# Telerik.Windows.Documents.FormatProviders.OpenXml.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.DocxImporter.Import() Line 190 C# Telerik.Windows.Documents.FormatProviders.OpenXml.dll!Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.DocxFormatProvider.Import(System.IO.Stream input) Line 147 C# Telerik.Windows.Documents.dll!Telerik.Windows.Documents.FormatProviders.DocumentFormatProviderBase.Import(byte[] input) Line 90 C#
Using
<Relationship Id="rId00004" Target="styles.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"></Relationship>
instead of
<Relationship Id="rId00004" Target="styles.xml" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"/>
throws KeyNotFoundException with the following stack trace:
KeyNotFoundException: The given key was not present in the dictionary. System.ThrowHelper.ThrowKeyNotFoundException() in ThrowHelper.cs System.Collections.Generic.Dictionary<TKey, TValue>.this[TKey].get(TKey) in Dictionary.cs Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.PartRelationsImporter.GetRelationByID(string) in PartRelationsImporter.cs Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.DocxImporter.GetRelationByID(string) in DocxImporter.cs Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.MainDocumentImporter.BuildSection() in MainDocumentImporter.cs Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.MainDocumentImporter.BuildBody() in MainDocumentImporter.cs Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.MainDocumentImporter.BuildDocument() in MainDocumentImporter.cs Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.MainDocumentImporter.Import() in MainDocumentImporter.cs Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.DocxImporter.ReadXmlContentFromPackage(Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.DocxPartImporterBase) in DocxImporter.cs Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.DocxImporter.ReadXmlContentAndRelationsFromPackage(Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.Import.DocxPartImporterBase) in DocxImporter.cs
To work this around, import the document with the WordsProcessing library. If you need to display it in RadRichTextBox, you can export it again using the WordsProcessing library. This will normalize the tags. Then import it again using the RadDocument's DocxFormatProvider.
var dplDocxFormatProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider();
RadFlowDocument flowDocument = dplDocxFormatProvider.Import(File.ReadAllBytes("../../../test.docx"), null);
var docBytes = dplDocxFormatProvider.Export(flowDocument, null);
File.WriteAllBytes("../../../modified-doc.docx", docBytes);
var rtbDocxFormatProvider= new Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.DocxFormatProvider();
RadDocument document = rtbDocxFormatProvider.Import(File.ReadAllBytes("../../../modified-doc.docx"));
Bold/Italic does not work for some font styles.
This might be a framework limitation in WPF: https://www.telerik.com/forums/some-fonts-are-not-able-to-bold-italic
Sample fonts list:
Can be reproduced in the demo:
In our processes, it is very important to know if a change happened before or after another action. If all the revisions have zero seconds, it's impossible to determine the order of the changes when they happened in the same minute.
This is not a new bug introduce in SP2: it was there in SP1.
Document exported to DOCX with 2025 Q2 cannot be opened by 2025 Q1 or previous versions.
Workaround: Use document processing to fix the document.
var processing_provider = new Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider();
var document = processing_provider.Import(File.ReadAllBytes("C:\\Users\\test\\Downloads\\word1.docx"),null);
var bytes_ = processing_provider.Export(document, null);
var rtb_provider = new Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.DocxFormatProvider();
var doc = rtb_provider.Import(bytes_);
radRichTextBox.Document = doc;
Type in Japanese text in RichTextBox that word wraps beyond the first line and export it to PDF. The text should always be left aligned (as visually shown when typing) but has an "indent" when exported when the font is Segoe UI.
The operating system region and language needs to be set to Japanese.
RichTextBox seems to have several issues with Japanese, but being locked from visibility or edit is the biggest one.
To recreate, start typing in Japanese, push the "right" arrow after selecting the IME option desired, then hit "spacebar." This seems to duplicate the text, then when trying to continue to type into the text field the text is no longer visible (yet the IME does display).
The native WPF RichTextBox has no issues (and also supports partial selection, etc.).
I've attached a video to show the behavior with 2025 Q1 telerik.
*note:* This is on a machine with NVIDIA graphics. I mention this as there may be some issues with RichTextBox and the hardware... When I'm in a virtual machine with a completely Japanese environment and virtual graphics driver, there is NO text visible at all when trying to type into the RichTextBox. Works fine with other controls and wpf RichTextBox.
It seems that the first time a Center TextAlignment is applied to the selection, its length is cached. Because of this, when the selection content (text) changes the length is not updated, thus the text doesn't align properly. It aligns accord to the initial length of the context. The content doesn't update also if the alignment is reset.
To work this around, avoid the FlowNoWrap layout mode and use only Flow.
NullReferenceException is thrown when the document gets updated after TableRow objects were removed with the Remove method of the parent Rows collection of the Table.
The table.Rows.Remove method is not properly removing some of the rows.
Stacktrace:
Telerik.Windows.Documents.dll!Telerik.Windows.Documents.Model.TableGridMeasurer.CalculateTableCellMinMaxWidths(Telerik.Windows.Documents.Model.TableCell cell, float availableWidth) Line 137 C# Telerik.Windows.Documents.dll!Telerik.Windows.Documents.Model.TableGridMeasurer.CalculateTableMinMaxWidths(Telerik.Windows.Documents.Model.Table table, float availableWidth) Line 165 C# Telerik.Windows.Documents.dll!Telerik.Windows.Documents.Model.TableGridMeasurer.MeasureAutoFit(Telerik.Windows.Documents.Model.Table table, float availableWidth) Line 229 C# Telerik.Windows.Documents.dll!Telerik.Windows.Documents.Model.Table.RecalculateColumnWidths(float measureWidth) Line 1151 C# Telerik.Windows.Documents.dll!Telerik.Windows.Documents.Model.Table.RecalculateTableGrid(float measureWidth) Line 1249 C# Telerik.Windows.Documents.dll!Telerik.Windows.Documents.Layout.TableLayoutBox.MeasureOverride(Telerik.Windows.Documents.Model.SizeF availableSize) Line 265 C# Telerik.Windows.Documents.dll!Telerik.Windows.Documents.Layout.LayoutElement.MeasureCore(Telerik.Windows.Documents.Model.SizeF availableSize) Line 933 C# Telerik.Windows.Documents.dll!Telerik.Windows.Documents.Layout.LayoutElement.Measure(Telerik.Windows.Documents.Model.SizeF availableSize) Line 836 C# Telerik.Windows.Documents.dll!Telerik.Windows.Documents.Layout.SectionLayoutBox.MeasureOverrideInternal(Telerik.Windows.Documents.Model.SizeF availableSize) Line 721 C# Telerik.Windows.Documents.dll!Telerik.Windows.Documents.Layout.SectionLayoutBox.MeasureOverride(Telerik.Windows.Documents.Model.SizeF availableSize) Line 468 C# Telerik.Windows.Documents.dll!Telerik.Windows.Documents.Layout.LayoutElement.MeasureCore(Telerik.Windows.Documents.Model.SizeF availableSize) Line 933 C# Telerik.Windows.Documents.dll!Telerik.Windows.Documents.Layout.LayoutElement.Measure(Telerik.Windows.Documents.Model.SizeF availableSize) Line 836 C# Telerik.Windows.Documents.dll!Telerik.Windows.Documents.Layout.DocumentLayoutBox.MeasureOverrideInternal(Telerik.Windows.Documents.Model.SizeF availableSize) Line 223 C# Telerik.Windows.Documents.dll!Telerik.Windows.Documents.Layout.DocumentLayoutBox.MeasureOverride(Telerik.Windows.Documents.Model.SizeF availableSize) Line 150 C# Telerik.Windows.Documents.dll!Telerik.Windows.Documents.Layout.LayoutElement.MeasureCore(Telerik.Windows.Documents.Model.SizeF availableSize) Line 933 C# Telerik.Windows.Documents.dll!Telerik.Windows.Documents.Layout.LayoutElement.Measure(Telerik.Windows.Documents.Model.SizeF availableSize) Line 836 C# Telerik.Windows.Documents.dll!Telerik.Windows.Documents.Model.RadDocument.Measure(Telerik.Windows.Documents.Model.SizeF measureSize) Line 1515 C# Telerik.Windows.Documents.dll!Telerik.Windows.Documents.UI.DocumentPrintLayoutPresenter.MeasureOverride(System.Windows.Size availableSize) Line 714 C#
To work this around, use the DeleteTableRow method of the RadDocumentEditor.
RadDocumentEditor documentEditor = new RadDocumentEditor(document); documentEditor.DeleteTableRow(row);
The issue reproduces when track changes is enabled and new text is entered. After waiting some time and pressing the Backspace on the keyboard in order to delete a character, nothing happens. You should press the Backspace a second time in order to make the deletion work. After that you can delete the content normally.
The waiting time before pressing the Backspace is usually until the next minute of the clock comes. For example, you can write something at 14:55 and wait until 14:56. Then, press Backspace.
If you check the Output pane of Visual Studio you will see the following assertion failure message printed:
---- DEBUG ASSERTION FAILED ---- at Telerik.Windows.Documents.Model.RadDocumentEditor.DeleteTrackChanges(Boolean deletePrevious) in C:\PersonalFiles\Git\wpf\Controls\RichTextBox\Core\Model\RadDocumentEditor_Editing.cs:line 693 at Telerik.Windows.Documents.Model.RadDocumentEditor.Delete(Boolean deletePrevious) in C:\PersonalFiles\Git\wpf\Controls\RichTextBox\Core\Model\RadDocumentEditor_Editing.cs:line 85 at Telerik.Windows.Controls.RadRichTextBox.Telerik.Windows.Documents.Model.IDocumentEditor.Delete(Boolean deletePrevious) in C:\PersonalFiles\Git\wpf\Controls\RichTextBox\Core\UI\RadRichTextBox.cs:line 4890 at Telerik.Windows.Controls.RadRichTextBox.Delete(Boolean deletePrevious) in C:\PersonalFiles\Git\wpf\Controls\RichTextBox\Core\UI\RadRichTextBox.cs:line 4866 at Telerik.Windows.Documents.RichTextBoxCommands.DeleteCommand.ExecuteOverride(Object parameter) in C:\PersonalFiles\Git\wpf\Controls\RichTextBox\Core\RichTextBoxCommands\DeleteCommand.cs:line 57 at Telerik.Windows.Documents.RichTextBoxCommands.RichTextBoxCommandBase.Execute(Object parameter, Boolean focusCaret) in C:\PersonalFiles\Git\wpf\Controls\RichTextBox\Core\RichTextBoxCommands\RichTextBoxCommandBase.cs:line 316 at Telerik.Windows.Documents.RichTextBoxCommands.RichTextBoxCommandBase.Execute(Object parameter) in C:\PersonalFiles\Git\wpf\Controls\RichTextBox\Core\RichTextBoxCommands\RichTextBoxCommandBase.cs:line 285 at Telerik.Windows.Documents.RichTextBoxCommands.RichTextBoxRoutedCommand.Execute(Object parameter, RadRichTextBox radRichTextBox) in C:\PersonalFiles\Git\wpf\Controls\RichTextBox\Core\RichTextBoxCommands\RoutedCommands\RichTextBoxRoutedCommand.cs:line 57 at Telerik.Windows.Documents.RichTextBoxCommands.RichTextBoxRoutedCommand.CommandBindingHelper.CommandBinding_Executed(Object sender, ExecutedRoutedEventArgs e) in C:\PersonalFiles\Git\wpf\Controls\RichTextBox\Core\RichTextBoxCommands\RoutedCommands\RichTextBoxRoutedCommand.cs:line 17 at System.Windows.Input.CommandBinding.OnExecuted(Object sender, ExecutedRoutedEventArgs e) at System.Windows.Input.CommandManager.FindCommandBinding(Object sender, RoutedEventArgs e, ICommand command, Boolean execute) at System.Windows.Input.CommandManager.OnExecuted(Object sender, ExecutedRoutedEventArgs e) at System.Windows.UIElement.OnExecutedThunk(Object sender, ExecutedRoutedEventArgs e) at System.Windows.Input.ExecutedRoutedEventArgs.InvokeEventHandler(Delegate genericHandler, Object target) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted) at System.Windows.Input.RoutedCommand.ExecuteImpl(Object parameter, IInputElement target, Boolean userInitiated) at System.Windows.Input.RoutedCommand.Execute(Object parameter, IInputElement target) at System.Windows.Input.RoutedCommand.System.Windows.Input.ICommand.Execute(Object parameter) at Telerik.Windows.Documents.UI.Extensibility.DefaultInputHandler.HandleInput(RadRichTextBox richTextBox, PreviewEditorKeyEventArgs e) in C:\PersonalFiles\Git\wpf\Controls\RichTextBox\Core\RichTextBoxCommands\RoutedCommands\DefaultInputHandler.cs:line 54 at Telerik.Windows.Controls.RadRichTextBox.HandlePresenterKeyDown(PreviewEditorKeyEventArgs e) in C:\PersonalFiles\Git\wpf\Controls\RichTextBox\Core\UI\RadRichTextBox.cs:line 4612 at Telerik.Windows.Documents.UI.DocumentPresenterBase.HandleKeyDown(KeyEventArgs e) in C:\PersonalFiles\Git\wpf\Controls\RichTextBox\Core\UI\DocumentPresenterBase.cs:line 859 at Telerik.Windows.Documents.UI.DocumentPresenterBase.OnPreviewKeyDown(KeyEventArgs e) in C:\PersonalFiles\Git\wpf\Controls\RichTextBox\Core\UI\DocumentPresenterBase.cs:line 805