Hi !
I follow the example in your tutorial to export to pdf and is woking nice.
The problem is I have a Date column and I don't know how to format to dd-MMM-yyyy.
And I've seen some columns are overlapping. Is any procedure to define a size of a column?
Regards,
Hans
I follow the example in your tutorial to export to pdf and is woking nice.
The problem is I have a Date column and I don't know how to format to dd-MMM-yyyy.
And I've seen some columns are overlapping. Is any procedure to define a size of a column?
Regards,
Hans
5 Answers, 1 is accepted
0
Hi Hans,
Thank you for writing. You can use HTMLCellFormatting event to apply any format on the exported data. As to the questions about overlapping, unfortunately, this is a limitation of our pdf engine, which does not support word-break. Since the columns size depends on the grid's column width, you can change their size before exporting and return the default values afterwards. You also can consider using the Scale and FitToPageWidth properties to setup the grid placement and size on the pdf document. Please consider the following code:
Hope this helps. Let me know if you have any other questions.
Regards,
Martin Vasilev
the Telerik team
Thank you for writing. You can use HTMLCellFormatting event to apply any format on the exported data. As to the questions about overlapping, unfortunately, this is a limitation of our pdf engine, which does not support word-break. Since the columns size depends on the grid's column width, you can change their size before exporting and return the default values afterwards. You also can consider using the Scale and FitToPageWidth properties to setup the grid placement and size on the pdf document. Please consider the following code:
void
ExportToPdfMethod(RadGridView radGridView,
string
filePath)
{
ExportToPDF pdfExporter =
new
ExportToPDF(radGridView1);
pdfExporter.ExportVisualSettings =
true
;
pdfExporter.Scale = 0.6f;
pdfExporter.FitToPageWidth =
true
;
pdfExporter.HTMLCellFormatting +=
new
HTMLCellFormattingEventHandler(pdfExporter_HTMLCellFormatting);
pdfExporter.RunExport(filePath);
}
void
pdfExporter_HTMLCellFormatting(
object
sender, HTMLCellFormattingEventArgs e)
{
//format datetime value
if
(e.GridColumnIndex == 5 && !String.IsNullOrEmpty(e.InnerCellValue.ToString()))
{
e.HTMLCellElement.Value = ((DateTime)e.InnerCellValue).ToString(
"dd/MM/yyyy"
);
}
}
Hope this helps. Let me know if you have any other questions.
Regards,
Martin Vasilev
the Telerik team
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? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0

Hasan
Top achievements
Rank 1
answered on 07 Feb 2011, 06:48 AM
Can you please translate this code in vb. I tried but could not find HTMLCellFormatting in vb. Please help,,
0

Richard Slade
Top achievements
Rank 2
answered on 07 Feb 2011, 08:34 AM
Hello Hasan,
Here is the translation into VB.NET
For reference, Telerik have a code converter from/to C#/VB at this address.
Hope that helps
Richard
Here is the translation into VB.NET
Private
Sub
ExportToPdfMethod(radGridView
As
RadGridView, filePath
As
String
)
Dim
pdfExporter
As
New
ExportToPDF(radGridView1)
pdfExporter.ExportVisualSettings =
True
pdfExporter.Scale = 0.6F
pdfExporter.FitToPageWidth =
True
AddHandler
pdfExporter.HTMLCellFormatting,
AddressOf
pdfExporter_HTMLCellFormatting
pdfExporter.RunExport(filePath)
End
Sub
Private
Sub
pdfExporter_HTMLCellFormatting(sender
As
Object
, e
As
HTMLCellFormattingEventArgs)
'format datetime value
If
e.GridColumnIndex = 5
AndAlso
Not
[
String
].IsNullOrEmpty(e.InnerCellValue.ToString())
Then
e.HTMLCellElement.Value =
DirectCast
(e.InnerCellValue, DateTime).ToString(
"dd/MM/yyyy"
)
End
If
End
Sub
For reference, Telerik have a code converter from/to C#/VB at this address.
Hope that helps
Richard
0

Hasan
Top achievements
Rank 1
answered on 13 Feb 2011, 12:01 PM
The exported pdf is not showing the correct column widths and the contents are overlaping. Any solution??
0

Richard Slade
Top achievements
Rank 2
answered on 13 Feb 2011, 12:40 PM
Hi Hassan,
This sounds like the limitation of the PDF Export at the moment. Please have a look at this thread which explains.
Regards,
Richard
This sounds like the limitation of the PDF Export at the moment. Please have a look at this thread which explains.
Regards,
Richard