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

Telerik.WinControls.Export.PdfExportRenderer renderer = new Telerik.WinControls.Export.PdfExportRenderer(); Unknow Type

25 Answers 270 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Gustavo
Top achievements
Rank 1
Gustavo asked on 31 Aug 2016, 07:56 PM

Hello Telerik,

I want to export a file.txt  to Pdf, I´m using GridViewPdfExport component but this line does not work:

Telerik.WinControls.Export.PdfExportRenderer renderer = new Telerik.WinControls.Export.PdfExportRenderer();

 

This is my code , taken from Export to PDF

 

Telerik.WinControls.Export.GridViewPdfExport pdfExporter = new Telerik.WinControls.Export.GridViewPdfExport(radGrid1);
pdfExporter.FileExtension = ".pdf";
pdfExporter.ShowHeaderAndFooter = true;
pdfExporter.HeaderHeight = 30;
pdfExporter.HeaderFont = new Font("Arial", 22);
pdfExporter.Logo = System.Drawing.Image.FromFile(@"C:\temp\logo.png");
pdfExporter.LeftHeader = "[Logo]";
pdfExporter.LogoAlignment = ContentAlignment.MiddleLeft;
pdfExporter.LogoLayout = Telerik.WinControls.Export.LogoLayout.Fit;
 
pdfExporter.MiddleHeader = "Middle header";
pdfExporter.RightHeader = "Right header";
pdfExporter.ReverseHeaderOnEvenPages = true;
 
pdfExporter.FooterHeight = 30;
pdfExporter.FooterFont = new Font("Arial", 22);
pdfExporter.LeftFooter = "Left footer";
pdfExporter.MiddleFooter = "Middle footer";
pdfExporter.RightFooter = "Right footer";
pdfExporter.ReverseFooterOnEvenPages = true;
 
pdfExporter.SummariesExportOption = SummariesOption.ExportAll;
pdfExporter.FitToPageWidth = true;
pdfExporter.Scale = 1.2;
pdfExporter.ExportSettings.Title = "Prueba";
 
string exportFile = @"..\..\exportedData.pdf";
using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
{
Telerik.WinControls.Export.GridViewPdfExport exporter = new    Telerik.WinControls.Export.GridViewPdfExport(radGrid1);
Telerik.WinControls.Export.PdfExportRenderer renderer = new Telerik.WinControls.Export.PdfExportRenderer();
exporter.RunExport(ms, renderer);
 
using (System.IO.FileStream fileStream = new System.IO.FileStream(exportFile, FileMode.Create, FileAccess.Write)){
ms.WriteTo(fileStream);}
}

Thanks in advance.

 

25 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 01 Sep 2016, 01:07 PM
Hi Jamsheer,

Thank you for writing.

You do not need to use the grid to convert text files to pdf. You can just use the WordsProcessing library. Detailed information is available here: 
Nevertheless, could you please share the error message observed on your side? You code compiles without errors on mine.

I am looking forward to your reply.
 
Regards,
Dimitar
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
Gustavo
Top achievements
Rank 1
answered on 06 Sep 2016, 12:32 AM

Hi Dimitar,

It works, but I now have another problem

My RadGridView does not load any information, I use this 

DataTable dt = new DataTable();
dt = objAdmin.Sales();
 
RadGridView radGrid1 = new RadGridView();
radGrid1.AutoGenerateColumns = true;
radGrid1.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
radGrid1.MasterTemplate.DataSource = dt;
What am I doing wrong?

 

 

 

 

