When a document is imported from HTML, we set locally to the span elements Times New Roman nevertheless it is not declared anywhere. This breaks the document view if for example we decide to change the RadDocument's default font family or even the NormalWeb style's font. The same applies for the font size as well.
Workaround: Clear the FontFamily property after import
foreach (Span span in this.radRichTextBox.Document.EnumerateChildrenOfType<Span>())
{
span.GetStyleProperty(Span.FontFamilyProperty).ClearValue();
span.GetStyleProperty(Span.FontSizeProperty).ClearValue();
}
Steps to reproduce:
1. Import the following html:
this.radRichTextBox.Document = new HtmlFormatProvider().Import(@"<h1>Hello</h1><h2>World</h2><p>Lorem ipsum<p>");
2. Set the document's default font family to Comic Sans MS:
this.radRichTextBox.Document.Style.SpanProperties.FontFamily = new FontFamily("Comic Sans MS");
Observe: The font in the document is Times New Roman
Expected: The font should be Comic Sans MS
The default browser paragraph spacing is not preserved during HTML import-export.
Workaround:
StyleDefinition normalStyle = this.radRichTextEditor1.Document.StyleRepository[RadDocumentDefaultStyles.NormalWebStyleName];
normalStyle.ParagraphProperties.SpacingAfter = 20;
normalStyle.ParagraphProperties.SpacingBefore = 20;
Importing this:
<p>This is a paragraph.</p>
<p>
This is a paragraph.
</p>
should import two identical paragraphs, but it actually import it like this:
This is a paragraph. This is a paragraph.
It has a leading space before the second paragraph.
RadRichTextEditor: The paste options popup stays visible when the control is hidden
Workaround:
((MiniToolBarBase)this.radRichTextEditor1.RichTextBoxElement.PasteOptionsPopup).Hide();
Pasting adds an additional paragraph that does not exist in the source(copy).
If the main document part of a DOCX document is with name different than "document.xml", for example "document2.xml", the content of the document is not imported. Such documents are created by OpenXML SDK, if for example this tutorial is followed: How to: Convert a word processing document from the DOCM to the DOCX file format - http://tpdogfood.telerik.com/msdn.microsoft.com/en-us/library/office/gg188063(v=office.15).aspx.
The paragraphs in the table are inheriting the negative indent from the previous paragraph.
Workaround: Manually remove the negative indent from the table paragraphs after the table is added.
The workaround in code:
private void RadRichTextEditor1_CommandExecuted(object sender, Telerik.WinForms.Documents.RichTextBoxCommands.CommandExecutedEventArgs e)
{
if (e.Command is InsertTableCommand)
{
var table = radRichTextEditor1.Document.CaretPosition.GetCurrentTable();
table.TableIndent = 0;
if (table != null)
{
foreach (var row in table.Rows)
{
foreach (var cell in row.Cells)
{
foreach (var block in cell.Blocks)
{
var paragrpah = block as Paragraph;
if (paragrpah != null && paragrpah.LeftIndent < 0)
{
paragrpah.LeftIndent = 0;
paragrpah.HangingIndent = 0;
}
}
}
}
}
radRichTextEditor1.RichTextBoxElement.Document.UpdateLayout();
}
}
The built-in Hyperlink style is not applied to hyperlinks imported from HTML (<a> tag). As a result, the hyperlinks in the document does not have the blue underline.
- Import the following HTML: <a href="http://google.com">test</a>