1. Create a document containing a style with NextStyleName:
StyleDefinition myStyle = new StyleDefinition();
myStyle.Type = StyleType.Table;
myStyle.DisplayName = "My Style";
myStyle.Name = "myStyle";
myStyle.NextStyleName = RadDocumentDefaultStyles.HyperlinkStyleName;
this.radRichTextBox.Document.StyleRepository.Add(myStyle);
2. Add several paragraphs and select some of them (ensure there is one using our custom style).
3. Create a DocumentFragment using the selection's CopySelectedDocumentElements
4. Convert the fragment to RadDocument and try to export it
Observed: When exporting to DOCX and XAML, the style is missing. Exporting to RTF causes KeyNotFoundException.
Expected: The style should be preserved in the exported document
Workaround: After creating the document from the fragment, ensure all needed styles are copied and available.
To reproduce: - Open the demo application. - Go to the Table Styles example. - Open the TableBorders dialog from the context menu and hit reset all.
Workaround:
private void RadRichTextEditor1_CommandExecuting(object sender, CommandExecutingEventArgs e)
{
if (!(e.Command is PasteCommand))
{
return;
}
DocumentFragment res = ClipboardEx.GetDocumentFromClipboard("RadDocumentGUID");
if (res == null)
{
foreach (ClipboardHandler settings in ClipboardEx.ClipboardHandlers)
{
res = ClipboardEx.GetDocumentFromClipboard(settings.ClipboardDataFormat, settings.ClipboardStringFilter);
}
}
if (res == null)
{
e.Cancel = true;
System.Drawing.Image bitmapSource = Clipboard.GetImage();
if (bitmapSource == null)
{
return;
}
Telerik.WinForms.Documents.Layout.Padding sectionmargin = this.radRichTextEditor1.Document.CaretPosition.GetCurrentSectionBox().AssociatedSection.ActualPageMargin;
double originalPixelWidth = bitmapSource.Width;
double originalPixelHeight = bitmapSource.Height;
if (originalPixelWidth == 0 || originalPixelHeight == 0)
{
originalPixelWidth = 10;
originalPixelHeight = 10;
}
double width = originalPixelWidth;
double height = originalPixelHeight;
if (this.radRichTextEditor1.Document.LayoutMode == DocumentLayoutMode.Paged)
{
Section currentSection = this.radRichTextEditor1.Document.CaretPosition.GetCurrentSectionBox().AssociatedSection;
Telerik.WinForms.Documents.Model.SizeF pageSize = (Telerik.WinForms.Documents.Model.SizeF)currentSection.GetType().GetProperty("ActualPageSize", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(currentSection);
double maxWidth = pageSize.Width - (sectionmargin.Left + sectionmargin.Right);
double maxHeight = pageSize.Height - (sectionmargin.Top + sectionmargin.Bottom);
width = Math.Min(maxWidth, width);
height = Math.Min(maxHeight, height);
}
double ratio = originalPixelWidth / originalPixelHeight;
width = Math.Min(width, height * ratio);
height = width / ratio;
Telerik.WinControls.RichTextEditor.UI.Size size = new Telerik.WinControls.RichTextEditor.UI.Size(width, height);
ImageInline imageInline = new ImageInline(new WriteableBitmap(bitmapSource));
imageInline.Size = size;
this.radRichTextEditor1.RichTextBoxElement.ActiveDocumentEditor.InsertInline(imageInline);
}
}
To reproduce: - Load a right to left document with Hebrew characters. - Export it to PDF - The characters' position is not correct.
Workaround:
private void RadRichTextEditor1_CommandExecuting(object sender, Telerik.WinForms.Documents.RichTextBoxCommands.CommandExecutingEventArgs e)
{
if (e.Command is SaveCommand)
{
DocumentPosition initial = this.radRichTextEditor1.Document.CaretPosition;
DocumentPosition start = new DocumentPosition(initial);
DocumentPosition end = new DocumentPosition(initial);
var spans = this.radRichTextEditor1.Document.EnumerateChildrenOfType<Span>();
foreach (var span in spans)
{
if (span.FontStyle != FontStyle.Regular)
{
continue;
}
start.MoveToInline(span);
end.MoveToEndOfDocumentElement(span);
this.radRichTextEditor1.Document.Selection.AddSelectionStart(start);
this.radRichTextEditor1.Document.Selection.AddSelectionEnd(end);
this.radRichTextEditor1.RichTextBoxElement.Commands.ChangeFontFamilyCommand.Execute("Calibri");
}
this.radRichTextEditor1.Document.CaretPosition.MoveToPosition(initial);
}
}
Please refer to the attached screenshots. A sample .docx file is attached. Just load it in RadRichTextEditor.
Use attached to reproduce.
Workaround: If possible set the layout mode to FlowNoWrap this.radRichTextEditor1.Document.LayoutMode = Telerik.WinForms.Documents.Model.DocumentLayoutMode.FlowNoWrap;
To reproduce: run the Demo application >> RichTextEditor >> First Look example and follow the steps illustrated in the attached gif file.
1. First add a footnote in the text
2. Than select a part of the footnote text or all text and use the context menu to cut the text
3. Then, paste the text in the document, it doesn't matter were.
4. Next step is to remove the footnote reference.
5.Then, scroll through the document and press the right mouse button to open the context menu.
The object release should have been called and the context menu is disposed. If so the error occurs.
Workaround:
this.radRichTextEditor1.MouseClick += radRichTextEditor1_MouseClick;
private void radRichTextEditor1_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Right)
{
if (this.radRichTextEditor1.RichTextBoxElement.ContextMenu != null)
{
FieldInfo fi = typeof(Telerik.WinControls.RichTextEditor.UI.ContextMenu).GetField("radDropDownMenu", BindingFlags.Instance | BindingFlags.NonPublic);
RadDropDownMenu dropdown = fi.GetValue(this.radRichTextEditor1.RichTextBoxElement.ContextMenu) as RadDropDownMenu;
if (dropdown.IsDisposed)
{
this.radRichTextEditor1.RichTextBoxElement.ContextMenu = new Telerik.WinControls.RichTextEditor.UI.ContextMenu();
}
}
}
}
To reproduce: 1. Open the following article: https://aajtak.intoday.in/gallery/indonesian-tsunami-warning-earthquake-lombok-island-dead-body-1-24549.html 2. Copy its title 3. Paste in Notepad/Notepad++ 4. Copy from notepad 5. Paste in RTE
The spacing between the letters is too big.
Please refer to the attached gif file.
Let's take for instance demo application with its default document, with text "RadRichTextEditor for WinForms" at the beginning in font Calibri of size 28. Suppose the user wants to add A, then empty line, then C in single line, followed by the rest of the document, and to have these three new lines in Times New Roman in size 10.
1. Document created via MS-Word, Page orientation is set to Landscape. (MS-Word works OK)
2. Document read into Telerik RichTextEditor and print ignore Landscape settings.
3. Documet "Landscape.rtf" and snapshot in attachmet
please help me
To reproduce:
Type a word and then change the font. The RichTextEditor is not focused. When you click in it the font is restored.
Workaround:
class MyRichtTextEditorRibbonbar : RichTextEditorRibbonBar
{
public MyRichtTextEditorRibbonbar()
{
this.dropDownListFont.PopupClosed += DropDownListFont_PopupClosed;
}
private void DropDownListFont_PopupClosed(object sender, RadPopupClosedEventArgs args)
{
this.associatedRichTextEditor.Focus();
}
}
Dear Sir/Madam,
I have a docx document and want to display it in flow layoutmode. It works normally except it cannot show header at the beginning of the document and footer at the end of the document. Please help.
My code is similar as follows (Rte is the RadRichTextEditor control):
DocumentFormatProviderBase provider = new DocxFormatProvider();
Rte.SuspendLayout();
Rte.Document = provider.Import([Docx in byte array]);
Rte.RichTextBoxElement.BackColor = Color.White;
Telerik.WinControls.RichTextEditor.UI.DocumentWebLayoutPresenter presenter = (Telerik.WinControls.RichTextEditor.UI.DocumentWebLayoutPresenter)rte.RichTextBoxElement.ActiveEditorPresenter;
presenter.BackColor = Color.White;
presenter.Margin = new Padding(20);
Rte.ResumeLayout();
Rte.PerformLayout();