After import, Telerik is selecting the wrong table style

1 Answer 152 Views
PdfProcessing WordsProcessing
Alex
Top achievements
Rank 1
Alex asked on 21 Apr 2022, 05:32 PM

Hi all,

Were using Telerik libraries for .Net Framework are trying to import an existing docx file and then export it as a PDF. While doing this we noticed that after importing the docx file using DocxFormatProvider the existing table on the docx file selects the wrong theme.

We want to use 'Grid Table 4 - Accent 5' but after the import, the table style gets converted to 'Grid Table 4 - Accent 1'. We can't really specify a direct table style since the document that will be imported and converted to a PDF can have different table styles.

Is there a way to make this work with our current table style and other table styles? Here's the nuget packages we currently have installed to the project

 

And here's the code we are using

public static byte[] ConvertDocxToPdf(byte[] inputStream, Core.Models.Common.Document.Watermark watermark = null)
        {
            var docxFormatProvider = new DocxFormatProvider();
            var radFixedDocumentProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();

            var radFlowDocument = docxFormatProvider.Import(inputStream);
            var radFlowDocumentEditor = new RadFlowDocumentEditor(radFlowDocument);

            if (watermark != null)
            {
                var watermarkSettings = new TextWatermarkSettings()
                {
                    Text = watermark?.Text,
                    FontFamily = new System.Windows.Media.FontFamily(watermark.FontName),
                    Angle = watermark.Angle,
                    Height = watermark.FontHeight,
                    Width = watermark.FontWidth,
                    ForegroundColor = ToMediaColor(watermark.Color),
                    Opacity = watermark.Opacity
                };

                var textWatermark = new Telerik.Windows.Documents.Flow.Model.Watermarks.Watermark(watermarkSettings);
                for (int i = 0; i < radFlowDocumentEditor.Document.Sections.Count(); i++)
                {
                    var sectionToModify = radFlowDocumentEditor.Document.Sections[i];
                    var header = sectionToModify.Headers.Default;
                    var copyWatermark = textWatermark.Clone();

                    if (header == null)
                    {
                        header = sectionToModify.Headers.Add(HeaderFooterType.Default);
                    }

                    radFlowDocumentEditor.SetWatermark(copyWatermark, header);
                }
            }

            return radFixedDocumentProvider.Export(radFlowDocument);
        }

 

Also, here's the table we are importing


And after importing as a RadFlowDocument, if we do radFlowDocumentEditor.Export and then save the bytes as a docx file, this is the resulted table 


Thanks in advance!

1 Answer, 1 is accepted

Sort by
1
Accepted
Dimitar
Telerik team
answered on 22 Apr 2022, 08:36 AM

Hello Alex,

This feature is not supported in the WordsProcessing library and this is why you are getting such results. We have a feature request for it on our feedback portal. You can track its progress, subscribe to status changes, and add your comment to it here: WordsProcessing: Conditional Table Styles.

I am afraid I cannot suggest a temporary solution for this case. 

I want to apologize for the inconvenience this missing functionality is causing you.

Regards,
Dimitar
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Alex
Top achievements
Rank 1
commented on 10 May 2022, 02:59 PM | edited

Alright, thanks! This helps a lot.

Excited to hear when this is added into the Pdf / Word processing library.

Tags
PdfProcessing WordsProcessing
Asked by
Alex
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Share this question
or