I am using this approach for my project. Everything is working fine but _pdfexporting event, the GridPdfExportingargs.RawHTML is adding duplicate columns.
I have 3 columns for my grid and when I reach this event, the e.RawHtml shows 6 columns.
Following is the code:
Protected Sub grdPDFDetailReports_PdfExporting(ByVal sender As Object, ByVal e As GridPdfExportingArgs)
' I have added some more information that will be included in the PDF above the RadGrid here
Dim customHTML As New StringBuilder()
Dim facilityDTO As New FacilityDTO
' Very Important to make sure you have a colgroup and the same number of "<col>" as "<td>"
customHTML.Append("<colgroup><col style='width: 2000px; white-space:nowrap;' /><col style='text-align:center;' /></colgroup>")
' ColGroup = Number of <td> in a row is needed for Telerik export to PDF
customHTML.Append("<tr><td>InnCode: " + "CHICI" + "</td></tr>")
customHTML.Append("<tr><td>Brand: " + facilityDTO.BrandFamily + "</td></tr>")
customHTML.Append("<tr><td>Hotel Name: " + facilityDTO.Name + "</td></tr>")
customHTML.Append("<tr><td>Management Type: " + facilityDTO.ManagementType + "</td></tr>")
customHTML.Append("<tr><td>State: " + facilityDTO.State + "</td></tr>")
customHTML.Append("<tr><td>City & Zip: " + facilityDTO.City + " & " + facilityDTO.Zip + "</td></tr>")
e.RawHTML = customHTML.Append(e.RawHTML).ToString
I have another query. I want to call exporttopdf, grid_pdfexporting andgrid_gridexporting events in loop but the control comes out after exporttopdf is done and moves for the next item in loop. Is there a way where we can forcefully raise the events.
answered on 23 Sep 2015, 01:51 PM
I assume the cause for the double columns is that you did not disable the auto generated columns. Please disable the AutoGenerateColumns property and check whether the issue remains.
Regards your second query I am afraid you cannot fire the events during a single request. That means first will fire OnPdfExporting and then OnGridExporting event will be fire. If you want to execute it again you have to fire ExportToPdf again after this request.
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Telerik Feedback Portal
and vote to affect the priority of the items
Export to Excel was working as the expected, but when I click for export to pdf....the message says " xxxxxxxxx.pdf is Protected. Please Enter a document Open password".I have tried with different passwords and by enabling and disabling the User password in pdf setting. Can you please help me out in this
answered on 28 Dec 2018, 10:38 AM
There are no such known issues with the grid PDF export and so I advise that you:
make sure pdf protection/password is not set somewhere in the code-behind of the page as well
upgrade to the latest version (there was an issue with that in 2010, see here for more details)
make sure that the problem does not stem from an Antivirus, the email client or other similar software that may be tampering with the file after it is generated from the grid
if you still can't resolve it, open a support ticket where you can send us an MCVE of the problem so we can help
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers.Learn More.