Telerik Forums
Telerik Document Processing Forum
2 answers
1,000 views
Hello, I wonder if you can help with my issue.

In short, I am getting the exception (as in the post's title) when I get to the following line of code:


document = new RadFixedDocument();

RadFixedPage page = document.Pages.AddPage();
                
editor = new FixedContentEditor(page); // <<-- exception here



The things to note are:

1. No exception is thrown when the project is run from Visual Studio.

2. The exception is thrown when the merged assembly is run, that is after it has been merged with ILMerge.

3. The merging worked fine UNTIL I have added the Telerik.WinControls.PdfViewer.dll (and the related Telerik.Windows.Documents.Core.dll and  Telerik.Windows.Documents.Fixed) assemblies to ILMerge script and then tried to instantiate the FixedContentEditor when executing the merged assembly. 

That is, I have been using ILMerge for months with over 20 merged Telerik assemblies--no problem! It's only now that I started instantiating the FixedContentEditor so I assume it is the merged Telerik.Windows.Documents.Fixed.dll assembly that's throwing a wobbly somewhere.

By the way, the ILMerge throws no errors or warnings and the merging completes just fine. When I then run the merged assembly, it runs fine until I access the function that executes the code snipped above (that is, all other Telerik controls render correctly, etc.).

This seems to indicates it is not an issue with the ILMerge process per se. I wonder if there are some weird WPF dependencies somewhere. Even though it is a WinForms project and according to the Telerik documentation the FixedContentEditor can be used in WinForm applications, I noticed I had to refer to WindowsBase.dll in the project references because of two silly lines of code which refer to the System.Windows.Size struct.

    maxWidth = page.Size.Width - defaultLeftIndent * 2;   <<-- does not compile without WindowsBase.dll reference add
     maxHeight = page.Size.Height - currentTopOffset * 2; <<-- does not compile without WindowsBase.dll reference add



I have attached the merge script below and also screenshots my project references and successfully completed ILMerge process.

Thank you!

-----------------
merge.bat below


ilmerge /target:winexe /out:F:\OFFLINE\GULMAY\VMP1_Pro\Setup\VMP2.exe /targetplatform:"v4, C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0" F:\OFFLINE\GULMAY\VMP1_Pro\VMP1Pro\VMP1Pro\bin\Release\VMP2.exe TelerikCommon.dll Telerik.WinControls.UI.dll Telerik.WinControls.dll Telerik.WinControls.Themes.Windows7.dll Telerik.WinControls.Themes.VisualStudio2012Light.dll Telerik.WinControls.Themes.VisualStudio2012Dark.dll  Telerik.WinControls.Themes.TelerikMetroBlue.dll Telerik.WinControls.Themes.TelerikMetro.dll Telerik.WinControls.Themes.Office2013Light.dll Telerik.WinControls.Themes.Office2013Dark.dll Telerik.WinControls.Themes.Office2010Silver.dll Telerik.WinControls.Themes.Office2010Blue.dll  Telerik.WinControls.Themes.HighContrastBlack.dll Telerik.WinControls.Themes.Desert.dll Telerik.WinControls.Themes.Breeze.dll Telerik.WinControls.Themes.Aqua.dll Telerik.WinControls.GridView.dll Telerik.Windows.Documents.Core.dll Telerik.Windows.Documents.Fixed.dll Telerik.Windows.Zip.dll Telerik.WinControls.PdfViewer.dll 











gulmay
Top achievements
Rank 1
 answered on 07 Nov 2014
1 answer
286 views
hi,

I'm trying to import an existing word template into a RadFlowDocument, edit it by filling the merge fields and display it on the screen (read-only).
Can anyone please assist me with this. The word templates also contains a header, which contains images and text boxes.
The File.OpenRead command returns an error, as it is unable to read the document into a stream (object reference not set to an instance of an object).
Petya
Telerik team
 answered on 21 Oct 2014
1 answer
324 views
Hi,

When I generate a Worksheet with foreground colors for every row this is slow for small Excel files (say 1000 rows and 25 columns) and runs out memory for a 4000 row by 25 column Excel (the .xls file without the colors is about 400k). When I comment out the color code below it is significantly faster (about 5 times) and doesnt run out of memory.

Regards,

Bayram


private static Workbook CreateWorkbook(RadGridView grid, IEnumerable<string> skipColumns)
{
    Workbook book = new Workbook();
    book.Sheets.Add(SheetType.Worksheet);
    Worksheet sheet = book.ActiveWorksheet;
 
    Color accentBorder = Office2013Palette.Palette.AccentColor;
    Color transparent = Colors.Transparent;
    Color black = Colors.Black;
    Color white = Colors.White;
 
    ThemableColor themeBlack = new ThemableColor(Color.FromArgb(0,0,0,0));
    ThemableColor themeWhite = new ThemableColor(Color.FromArgb(0, 255, 255, 255));
 
    CellBorder border = new CellBorder(CellBorderStyle.Thin, themeBlack);
    CellBorder noBorder = new CellBorder(CellBorderStyle.None, themeBlack);
    CellBorders borders = new CellBorders(border, border, border, border, border, border, noBorder, noBorder);
 
    int rowNumber = 0;
    int colNumber = 0;
    foreach (var column in grid.Columns)
    {
        if (column.Header is string)
        {
            string columnHeader = (string)column.Header;
            if (skipColumns == null || !skipColumns.Contains(columnHeader))
            {
                sheet.Cells[rowNumber, colNumber].SetValue(columnHeader);
                colNumber++;
            }
        }
    }
    CellSelection selection = sheet.Cells[0,0,0,colNumber-1];
    selection.SetIsBold(true);
    PatternFill solidPatternFill = new PatternFill(PatternType.Solid, accentBorder, transparent);
    selection.SetFill(solidPatternFill);
    selection.SetForeColor(themeWhite);
 
    HashSet<int> textColumns = new HashSet<int>();
    rowNumber++;
    foreach (var item in grid.Items)
    {
        if (item is DynRecord)
        {
            DynRecord record = (DynRecord)item;
            colNumber = 0;
 
            foreach (var column in grid.Columns)
            {
                if (column.Header is string)
                {
                    string columnHeader = (string)column.Header;
                    if (skipColumns == null || !skipColumns.Contains(columnHeader))
                    {
                        if (column is GridViewDataColumn)
                        {
                            GridViewDataColumn dataColumn = (GridViewDataColumn)column;
                            string propName = dataColumn.DataMemberBinding.Path.Path;
 
                            object value = record.Value(propName);
                            if (value != null)
                            {
                                if (value is string)
                                {
                                    textColumns.Add(colNumber);
                                    sheet.Cells[rowNumber, colNumber].SetValue((string)value);
                                }
                                else if (value is DateTime)
                                    sheet.Cells[rowNumber, colNumber].SetValue((DateTime)value);
                                else if (value is Decimal)
                                    sheet.Cells[rowNumber, colNumber].SetValue(Convert.ToDouble((decimal)value));
                                else
                                {
                                    textColumns.Add(colNumber);
                                    sheet.Cells[rowNumber, colNumber].SetValue(value.ToString());
                                }
                            }
                        }
                        colNumber++;
                    }
                }
            }
            // This part is slow and runs out of memory
            //Color color = record.GetRecordColor().Color;
            //if (color != Colors.Black)
            //{
            //    selection = sheet.Cells[rowNumber, 0, rowNumber, colNumber - 1];
            //    selection.SetForeColor(new ThemableColor(color));
            //}
 
            rowNumber++;
        }
    }
    selection = sheet.Cells[0, 0, rowNumber-1, colNumber - 1];
    selection.SetBorders(borders);
 
 
    // Set Text columns formatting to @ to prevent Excel autoformatting
    foreach (int i in textColumns)
    {
        selection = sheet.Cells[1, i, rowNumber - 1, i];
        selection.SetFormat(new CellValueFormat("@"));
    }
 
    // AutoFitWidth
    for (int i = 0; i < colNumber - 1; i++)
    {
        ColumnSelection columnSelection = sheet.Columns[i];
        columnSelection.AutoFitWidth();
        double width = sheet.Columns[i].GetWidth().Value.Value * 1.1;
        columnSelection.SetWidth(new ColumnWidth(width, false));
    }
 
    return book;
}
Anna
Telerik team
 answered on 17 Oct 2014
1 answer
126 views
In excel you can open a document and go to File->Properties where in custom tab you can enter a custom property (with value) to the document.

Is it possible to do this in an excel workbook created with SpreadProcessing?
Nikolay Demirev
Telerik team
 answered on 10 Oct 2014
5 answers
208 views
Hi,

Setting:

TextProperties.Font = FontsRepository.Helvetica

Editor.DrawText("æøåÆØÅ")

Gives an error

Any setting for nordic letters I am missing?

Regards,
Brian
Kammen
Telerik team
 answered on 30 Sep 2014
1 answer
98 views
Hi,

When trying to overwrite an already created pdf file using the following code:

      Dim OutStream As New FileStream(Me.FileName, FileMode.Create)
      PdfFormatProvider.Export(Me.PDFDocument, OutStream)
      OutStream.Close()

I get an error "File is being used by an other process"

What do I miss in ending the first operation?

Regards,
Brian
Kammen
Telerik team
 answered on 29 Sep 2014
1 answer
76 views
Hi,

Using Clipping and having defined a clipping rectangle: I am searching for a "IsVisible" function like the one in System.Drawing.Graphics.

The purpose is to reduce file size by excluding eg. text, which will not be visible because of the clipping.

Regards,
Brian
Kammen
Telerik team
 answered on 29 Sep 2014
1 answer
198 views
Hi,

I would like to apply multiple transformation to FixedContentEditor.Position

However, the MatrixPosition class seems not to apply to the FixedContentEditor

And eg. the Editor.Position.Matrix.TranslatePrepend function does not seem to work, because Editor.Position.Matrix is readonly.

Regards,
Brian
Kammen
Telerik team
 answered on 29 Sep 2014
1 answer
610 views
Hi,

Your example shows how to insert jpg image from file:

Using stream As Stream = Me.GetResourceStream("Telerik_logo.jpg")
editor.DrawImage(stream, ImageFormat.Jpeg, New Size(118, 28))
End Using

I would like to insert image from .NET Image class variable. The images are stored in Base64 format in a database.

Could you provide a code snippet for that?

Regards,
Brian
Kammen
Telerik team
 answered on 29 Sep 2014
1 answer
176 views
I'm trying to evaluate the functionality available with your pdfviewer and this pdfprocessing component.  I can't locate the pdfprocessing class or namespace and I can't find any documentation on it.  Can someone provide an example of how to use the pdfprocessing component to extract images from a pdf file?
Petya
Telerik team
 answered on 23 Sep 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Cynthia
Top achievements
Rank 1
Iron
Toby
Top achievements
Rank 3
Iron
Iron
Iron
Danielle
Top achievements
Rank 1
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Iron
yw
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?