This is the used code snippet:
static void Main(string[] args)
{
Telerik.WinForms.Documents.Model.RadDocument templateDocument = GetDocument("Template.rtf");
Telerik.WinForms.Documents.Model.RadDocument contentDocument = GetDocument("Content.rtf");
Telerik.WinForms.Documents.Model.Merging.InsertDocumentOptions options = new Telerik.WinForms.Documents.Model.Merging.InsertDocumentOptions();
options.ConflictingStylesResolutionMode = Telerik.WinForms.Documents.Model.Merging.ConflictingStylesResolutionMode.RenameSourceStyle;
options.InsertLastParagraphMarker = true;
Telerik.WinForms.Documents.Model.RadDocumentEditor templateEditor = new Telerik.WinForms.Documents.Model.RadDocumentEditor(templateDocument);
templateEditor.InsertFragment(new Telerik.WinForms.Documents.Model.DocumentFragment(contentDocument));
string mergedDocumentFilePath = "MergeDocumentsWithRichTextEditor.rtf";
File.Delete(mergedDocumentFilePath);
WriteDocToFile(templateDocument, mergedDocumentFilePath);
}
private static Telerik.WinForms.Documents.Model.RadDocument GetDocument(string rtfFilePath)
{
Telerik.WinForms.Documents.Model.RadDocument document = null;
var rtfImporter = new Telerik.WinForms.Documents.FormatProviders.Rtf.RtfFormatProvider();
using (Stream stream = File.OpenRead(rtfFilePath))
{
document = rtfImporter.Import(stream);
}
return document;
}
private static void WriteDocToFile(Telerik.WinForms.Documents.Model.RadDocument doc, string filename)
{
var rtfExporter = new Telerik.WinForms.Documents.FormatProviders.Rtf.RtfFormatProvider();
string rtfText = rtfExporter.Export(doc);
File.WriteAllText(filename, rtfText);
Process.Start(filename);
}
Observed result:
Expected result: keep the After spacing as it is in the original documents.
In the Fluent theme, the Font Size Dropdown of the SelectionMiniToolBar is not wide enough.
Copy some text from the introduction docs page:
Paste in RadRichTextEditor from the Demo app:
Copy some content and paste it in the editor. The PasteOptions dialog remains opened and if the user clicks the PrintPreview button an error occurs:
Stack trace:
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at Telerik.WinControls.RichTextEditor.UI.PasteOptionsPopup.OnRichTextBoxLayoutUpdated(Object sender, EventArgs e)
at Telerik.WinControls.Layouts.ContextLayoutManager.fireLayoutUpdateEvent()
at Telerik.WinControls.Layouts.ContextLayoutManager.UpdateLayout()
at Telerik.WinForms.Documents.UI.DocumentPrintPresenter.Telerik.WinForms.RichTextEditor.IDocumentEditorPresenter.UpdateLayout()
at Telerik.WinForms.RichTextEditor.RadRichTextBox.<>c__DisplayClass653_0.<UpdateEditorLayout>b__0()
at Telerik.WinForms.RichTextEditor.RadRichTextBox.UpdateEditorLayout(Boolean focusCarret, Boolean updateCaretSize, Boolean async)
at Telerik.WinForms.RichTextEditor.RadRichTextBox.set_ActiveEditorPresenter(IDocumentEditorPresenter value)
at Telerik.WinForms.RichTextEditor.RadRichTextBox.Telerik.WinControls.UI.IPrintable.BeginPrint(RadPrintDocument sender, PrintEventArgs args)
at Telerik.WinControls.UI.RadPrintDocument.OnBeginPrint(PrintEventArgs e)
at System.Drawing.Printing.PrintDocument._OnBeginPrint(PrintEventArgs e)
at System.Drawing.Printing.PrintController.Print(PrintDocument document)
at System.Drawing.Printing.PrintDocument.Print()
at System.Windows.Forms.PrintPreviewControl.ComputePreview()
at System.Windows.Forms.PrintPreviewControl.CalculatePageInfo()
at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
Open the Demo application >> RichTextEditor>> First Look example and open and empty document. Keep a random key pressed. You are expected to observe delayed text input:
Use the code below.
1. Click the first button to insert a link.
2. Click inside the link to move the cursor.
3. Click the second button to insert the yellow rectangle
4. Click the third button to export the HTML content.
Actual result: StackOverflow exception occurs
private void radButton1_Click(object sender, EventArgs e)
{
HyperlinkInfo info = new HyperlinkInfo()
{
NavigateUri = "http://www.google.com",
Target = HyperlinkTargets.Blank,
IsAnchor = false
};
this.radRichTextEditor1.InsertHyperlink(info, "www.google.com");
}
private void radButton2_Click(object sender, EventArgs e)
{
LightVisualElement button = new LightVisualElement();
button.Text = "My Button";
button.DrawFill = true;
button.BackColor = System.Drawing.Color.Yellow;
button.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
Section section = new Section();
Paragraph paragraph = new Paragraph();
InlineUIContainer container = new InlineUIContainer();
RadElementUIContainer radContainer = new RadElementUIContainer(button);
container.UiElement = radContainer;
container.Height = 25;
container.Width = 70;
paragraph.Inlines.Add(container);
section.Blocks.Add(paragraph);
RadDocument doc = new RadDocument();
doc.Sections.Add(section);
radRichTextEditor1.InsertFragment(new DocumentFragment(doc));
}
private void radButton3_Click(object sender, EventArgs e)
{
Telerik.WinForms.Documents.Model.RadDocument document = radRichTextEditor1.Document;
Telerik.WinForms.Documents.FormatProviders.Html.HtmlFormatProvider provider = new Telerik.WinForms.Documents.FormatProviders.Html.HtmlFormatProvider();
provider.ExportSettings.InlineUIContainerExporting += ExportSettings_InlineUIContainerExporting;
provider.ExportSettings.DocumentExportLevel = Telerik.WinForms.Documents.FormatProviders.Html.DocumentExportLevel.Fragment;
provider.ExportSettings.ExportFontStylesAsTags = true;
provider.ExportSettings.SpanExportMode = Telerik.WinForms.Documents.FormatProviders.Html.SpanExportMode.DefaultBehavior;
string htmlValue = provider.Export(document);
webBrowser1.DocumentText = htmlValue;
}
private void ExportSettings_InlineUIContainerExporting(object sender, Telerik.WinForms.Documents.FormatProviders.Html.InlineUIContainerExportingEventArgs e)
{
}
If you remove the last span of a paragraph (on a measured document), using the inline collection, a NullReferenceException is thrown.
As a workaround: either make sure the manipulation happens on a non-measured document, or remove the span by using the RichTextEditor's API:
this.radRichTextEditor.Document.Selection.AddDocumentElementToSelection(span);
this.radRichTextEditor.Delete(false);
To reproduce:
this.radRichTextEditor1.Text = null;
Add Korean language to your machine:
Then type 'rkskekfk'. The expected symbols are: "가나다라". However, if you try selecting the entered text, the last symbol disappears:
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
When changing the theme through ThemeResolutionService.ApplicationThemeName all the application gets changed. Except the ForeColor of the RadRichTextEditor does not get change. Hence the box displays black text on a dark background. Quite unreadable.
Assigning the theme directly in the designer makes everything renders ok.
Sample application attached.
Regrads,
Matthias