** Disclaimer **
The Telerik product was just purchased by us less than 2 weeks ago and therefore as a Newbie, I may have posted this to the wrong forum, and I may be overlooking an obvious resolution.
** Problem **
Unable to set the font-size of the column headings when exporting a grid to PDF.
** Things Tried **
I have tried many things, including some samples directly from Telerik demos. For example:
bool isPdfExport = false;
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) {
if (isPdfExport && e.Item is GridDataItem) {
/// <ColumnHeadings>
if (e.Item is GridHeaderItem) {
GridHeaderItem headerItem = (GridHeaderItem)e.Item;
headerItem.Style["font-size"] = "6pt";
foreach (TableCell cell in headerItem.Cells) {
cell.Style["font-size"] = "6pt";
}
}
/// </ColumnHeadings>
/// <ColumnData>
if (e.Item is GridItem) {
GridItem gridItem = (GridItem)e.Item;
gridItem.Style["font-size"] = "6pt";
foreach (TableCell cell in gridItem.Cells) {
cell.Style["font-size"] = "6pt";
}
/// </ColumnData>
}
} //End if (isPdfExport && e.Item is GridDataItem)
} //End protected void RadGrid1_ItemCreated()
protected void btnExport_Click(object sender, EventArgs e) {
isPdfExport = true;
this.RadGrid1.Visible = true;
this.RadGrid1.MasterTableView.ExportToPdf();
}
Within the above event, the ColumnHeadings section fails to resize the font. However, the ColumnData section *will* successfully resize the font. If I change the ColumnData section from 6pt to 12pt font, the data that appears under the column headings (after exporting to PDF) will be resized according. Change it back to 6pt and re-export, and the data is formatted properly.
When making the same change from 6pt to 12pt (or whatever) in the ColumnHeading section, there is no impact on the headings that appear in the PDF. The font size of the column headings remain unchanged. I have no success using "x-small" or "x-large" either (instead of a point size).
I have tried using similiar code in RadGrid1_ColumnCreated() as well as other grid events, but with no luck. BTW, here is the grid schema if interested:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="true"
GridLines="Both" BorderWidth="0.5" Visible="false"
OnNeedDataSource="RadGrid1_NeedDataSource"
OnItemCreated="RadGrid1_ItemCreated"
OnDataBound="RadGrid1_DataBound"
OnColumnCreated="RadGrid1_ColumnCreated">
<ClientSettings>
<Resizing AllowColumnResize="true" />
</ClientSettings>
<ExportSettings IgnorePaging="true" OpenInNewWindow="true">
<Pdf AllowPrinting="true" PaperSize="Legal" PageHeight="8.5in" PageWidth="14in"
PageBottomMargin="10mm" PageTopMargin="20mm" PageLeftMargin="8mm" PageRightMargin="8mm" />
</ExportSettings>
</telerik:RadGrid>
** Resolution **
Unable to determine. Can someone please provide the proper way to resize Column Headings when exporting a grid to PDF?
Thank you,
Steven
The Telerik product was just purchased by us less than 2 weeks ago and therefore as a Newbie, I may have posted this to the wrong forum, and I may be overlooking an obvious resolution.
** Problem **
Unable to set the font-size of the column headings when exporting a grid to PDF.
** Things Tried **
I have tried many things, including some samples directly from Telerik demos. For example:
bool isPdfExport = false;
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) {
if (isPdfExport && e.Item is GridDataItem) {
/// <ColumnHeadings>
if (e.Item is GridHeaderItem) {
GridHeaderItem headerItem = (GridHeaderItem)e.Item;
headerItem.Style["font-size"] = "6pt";
foreach (TableCell cell in headerItem.Cells) {
cell.Style["font-size"] = "6pt";
}
}
/// </ColumnHeadings>
/// <ColumnData>
if (e.Item is GridItem) {
GridItem gridItem = (GridItem)e.Item;
gridItem.Style["font-size"] = "6pt";
foreach (TableCell cell in gridItem.Cells) {
cell.Style["font-size"] = "6pt";
}
/// </ColumnData>
}
} //End if (isPdfExport && e.Item is GridDataItem)
} //End protected void RadGrid1_ItemCreated()
protected void btnExport_Click(object sender, EventArgs e) {
isPdfExport = true;
this.RadGrid1.Visible = true;
this.RadGrid1.MasterTableView.ExportToPdf();
}
Within the above event, the ColumnHeadings section fails to resize the font. However, the ColumnData section *will* successfully resize the font. If I change the ColumnData section from 6pt to 12pt font, the data that appears under the column headings (after exporting to PDF) will be resized according. Change it back to 6pt and re-export, and the data is formatted properly.
When making the same change from 6pt to 12pt (or whatever) in the ColumnHeading section, there is no impact on the headings that appear in the PDF. The font size of the column headings remain unchanged. I have no success using "x-small" or "x-large" either (instead of a point size).
I have tried using similiar code in RadGrid1_ColumnCreated() as well as other grid events, but with no luck. BTW, here is the grid schema if interested:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="true"
GridLines="Both" BorderWidth="0.5" Visible="false"
OnNeedDataSource="RadGrid1_NeedDataSource"
OnItemCreated="RadGrid1_ItemCreated"
OnDataBound="RadGrid1_DataBound"
OnColumnCreated="RadGrid1_ColumnCreated">
<ClientSettings>
<Resizing AllowColumnResize="true" />
</ClientSettings>
<ExportSettings IgnorePaging="true" OpenInNewWindow="true">
<Pdf AllowPrinting="true" PaperSize="Legal" PageHeight="8.5in" PageWidth="14in"
PageBottomMargin="10mm" PageTopMargin="20mm" PageLeftMargin="8mm" PageRightMargin="8mm" />
</ExportSettings>
</telerik:RadGrid>
** Resolution **
Unable to determine. Can someone please provide the proper way to resize Column Headings when exporting a grid to PDF?
Thank you,
Steven