This is a migrated thread and some comments may be shown as answers.

Border Created with RadFlowDocumentEditor not displayed in RadRichTextBox

1 Answer 553 Views
WordsProcessing
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 09 Oct 2019, 12:45 PM

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);
            }
}

 

 

1 Answer, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 14 Oct 2019, 12:43 PM

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.
Tags
WordsProcessing
Asked by
Michael
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Share this question
or