Telerik Forums
Telerik Document Processing Forum
1 answer
306 views

Hi guys,

I'm trying to add an ImageInLine into header (a classical Logo Company).

I would keep aspect ratio of my bitmap, but after export to word, it takes not effects.

I tryed to change PreferRelativeToOriginalResize to true and to false, when I try to open properties of image (into generated word file), I found this propertiy correctly changed.

But if I try to do same approach with LockAspectRatio to true and to false, It's ever false. Why?

This is my code to test.

I attached 4 test bitmap, 2 for PreferRelativeToOriginalResize (correctly results) and 2 for LockAspectRatio (wrong results)

editor.Document.HasDifferentEvenOddPageHeadersFooters = false;
var header = editor.Document.Sections.First().Headers.Add();
 
var image = header.Blocks.AddParagraph().Inlines.AddImageInline();
using (FileStream fs = File.Open(@"Resources\mylogo.jpg", FileMode.Open))
{
    image.Image.ImageSource = new Telerik.Windows.Documents.Media.ImageSource(fs, ".jpg");
    //image.Image.PreferRelativeToOriginalResize = false;
    image.Image.LockAspectRatio = true;
    //image.Image.SetWidth(true, 40);
}
Tanya
Telerik team
 answered on 12 Apr 2018
1 answer
216 views
Is there something special I need to keep in mind when converting Docx with images to a PDF? I tried to use the demo and my docx that had an image converted but the resulting pdf did not include the image.
Tanya
Telerik team
 answered on 06 Apr 2018
4 answers
508 views

How to get the text of BookMarks into a string variable. Following is my code.

#region Get Book Mark Data
        public void GetTextFromBookMarks(RadFlowDocument document)
        {
            IEnumerable<BookmarkRangeStart> bookmarkStart = document.EnumerateChildrenOfType<BookmarkRangeStart>();
            IEnumerable<BookmarkRangeEnd> bookmarkEnd = document.EnumerateChildrenOfType<BookmarkRangeEnd>();

            foreach (var item in bookmarkStart)
            {

            }

        }
        #endregion

Tanya
Telerik team
 answered on 03 Apr 2018
3 answers
2.5K+ views

Hello,

Could you please provide me an example or redirect me to a demo where pdf is created from stratch and/or pdf exported from the html input. We currently convert data populated WebForm pages into PDF files all on the server that are never delivered to a user via browser interaction, or even requested by a browser (automated generation.). Aside from an HTML source being easier to use and maintain, it would plug right into our existing situation and not require use to reconstruct our forms in C#. 

Thanks.

Tanya
Telerik team
 answered on 29 Mar 2018
1 answer
315 views

 

In my docx document I have a bookmark named: "SomeBookMark". "SomeBookMark" was created in msword while "SomeText" was selected.

In the telerik flowdocuments this would mean that BookmarkRangeStart would be placed before "SomeText" and BookmarkRangeEnd would be placed at the end of "SomeText".

 

I'm able to delete the bookmark and I am able to insert text before or after "SomeText". But effectively I would like to remove "SomeText" and insert my own text. I can see the text in the "inlines" of the paragraph that contains the bookmarks and the text but the way the inlines are populated depends heavily on how the word document was edited. From the word document it would look like "SomeText" was 1 inline entry but it might actually be more than 1. 

 

Is there any generic way to use the bookmarks to select the range of text between the start and end and replace or delete it?

Tanya
Telerik team
 answered on 28 Mar 2018
6 answers
937 views

when I import an Excel-Sheet with formulas,

in very simple cases,it converts correctly into a FormulaValueCell, gives me the formula and the GetResultValueAsString() gives the computed Value.

But with more complicated formulas, this doesn't seem to work.

 

 var value = sheet.Cells[6, 2].GetValue();
 var a = value.Value.GetResultValueAsString(CellValueFormat.GeneralFormat);
 var b = value.Value.GetValueAsString(CellValueFormat.GeneralFormat);
 var c = value.Value.RawValue;
 var d = value.Value.ValueType;

 

