Border Created with RadFlowDocumentEditor not displayed in RadRichTextBox

2 posts, 0 answers
  1. Michael
    Michael avatar
    22 posts
    Member since:
    Apr 2011

    Posted 09 Oct 2019 Link to this post

    Borders I am creating with RadFlowDocumentEditor are not displayed in Radrichtextbox, to demonstrate here is my test code, I am using Telerik UI for WPF R2 2019.

    Attached is the file, also how it is displayed in Word and the how it is displayed in the RadRichTextBox inside my application.

     

    using System.Windows;
    using System.Windows.Controls;
    using Telerik.Windows.Controls;
    using Telerik.Windows.Documents.FormatProviders.Html;
    using System.Linq;
    using System;
    using System.IO;
    using Telerik.Windows.Documents.Flow.Model;
    using Telerik.Windows.Documents.Flow.Model.Editing;
    using Telerik.Windows.Documents.Flow.Model.Styles;
    using Telerik.Windows.Documents.Spreadsheet.Model;
     
     public void CreateCell(RadFlowDocumentEditor documentEditor, Table table, int row, int column, string text, FontWeight fw, float Width, Alignment alignment, double fs = 0)
            {
                while (table.Rows[row].Cells.Count < (column + 1))
                {
                    table.Rows[row].Cells.AddTableCell();
                }
                Paragraph newPara = table.Rows[row].Cells[column].Blocks.AddParagraph();
                table.Rows[row].Cells[column].PreferredWidth = new TableWidthUnit(Width);
                table.Rows[row].Cells[column].Padding = new Telerik.Windows.Documents.Primitives.Padding(2);
                newPara.TextAlignment = alignment;
                documentEditor.MoveToParagraphStart(newPara);
                var line = documentEditor.InsertText(text);
                line.FontWeight = fw;
                if (fs > 0) line.FontSize = fs;
            }
     
            private void radButtonTest_Click(object sender, RoutedEventArgs e)
            {
                //produce test doc
                Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider provider = new Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider();
                RadFlowDocument document = new RadFlowDocument();
                RadFlowDocumentEditor documentEditor = new RadFlowDocumentEditor(document);
           
                //create table
                Table table = documentEditor.InsertTable(1, 3);
                //header
                double fsText = Telerik.Windows.Documents.Model.Unit.PointToDip(10);
                var row = 0;
                CreateCell(documentEditor,table, row, 0, "Time", FontWeights.Bold, 80, Alignment.Left, fsText);
                CreateCell(documentEditor, table, row, 1, "Type", FontWeights.Bold, 200, Alignment.Left, fsText);
                CreateCell(documentEditor, table, row, 2, "Location", FontWeights.Bold, 230, Alignment.Left, fsText);
                table.Rows[row].Cells[0].Shading.BackgroundColor = new ThemableColor(Telerik.Windows.Documents.Spreadsheet.Theming.ThemeColorType.Accent1, 0.5);
                table.Rows[row].Cells[1].Shading.BackgroundColor = new ThemableColor(Telerik.Windows.Documents.Spreadsheet.Theming.ThemeColorType.Accent1);
                table.Rows[row].Cells[2].Shading.BackgroundColor = new ThemableColor(Telerik.Windows.Documents.Spreadsheet.Theming.ThemeColorType.Accent1, 0.9);
                //add rows
                table.Rows.AddTableRow();
                row++;
                CreateCell(documentEditor, table, row, 0, DateTime.Now.ToString("HH:mm:ss"), FontWeights.Normal, 80, Alignment.Left, fsText);
                CreateCell(documentEditor, table, row, 1, "Value " + row.ToString(), FontWeights.Normal, 200, Alignment.Left, fsText);
                CreateCell(documentEditor, table, row, 2, "Loc " + row.ToString(), FontWeights.Normal, 230, Alignment.Left, fsText);
                table.Rows[row].Cells[0].Borders = new TableCellBorders(new Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.None)
                    , new Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.Double)
                    , new Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.None)
                    , new Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.None));
                table.Rows[row].Cells[1].Borders = new TableCellBorders(new Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.None)
                   , new Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.Double)
                   , new Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.None)
                   , new Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.None));
                table.Rows[row].Cells[2].Borders = new TableCellBorders(new Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.None)
                   , new Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.Double)
                   , new Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.None)
                   , new Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.None));
     
                table.Rows.AddTableRow();
                row++;
                CreateCell(documentEditor, table, row, 0, DateTime.Now.ToString("HH:mm:ss"), FontWeights.Normal, 80, Alignment.Left, fsText);
                CreateCell(documentEditor, table, row, 1, "Value " + row.ToString(), FontWeights.Normal, 200, Alignment.Left, fsText);
                CreateCell(documentEditor, table, row, 2, "Loc " + row.ToString(), FontWeights.Normal, 230, Alignment.Left, fsText);
               
                table.Borders = new TableBorders(
                                new Telerik.Windows.Documents.Flow.Model.Styles.Border(BorderStyle.Single));
                //save test file
                using (Stream output = new FileStream(@"c:\temp\testdoc.docx", FileMode.OpenOrCreate))
                {
                    provider.Export(document, output);
                }
    }

     

     

  2. Georgi
    Admin
    Georgi avatar
    49 posts

    Posted 14 Oct 2019 Link to this post

    Hi Michael,

    Thank you for sharing the sample code with us.

    After taking a look, I noticed that the border thickness of the Table and the TableCell borders are not specified. When the border thickness is not specified, the border is exported with a default value of zero. However, by specification, the default value of the exported borders thickness should be two, which causes the issues you are currently encountering. We have logged this in our feedback portal: Table and TableCell borders width is exported with default value of zero when not specified, where you can subscribe to be notified for any status updates. As a possible workaround, you may specify the border thickness when the border instance is created. For example:

    table.Borders = new TableBorders(new Border(thickness, BorderStyle.Single, new ThemableColor(Colors.Black)));

    In appreciation for pointing out this to our attention, I have increased your Telerik points.

    Regards,
    Georgi
    Progress Telerik

    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top