PdfFormatProvider creates an invalid PDF document.
Workaround:
RadDocument radDocument = null;
XamlFormatProvider xamlformatProvider = new XamlFormatProvider();
using (FileStream inputStream = new FileStream("input.xaml", FileMode.Open))
{
Console.WriteLine("reading input file");
radDocument = xamlformatProvider.Import(inputStream);
}
var provider = new Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.DocxFormatProvider();
var bytes = provider.Export(radDocument);
var provider2 = new Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider();
var flowDoc = provider2.Import(bytes);
var provider3 = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
using (Stream output = File.OpenWrite(@"output.pdf"))
{
Console.WriteLine("writing output file");
provider3.Export(flowDoc, output);
}
Console.WriteLine("done...");
Console.ReadKey();
HtmlFormatProvider: Exception when importing a table that has only width set. In this case, we are trying to measure some elements with float.NaN.
Workaround: Use the HtmlFormatProvider from the Document Processing library.
Numbered lists have invalid values when combining documents by using the InsertFragment method.
Workaround: use RadDocumentMerger:
RadDocument radDocument1 = RtfSourceProvider.Import(rtf1);
RadDocument radDocument2 = RtfSourceProvider.Import(rtf2);
AppendDocumentOptions options = new AppendDocumentOptions();
options.FirstSourceSectionPropertiesResolutionMode = SectionPropertiesResolutionMode.NoSectionBreak;
RadDocumentMerger merger = new RadDocumentMerger(radDocument1);
merger.AppendDocument(radDocument2, options);
RichText.Document = merger.Document;
The custom list styles from a document exported by RadRichTextBox's HtmlFormatProvider are not imported.
Loading large documents freezes the UI. Instead, the document could be imported and measured asynchronously in a background thread, and some progress indicator shown to the user.
Note: Image sources should be frozen when the document is loaded in a background thread.
Workaround: Following the steps:
- Import the document in a background thread using the specific format provider.
- Freeze all images in the document using the methods in the attached file.
- Set the document to RadRichTextBox in the main thread using a dispatcher: this.Dispatcher.Invoke(new Action(() => { this.radRichTextBox.Document = document; }));
Having a table with specified RowSpan and further exported to PDF does not draw the border. This is due to export optimization caused by the fact whether there is or is not a CellSpacing specified. Workaround: Set really small CellSpacing for the table.
Currently, RadRichTextBox only imports from HTML documents tables with spacing between cells, but it does not export tables with such style. It seems like the border-collapse: collapse value defined in the Table Normal style overrides the border-spacing value, which is applied to the cells. As a workaround, the document styles can be omitted from the exported HTML and the styling can be exported inline be changing the ExportSettings of HtmlFormatProvider: provider.ExportSettings.StylesExportMode = StylesExportMode.Inline; provider.ExportSettings.StyleRepositoryExportMode = StyleRepositoryExportMode.DontExportStyles;
There are a number of Bitmap objects that are not disposed. Changing this behavior could improve the memory usage when exporting PDF documents.
The caret gets a wrong size when positioned on annotation start/end.
- Localization for "Simple text" in the Define New List Style dialog and Define New Style dialog at RadRichTextBox. - Levels (from 1st to 9th) are hardcoded in dialog's code behind and cannot be localized. (these are the items in the 'Apply Formatting to' comboBox)
The "Text Wrapping" string, used in the FloatingBlockPropertiesDialog lacks translations in Spanish and French. In the English and Turkish values, a space is missing between the words. Fix available in LIB Version 2018.1.416.
When pasting a big image in RichTextBox, it is pasted with its original size. It should be resized so it can fit on the page. Similar logic is available in the InsertPictureCommand. Workaround: private void RadRichTextBox_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; var bitmapSource = Clipboard.GetImage(); if (bitmapSource == null) { return; } Padding sectionmargin = this.radRichTextBox.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.radRichTextBox.Document.LayoutMode == DocumentLayoutMode.Paged) { Section currentSection = this.radRichTextBox.Document.CaretPosition.GetCurrentSectionBox().AssociatedSection; var pageSize = (SizeF) currentSection.GetType().GetProperty("ActualPageSize", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(currentSection, null); 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; Size size = new Size(width, height); ImageInline imageInline = new ImageInline(new WriteableBitmap(bitmapSource)); imageInline.Size = size; this.radRichTextBox.ActiveDocumentEditor.InsertInline(imageInline); } }