a"='[2]Übernahme 11-12'!C7"
b"='[2]Übernahme 11-12'!C7"
c"='[2]Übernahme 11-12'!C7"
d = Text

 

So first, it's generally wrong to consider this a text-cell

Second, in the xlsx File, there is a <v> Tag for each cell, containing the actual (numeric) value of a cell, even of formula cells.

Is there a way to access this computed value ? I can find the <v>100</v> Tag in the xlsx-File, but I don't find a way to access it.

Tanya
Telerik team
 answered on 28 Mar 2018
1 answer
354 views

How should I dispose the target object?

The file is kept locked...and cannot be accessed later by other code.

 Dim fileName As String = Server.MapPath("~/userfiles/file/excel/" & Session.SessionID & ".xlsx")

            Dim formatProvider As IWorkbookFormatProvider = New XlsxFormatProvider()

            Using output As New FileStream(fileName, FileMode.Create)
                formatProvider.Export(workbook, output)
            End Using

Anna
Telerik team
 answered on 26 Mar 2018
4 answers
190 views

Dear Sirs, 

I'm seaching for a pdf solution and found your product. Now I'm evaluating. 

In the documentation there is an example for creating a gradient:

 http://docs.telerik.com/devtools/aspnet-ajax/controls/pdfprocessing/concepts/colors-and-color-spaces

1.FixedContentEditor containerEditor = new FixedContentEditor(container);
2.LinearGradient linearGradient = new LinearGradient(new Point(0, 0), new Point(30, 30));
3.linearGradient.GradientStops.Add(new GradientStop(new RgbColor(0, 207, 0), 0));
4.linearGradient.GradientStops.Add(new GradientStop(new RgbColor(0, 102, 204), 0));
5. 
6.containerEditor.GraphicProperties.FillColor = linearGradient;
7.containerEditor.DrawRectangle(new Rect(10, 10, 48, 29));

If I copy these code I just get a monochrome rectangle filled with the color (0,102,204). 

 Any help would be fine.

 

many thanks in advance

 

Gustav Meier

Peter
Top achievements
Rank 1
 answered on 05 Mar 2018
1 answer
585 views

