I am trying to export a telerik gridview to pdf. Although I have managed to do that, I would like to include inside the pdf text like title, or use some values from textboxes inside the aspx page.
I am not sure if the current version of telerik support these actions. Which version of telerik supports these actions and where can I find more information about this if I would like to have this functionality?
What is the code needed for this functionality? so that I can test it with my current version..
Thanks
I am not sure if the current version of telerik support these actions. Which version of telerik supports these actions and where can I find more information about this if I would like to have this functionality?
What is the code needed for this functionality? so that I can test it with my current version..
Thanks
5 Answers, 1 is accepted
0
0
leo
Top achievements
Rank 1
answered on 18 Mar 2014, 06:58 AM
I have seen the link, it is very useful.
However what I want to do is to also add some other data to the exported pdf document, apart from the grid view. For instance, I would like to add a textbox value for instance or labels. Is it possible to add these as well together with gridview??
Thanks
However what I want to do is to also add some other data to the exported pdf document, apart from the grid view. For instance, I would like to add a textbox value for instance or labels. Is it possible to add these as well together with gridview??
Thanks
0
Princy
Top achievements
Rank 2
answered on 19 Mar 2014, 06:47 AM
Hi Leo,
You can add text to PDF on the OnPdfExporting event of the RadGrid as shown below.
C#:
Thanks,
Princy
You can add text to PDF on the OnPdfExporting event of the RadGrid as shown below.
C#:
protected void RadGrid1_PdfExporting(object sender, GridPdfExportingArgs e){ string headertext = "<div width=\"100%\" style=\"text-align:center;\">HEADER HERE</div>"; e.RawHTML = headertext + e.RawHTML; string footertext = "<div>FOOTER HERE</div>"; e.RawHTML = e.RawHTML + footertext;}Thanks,
Princy
0
leo
Top achievements
Rank 1
answered on 19 Mar 2014, 04:22 PM
This did not work, it never enters to this code. not sure if the problem is the telerik version I use...
0
Accepted
Princy
Top achievements
Rank 2
answered on 20 Mar 2014, 03:39 AM
Hi Leo,
Please take a look at this sample. It works fine at my end. Provide your code snippet if this doesn't help.
ASPX:
C#:
Thanks,
Princy
Please take a look at this sample. It works fine at my end. Provide your code snippet if this doesn't help.
ASPX:
<asp:Button ID="btnPDFExport" runat="server" Text="Export to PDF" OnClick="btnPDFExport_Click" /><telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" DataSourceID="SqlDataSource1" AllowPaging="true" OnPdfExporting="RadGrid1_PdfExporting"> <ExportSettings ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true"> </ExportSettings> <MasterTableView CommandItemDisplay="Top"> <CommandItemSettings ShowExportToPdfButton="true" /> <Columns> <telerik:GridBoundColumn UniqueName="OrderID" DataField="OrderID" HeaderText="OrderID" /> <telerik:GridBoundColumn DataField="ShipCity" HeaderText="ShipCity" UniqueName="ShipCity" /> </Columns> </MasterTableView></telerik:RadGrid>C#:
protected void RadGrid1_PdfExporting(object sender, GridPdfExportingArgs e){ string headertext = "<div width=\"100%\" style=\"text-align:center;\">HEADER HERE</div>"; e.RawHTML = headertext + e.RawHTML; string footertext = "<div>FOOTER HERE</div>"; e.RawHTML = e.RawHTML + footertext;}protected void btnPDFExport_Click(object sender, EventArgs e){ RadGrid1.MasterTableView.ExportToPdf();}Thanks,
Princy