Copy some text from the introduction docs page:
Paste in RadRichTextEditor from the Demo app:
When I have an InlineImage in a horizontally centered paragraph, PrintPreview presents the image unevenly on the page. There should be the same space on left and right, as the page padding is the same all around. See the arrows indicated below:
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();
To reproduce: - Add a word, press tab the add another word. - Export the document using HtmlFormatProvider. - Import the same document. - The tab is interpreted like 7 spaces.
Currently all tables are stuck to the let and there cannot be a text before them.
To reproduce: please refer to the attached sample project. Workaround: export RadRichTextEditor's content to a .doc file. Then, use the RadWordsProcessing library to import the .doc file and export it as a pdf: Telerik.WinForms.Documents.FormatProviders.OpenXml.Docx.DocxFormatProvider provider = new Telerik.WinForms.Documents.FormatProviders.OpenXml.Docx.DocxFormatProvider(); string fileName = @"..\..\exported.doc"; string pdfFileName = @"..\..\exported.pdf"; Stream s = new FileStream(fileName,FileMode.Create, FileAccess.Write); provider.Export(document, s); s.Close(); s.Dispose(); Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider provider2 = new Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider(); using (Stream input = File.OpenRead(fileName)) { Telerik.Windows.Documents.Flow.Model.RadFlowDocument document2 = provider2.Import(input); Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider provider3 = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider(); using (Stream output = File.OpenWrite(pdfFileName)) { provider3.Export(document2, output); } } System.Diagnostics.Process.Start(pdfFileName);
To reproduce: radRichTextEditor.Document = new RadDocument(); radRichTextEditor.Document.MeasureAndArrangeInDefaultSize(); radRichTextEditor.UpdateEditorLayout(); radRichTextEditor.Document.CaretPosition.MoveToLastPositionInDocument(); var p = new Paragraph(); p.Inlines.Add(new Span("Cell")); var cell = new TableCell(); cell.Blocks.Add(p); var row = new TableRow(); row.Cells.Add(cell); var table = new Table(); table.Rows.Add(row); var section = new Section(); section.Blocks.Add(table); radRichTextEditor.Document.Sections.Add(section); radRichTextEditor.Document.CaretPosition.MoveToLastPositionInDocument(); var provider = new RtfFormatProvider(); var txt = provider.Export(radRichTextEditor.Document); Clipboard.SetText(txt, TextDataFormat.Rtf); Workaround: measure the document after the section is added: radRichTextEditor.Document.Sections.Add(section); radRichTextEditor.Document.MeasureAndArrangeInDefaultSize(); radRichTextEditor.UpdateEditorLayout();
To reproduce: public Form1() { InitializeComponent(); this.radRichTextEditor1.IsReadOnly = true; } Workaround: private void Form1_Load(object sender, EventArgs e) { this.radRichTextEditor1.IsReadOnly = true; Telerik.WinControls.RichTextEditor.UI.DocumentWebLayoutPresenter webLayoutPresenter = this.radRichTextEditor1.RichTextBoxElement.ActiveEditorPresenter as Telerik.WinControls.RichTextEditor.UI.DocumentWebLayoutPresenter; webLayoutPresenter.Caret.Width = 0; }
To reproduce: Import the following rtf: string rtfText = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1031{\fonttbl{\f0\fnil\fcharset0 Arial;}{\f1\fnil\fcharset0 Tahoma;}{\f2\fnil\fcharset0 Times New Roman;}{\f3\fnil\fcharset0 Arial Unicode MS;}{\f4\fnil\fcharset0 Calibri;}} {\colortbl ;\red0\green0\blue0;} \viewkind4\uc1\pard\tx300\tx600\tx900\tx1200\tx1500\tx1800\tx2100\tx2400\tx2700\tx3000\tx3300\tx3600\tx3900\tx4200\tx4500\cf1\b\fs32 Arial\f1\par Tahoma\par \f2 Times New Roman\par \f0 Arial\f2\par \f3 Arial Unicode MS\par \f4 Calibri\b0\f0\fs20\par }"; RtfFormatProvider rtf = new RtfFormatProvider(); this.radRichTextEditor1.Document = rtf.Import(rtfText); this.richTextBox1.Rtf = rtfText;
Workaround: load an empty docx document in the RadRichTextEditor and use it as a template public RadDocument ImportDocx() { RadDocument document = null; IDocumentFormatProvider provider = new DocxFormatProvider(); OpenFileDialog openDialog = new OpenFileDialog(); openDialog.Filter = "Documents|*.docx"; openDialog.Multiselect = false; DialogResult dialogResult = openDialog.ShowDialog(); if (dialogResult == System.Windows.Forms.DialogResult.OK) { using (Stream stream = openDialog.OpenFile()) { document = provider.Import(stream); } } return document; }
To reproduce: Add image like this: void button_Click1(object sender, EventArgs e) { Section section = new Section(); Paragraph paragraph = new Paragraph(); ImageInline image; Telerik.WinControls.RichTextEditor.UI.Size size = new Telerik.WinControls.RichTextEditor.UI.Size(236, 50); using (MemoryStream ms = new MemoryStream()) { System.Drawing.Image.FromFile(@"C:\img\delete.png").Save(ms, System.Drawing.Imaging.ImageFormat.Png); image = new ImageInline(ms, size, "png"); } paragraph.Inlines.Add(image); section.Children.Add(paragraph); this.radRichTextEditor1.Document.Sections.Add(section); } Workaround: Manually update the layout: this.radRichTextEditor1.UpdateEditorLayout();
To reproduce: 1.Add some text to RadRichTextEditor. 2.Copy an image from a Word document and paste it to the RadRichTextEditor. 3.Export the document content with RtfFormatProvider. When you try to open the exported .rtf file via WordPad, you will notice that the image is not loaded. Please refer to the attached files created by MS Word and RadRichTextEditor.
When highlighting text inside the richtexteditor control I receive a null reference exception.
If you export a document using the HtmlFormatProvider, all style properties which contain measurement units are exported in pixel units. This makes the exported documents look much smaller when opened on devices with higher pixel density. WORKAROUND: use Regex to find, convert and replace the font-size attributes HtmlFormatProvider html = new HtmlFormatProvider(); string res = html.Export(document); Regex regex = new Regex(@"font-size: [0-9]*\.?[0-9]*px"); Match match = null; do { match = regex.Match(res); if (!match.Success) { break; } string value = match.Value.Substring("font-size: ".Length, match.Value.Length - "font-size: ".Length - "px".Length); double pts = double.Parse(value) * 72 / 96; res = res.Replace(match.Value, @"font-size: " + Math.Round(pts, 4) + "pt"); } while (match.Success); File.WriteAllText("output.html", res);