The spreadsheet widget supports array formulas with a manual Ctrl-Shift-Enter. (see bottom of https://docs.telerik.com/kendo-ui/controls/data-management/spreadsheet/end-user/list-of-formulas)

I want to do the same programmatically using the Spreadsheet.Model classes.

This example shows how I can set and get results of a simple calculation, however the array formula I want to use is an Error. 

Indeed, the Sample.xlsx it creates, when opened shows #N/A where the array formula is.  However, in Excel, when I edit the cell and do Ctrl-Shift-Enter, it is interpreted as an array formula and shows the proper result.  The same formula in the spreadsheet widget also works (kudos to the dev team -- array formulas can make you squirrely).

console output

Starting
B2 retrieved 1
B3 retrieved 10
b4FormulaCell: =B2+B3
b4Result.RawValue: 11
k9CellValue: Telerik.Windows.Documents.Spreadsheet.Model.RangePropertyValue`1[Telerik.Windows.Documents.Spreadsheet.Model.ICellValue]
k9FormulaCell: Telerik.Windows.Documents.Spreadsheet.Model.FormulaCellValue
k9FormulaCell.RawValue: =MATCH(MIN(ABS(K2:K4-K8)),ABS(K2:K4-K8),0)
k9FormulaCell.ResultValueType: Error
Finished

 

program

using System;
using System.IO;
using Telerik.Windows.Documents.Spreadsheet.FormatProviders.OpenXml.Xlsx;
using Telerik.Windows.Documents.Spreadsheet.Model;
 
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Starting");
 
            var workbook = new Workbook();
            var sheet = workbook.Worksheets.Add();
 
            // B2
            var b2 = sheet.Cells[1, 1];
            b2.SetValue(1);
            var b2CellValue = b2.GetValue();
            var b2NumCell = b2CellValue.Value as NumberCellValue;
            var b2Num = b2NumCell.Value;
 
            Console.WriteLine($"B2 retrieved {b2Num}");
 
            // B3
            var b3 = sheet.Cells[2, 1];
            b3.SetValue(10);
            var b3CellValue = b3.GetValue();
            var b3NumCell = b3CellValue.Value as NumberCellValue;
            var b3Num = b3NumCell.Value;
 
            Console.WriteLine($"B3 retrieved {b3Num}");
 
            // B4 = B2 + B3
            var b4 = sheet.Cells[3, 1];
            b4.SetValue("=B2+B3");
            var b4CellValue = b4.GetValue();
            var b4FormulaCell = b4CellValue.Value as FormulaCellValue;
            var b4Result = b4FormulaCell.GetResultValueAsCellValue();
 
            Console.WriteLine($"b4FormulaCell: {b4FormulaCell.RawValue}");
            Console.WriteLine($"b4Result.RawValue: {b4Result.RawValue}");
 
 
            sheet.Cells[1, 10].SetValue(6);         // K2
            sheet.Cells[2, 10].SetValue(7);         // K3
            sheet.Cells[3, 10].SetValue(8);         // K4
            sheet.Cells[4, 10].SetValue(100);       // K5
            sheet.Cells[5, 10].SetValue(1000);      // K6
            sheet.Cells[6, 10].SetValue(10000);     // K7
            sheet.Cells[7, 10].SetValue(7.1);       // K8
 

                 // https://www.extendoffice.com/documents/excel/1050-excel-find-closest-value.html
            
// goal use MATCH look up to find index of value in K2:K4 nearest to K8

            var arrayDiff = "ABS(K2:K4-K8)"// formula for computing nearness
            var matchFormula = $"=MATCH(MIN({arrayDiff}),{arrayDiff},0)"; // formula for computing index of nearest (smallest ABS diff)
 
            sheet.Cells[8, 10].SetValue(matchFormula); // K9, nearest index for 7.1 should be computed as 2, which corresponds to value of 7 in K3, which is the second item in K2:K4
 
            var k9 = sheet.Cells[8, 10];
            var k9CellValue = k9.GetValue();
            var k9FormulaCell = k9CellValue.Value as FormulaCellValue;
            // var k9Result = k9FormulaCell.GetResultValueAsCellValue();
 
            Console.WriteLine($"k9CellValue: {k9CellValue}");
            Console.WriteLine($"k9FormulaCell: {k9FormulaCell}");
            Console.WriteLine($"k9FormulaCell.RawValue: {k9FormulaCell.RawValue}");
            Console.WriteLine($"k9FormulaCell.ResultValueType: {k9FormulaCell.ResultValueType}");
            // Console.WriteLine($"k9Result.RawValue: {k9Result.RawValue}");
 
            using (var output = new FileStream(@"C:\Temp\Sample.xlsx", FileMode.Create))
            {
                new XlsxFormatProvider().Export(workbook, output);
            }
 
            Console.WriteLine("Finished");
        }
    }
}
Deyan
Telerik team
 answered on 05 Mar 2018
1 answer
917 views

Is there a way to take an existing Word document that is full of Word merge fields and replace them with merge fields that Telerik Document Processing understands («Zipcode» to MERGEFIELD Zipcode)?

I understand how I can create merge fields in code, but there are many templates with all sorts of formats and I would prefer to not have to recreate each one in code.  As a second option is there a way to do a replace text with a MERGEFIELD?  That would at least allow me to minimally modify the Word document. 

These Word templates will continue to be used outside of the web and ideally I would want a user to be able to select a template (.docx) to load with allowable merge fields, and then I take care of merging them via document processing and return the nicely merged document based on the data in our application.

I do not see how I can easily just translate between the two.

Tanya
Telerik team
 answered on 15 Feb 2018
Narrow your results
Selected tags
Tags
+? more
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?