What am I doing wrong?. On the other hand , the library that you recommend me , so I understand not allow me to customize the pdf in order that want to show the information, and information gathering for the use of this is very poor and I do not think Easy to use. for example I can not find how or where to place the path of the plane I want to export file, I found only this
What am I doing wrong?. On the other hand , the library that you recommend me , so I understand not allow me to customize the pdf in order that want to show the information, and information gathering for the use of this is very poor and I do not think Easy to use. for example I can not find how or where to place the path of the plane I want to export file, I found only this
What am I doing wrong?. On the other hand , the library that you recommend me , so I understand not allow me to customize the pdf in order that want to show the information, and information gathering for the use of this is very poor and I do not think Easy to use. for example I can not find how or where to place the path of the plane I want to export file, I found only this
What am I doing wrong?. On the other hand , the library that you recommend me , so I understand not allow me to customize the pdf in order that want to show the information, and information gathering for the use of this is very poor and I do not think Easy to use. for example I can not find how or where to place the path of the plane I want to export file, I found only this
0
Dimitar
Telerik team
answered on 06 Sep 2016, 09:11 AM
Hello Gustavo,

Are you adding the grid to the form or you want to export the data without showing it? If this is the case you need to call the LoadElementTree method and set the BindingContext manually:
RadGridView radGrid1 = new RadGridView();
radGrid1.AutoGenerateColumns = true;
radGrid1.MasterTemplate.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
radGrid1.MasterTemplate.DataSource = dt;
 
radGrid1.BindingContext = this.BindingContext;
radGrid1.LoadElementTree();

I hope this helps. Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
Gustavo
Top achievements
Rank 1
answered on 06 Sep 2016, 05:33 PM

Hello Dimitar,

Yes, I want to export the data without showing it, my project is a console application, I need export a plain text

 

I have this error

 

Thanks in advence

0
Dimitar
Telerik team
answered on 07 Sep 2016, 07:45 AM
Hello Gustavo,

You need to make sure that the System.Windows.Forms assembly is referenced. In addition, since you do not have a form you need to create a binding context:
radGrid1.BindingContext = new BindingContext();

I hope this will be useful. 

Regards,
Dimitar
Telerik by Progress
Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
0
JUAN
Top achievements
Rank 1
answered on 07 Sep 2016, 12:54 PM

It´s work , thanks a lot.

Gustavo

0
jamsheer
Top achievements
Rank 1
Veteran
answered on 20 Feb 2017, 12:18 PM
Telerik.WinControls.Export.GridViewPdfExport pdfExporter = new Telerik.WinControls.Export.GridViewPdfExport(DgvTrialBalance);
            pdfExporter.FileExtension = ".pdf";
            pdfExporter.ShowHeaderAndFooter = true;
            pdfExporter.HeaderHeight = 30;
            pdfExporter.HeaderFont = new Font("Arial", 22);
 
            //pdfExporter.Logo = System.Drawing.Image.FromFile(@"C:\temp\logo.png");
            //pdfExporter.LeftHeader = "[Logo]";
            //pdfExporter.LogoAlignment = ContentAlignment.MiddleLeft;
            //pdfExporter.LogoLayout = Telerik.WinControls.Export.LogoLayout.Fit;
 
            pdfExporter.MiddleHeader = "Middle header";
            pdfExporter.RightHeader = "Right header";
            pdfExporter.ReverseHeaderOnEvenPages = true;
 
            pdfExporter.FooterHeight = 30;
            pdfExporter.FooterFont = new Font("Arial", 22);
            pdfExporter.LeftFooter = "Left footer";
            pdfExporter.MiddleFooter = "Middle footer";
            pdfExporter.RightFooter = "Right footer";
            pdfExporter.ReverseFooterOnEvenPages = true;
 
            pdfExporter.SummariesExportOption = SummariesOption.ExportAll;
            pdfExporter.FitToPageWidth = true;
            pdfExporter.Scale = 1.2;
            pdfExporter.ExportSettings.Title = "Prueba";
 
            string exportFile = @"..\..\exportedData.pdf";
             
            using(System.IO.MemoryStream ms = new System.IO.MemoryStream())
            {
                Telerik.WinControls.Export.GridViewPdfExport exporter = new Telerik.WinControls.Export.GridViewPdfExport(DgvTrialBalance);
                PdfExportRenderer renderer = new Telerik.WinControls.Export.PdfExportRenderer();
                exporter.RunExport(ms , renderer);
 
                using (System.IO.FileStream fileStream = new System.IO.FileStream(exportFile, FileMode.Create, FileAccess.Write))
                {
                    ms.WriteTo(fileStream);
                }
            }

