Telerik Forums
Telerik Document Processing Forum
0 answers
315 views

I would like to add a superscript to text I am adding to a block.  I tried adding the text to a block, and then a TextFragment to the block, but I can't seem to move the text up as a superscript.

block.InsertText(text ?? string.Empty);
var frag = new TextFragment(superscript);
frag.FontSize = fontSize - 2;
block.Insert(frag);

I tried using frag.TextRise but it doesn't seem to affect the vertical offset of the fragment no matter what values I use. I also tried using frag.Position, but that doesn't affect it either.   Clearly I am missing something.  Perhaps I should use another approach?

Thanks in advance,

Dudley Chapman

Dudley
Top achievements
Rank 1
 asked on 27 Apr 2022
0 answers
890 views

I am starting with the Telerik Document processing libraries.  I have a simple excel file that I would like to import into a list to work with in my program.  

I have an imported workbook and worksheet that seems to work.  When I try to get the data from a test cell however:


string test;
test = sheet.Cells[0,0].GetValue().ToString();

instead of returning the value I put in the cell I get:

"Telerik.Windows.Documents.Spreadsheet.Model.RangePropertyValue`1[Telerik.Windows.Documents.Spreadsheet.Model.ICellValue]"

 

I have been reading the documentation and can't figure out what I am doing wrong.  

 

(for the record:

test = sheet.Cells[0,0].GetValue().Value.ToString(); returns 

"Telerik.Windows.Documents.Spreadsheet.Model.NumberCellValue"

so it isn't helpful either.)

 

Steven
Top achievements
Rank 1
Iron
 asked on 26 Apr 2022
1 answer
332 views

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!

Dimitar
Telerik team
 answered on 22 Apr 2022
1 answer
647 views

I am receiving an error when trying to convert a word doc to a PDF.

 

Here is the code:

var docxPRovider = new Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider();
var pdfProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();

var docBytes = File.ReadAllBytes(path);
var document = docxPRovider.Import(docBytes);

var testFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "test.pdf");
var resultBytes = pdfProvider.Export(document);
File.WriteAllBytes(testFile, resultBytes);

 

Here is the error:

Could not load type 'System.Windows.Point' from assembly 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
   at Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.PdfExportSettings..ctor()
   at Telerik.Windows.Documents.Flow.FormatProviders.Pdf.Export.PdfExportSettings..ctor()
   at Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider..ctor()

The line in bold is where the error occurs. I verified I have WindowsBase and System.Windows as references in my project.

Any help would be appreciated.

Svilen
Telerik team
 answered on 05 Apr 2022
2 answers
457 views

Hi everyone,

in my company we are using Telerik WordProcessing to handle some docx templates by replacing placeholder in there with values we took from DB. Everything works well when we use ReplaceText of RadFlowDocumentEditor except when we have a string that contains '\n' character.

Basically, for a string like "Ipsum\nDolor\nSit\nAmet" when we call ReplaceText on a particular placeholder, we got a situation like this

Ipsum
Dolor
Sit
Amet

which seems look ok, but unfortunately just the first row keeps the font style that placeholder has, the others instead doesn't and fallback to default style.

Any idea how to solve this?

Thank you very much for your attention

Luigi
Top achievements
Rank 1
Iron
 answered on 05 Apr 2022
1 answer
194 views

Hi

 

are there any experiences with using the DocumentProcessing libraries in a Linux / k8s cloud env?

A lot of .net libraries have issued with this because they have a system.drawing reference.

In the documentation, I didn't find anything about this.

 

I plan to u see the document processing library in a .net 6 / c# web API project running in a linux docker image .,

are there any pitfalls?

many thanks in advance

 

Dimitar
Telerik team
 answered on 04 Apr 2022
1 answer
3.0K+ views
Is there a way to add a carriage return\line feed (like an Alt+Enter) in an Excel cell value?
Svilen
Telerik team
 answered on 28 Mar 2022
1 answer
226 views


public static void AddLabel(TableRow quartersRow1, string Label, alignment.HorizontalAlignment LabelAlignment = alignment.HorizontalAlignment.Right,  double Labelpreferwidth = 0, int labelColSpan = 1, double LabelFontSize = 10, bool ShowBorder = false)
        {
            TableCell Labelcell = quartersRow1.Cells.AddTableCell();
            Labelcell.PreferredWidth = Labelpreferwidth;
            Labelcell.ColumnSpan = labelColSpan;
            if (ShowBorder) Labelcell.Borders = new TableCellBorders(border, border, border, border);
            Block Lblock = Labelcell.Blocks.AddBlock();
            Lblock.HorizontalAlignment = LabelAlignment;
            Lblock.TextProperties.FontSize = LabelFontSize;
            Lblock.InsertText(genericfontfamily, FontStyles.Normal, FontWeights.Bold, Label ?? "");
            
        }


We have recently migrated our application from .Net framework to .Net Core. Earlier the label we used to print in the PDF were bold, but now since we have migrated the application the bold font is showing as normal font.

The code mentioned above was giving the bold fonts for the labels in the PDF.  

Can you please let me know what changes would be needed here for the desired output.

Dimitar
Telerik team
 answered on 21 Mar 2022
1 answer
227 views

I would like to format a range of cells in an Excel Worksheet that are already part of a named range. How is it possible to format this table in the Excel worksheet with banded rows? I want it just like Excel does it for a table formatting.

Is this banding of rows possible with the present Telerik SpreadProcessing library?

Tanya
Telerik team
 answered on 17 Mar 2022
0 answers
255 views

Hi,

I'm working on document word processing. My task is quite simple, basically I need to take a DOCX template, manipulate it by replacing some fields, with values taken from other parts, and adding some TableRow on it and, finally, I need to export it into PDF format.

This works but unfortunaley the PDF I see is not equal to the docx template from where I start, so do you know some workaround that may help me to fix this issue.

Thank you for your attention.

Luigi
Top achievements
Rank 1
Iron
 asked on 16 Mar 2022
Narrow your results
Selected tags
Tags
+? more
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?