[quote]Dimitar said:Hi Gustavo,

Thank you for writing.

You need to add a reference to the TelerikExport assembly. This is noted at the begging of the article. 

In addition, you can use our WordsProcessing library to convert such files, you do not need a UI component for this: WordsProcessing.

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Telerik by Progress

Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.

[/quote]Hello Dimitar,
I want to export a file.txt  to Pdf, I´m using GridViewPdfExport component but this line does not work:
exporter.RunExport(ms , renderer);

I have this error

Thanks in advence

0
Dimitar
Telerik team
answered on 20 Feb 2017, 01:38 PM
Hi Jamsheer,

Please note that you do not need the grid exporter in order to convert such files. You can just use the WordsProcessing library. Detailed information is available here:
In addition, I cannot see the error message. Could you please specify it again? Your code compiles without errors on my side.

I am looking forward to your reply.
 
Regards,
Dimitar
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
jamsheer
Top achievements
Rank 1
Veteran
answered on 21 Feb 2017, 03:52 AM

Hello Dimitar,
    I have error message in there in my memeorystream variable its like below
Thanks in advence

jamsheer

0
jamsheer
Top achievements
Rank 1
Veteran
answered on 21 Feb 2017, 03:58 AM
Hello Dimitar,
    I have error message in there in my memeorystream variable its like below
Thanks in advence
jamsheer
0
Dimitar
Telerik team
answered on 21 Feb 2017, 07:27 AM
Hello,

The method overload that accepts stream was introduced in R2 2016 SP1 (version 2016.2.608). So you need this or newer version in order to export to a stream.

Please note that you can pass the file name and path directly and export the grid, the stream is used for some cases where you do not want to create a file.

I hope this will be useful. Let me know if you have additional questions.

Regards,
Dimitar
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
jamsheer
Top achievements
Rank 1
Veteran
answered on 21 Feb 2017, 10:41 AM

Hello Dimitar,

     I overcome that Issue ,Thanks a lot.

 Now I want to export my RadGridview to Word file also,How could I do ?

Thanks in advance
jamsheer

0
Dimitar
Telerik team
answered on 21 Feb 2017, 11:28 AM
Hi,

There is no built-in exporter that can export to the  format. However, this can be achieved and we have an example of it in our demo application (see attached image). 

Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
jamsheer
Top achievements
Rank 1
Veteran
answered on 22 Feb 2017, 06:46 AM

Hello Dimitar,
    How could I convert my RadPrintDocument  values to RadFlowDocument, because when export RadGridview to docx file or text file  there we are using RadFlowDocument.

Where I exported successfully to pdf,xlsx,xls formats, The above issue when exporting to those formats (docx and txt)

If you can attach example project or sample codes

Thanks in advance
jamsheer

0
Dimitar
Telerik team
answered on 22 Feb 2017, 11:27 AM
Hi Jamsheer,

There is no way to convert RadPrintDocumet to RadFlowDocument.

I do not understand what is your exact requirement. So could you please specify what exactly you want to achieve and why you want to convert these document types?

I am looking forward to your reply.

Regards,
Dimitar
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
jamsheer
Top achievements
Rank 1
Veteran
answered on 25 Feb 2017, 06:53 AM

Hello Dimitar,

      I tried to  export Radgridview  to Docx file ,but i didnt get the output .
can u please attach example codes or sample projects
Thanks in advance
jamsheer

 

 

0
jamsheer
Top achievements
Rank 1
Veteran
answered on 25 Feb 2017, 07:13 AM

Hello Dimitar,
      I have getting duplicate value to my radprintpreview from  a grouped radfridview (Actually there i grouped two columns name as ledgergroup and groupname  , some ledgergroup have same groupname because of that its getting duplication ,In this pic look the second marked fields where "sales  is a ledgergroup and the groupname also same as ledgergroup  name as sales")

i want to avoid that duplicate name at this case.
Thanks in advance
jamsheer

0
Dimitar
Telerik team
answered on 27 Feb 2017, 01:45 PM
Hi Jamsheer,

We have an example that shows how you can export to  format in our demo application. You can directly copy the code as well (see attached image). 

In addition, I am not sure how to reduce the issue with the groups printing. This is why I want to kindly ask you to open a separate thread for this and add the code of your form. This will allow us to properly investigate this and provide you with a solution.

I hope this will be useful.

Regards,
Dimitar
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
jamsheer
Top achievements
Rank 1
Veteran
answered on 01 Mar 2017, 12:43 PM

Hello Dimitar,
     I want to show printdialog with the all details of print preview without using print preview ,where i created class for Header and footer .

I can get that with this code (this.Raddatagridview.Print(true);),but there i didnt get Header and footer 

how could i get it ?
Thanks in advance
jamsheer

0
jamsheer
Top achievements
Rank 1
Veteran
answered on 03 Mar 2017, 04:25 AM

Hello ,

   I got the answer where i used this:

DgvTrialBalance.Print(true, RadPrintDocument1);

Thanks,

 

0
Dimitar
Telerik team
answered on 03 Mar 2017, 12:49 PM
Hello Jamsheer,

I am glad that you have found a solution for this. Should you have any other questions do not hesitate to ask.

Regards,
Dimitar
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
jamsheer
Top achievements
Rank 1
Veteran
answered on 06 Mar 2017, 06:53 AM

Hello Dimitar,
    I want to create a new row at top of my Radgrid look like below.

where my Radgrid grouping is true
Thanks in advance
jamsheer

0
jamsheer
Top achievements
Rank 1
Veteran
answered on 06 Mar 2017, 12:25 PM

Hello Dimitar,
    How could I change the color of Pinned row of Radgrid,where I have lot of summary rows and I pinned the last total value of my documents .

Where I used to Pinned Row with this code,

this.DgvTrialBalance.MasterView.SummaryRows[0].PinPosition = PinnedRowPosition.Bottom;

I want to change the color where I red marked in the below pic.

Expecting your help,

Thanks in advance
jamsheer

0
jamsheer
Top achievements
Rank 1
Veteran
answered on 07 Mar 2017, 04:22 AM

Hello Dimitar,

   Expecting your help for those questions.

Thanks in advance

jamsheer

0
Dimitar
Telerik team
answered on 07 Mar 2017, 12:50 PM
Hi Jamsheer,

1. You can use Column Groups View to create such layout.

2. Use the ViewCellFormatting event to change the styles of the summary cells:
private void RadGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.CellElement is GridSummaryCellElement)
    {
        e.CellElement.DrawFill = true;
        e.CellElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
        e.CellElement.BackColor = Color.Red;
 
    }
    else
    {
        e.CellElement.ResetValue(LightVisualElement.BackColorProperty, Telerik.WinControls.ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, Telerik.WinControls.ValueResetFlags.Local);
        e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, Telerik.WinControls.ValueResetFlags.Local);
    }
}

Off topic, I want to mention that these questions are not related to the original subject of this thread. I want to kindly ask you to use relevant or open new threads for unrelated questions. In addition, could please use just one support channel to contact us. Posting the same questions numerous times slows down our response time because we will need to review and address two or more tickets instead of one.

Thank you for your understanding.

Regards,
Dimitar
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
Gustavo
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Gustavo
Top achievements
Rank 1
JUAN
Top achievements
Rank 1
jamsheer
Top achievements
Rank 1
Veteran
Share this question
or