GridDocumentExportOptions.CustomizeDocumentFooter Property
Allows you to add a document footer to the exported file.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v25.1.dll
NuGet Package: DevExpress.Blazor
Declaration
public Action<GridDocumentExportCustomizeDocumentHeaderFooterEventArgs> CustomizeDocumentFooter { get; set; }
Property Value
Type | Description |
---|---|
Action<GridDocumentExportCustomizeDocumentHeaderFooterEventArgs> | A delegate method that adds a document footer. |
Property Paths
You can access this nested property as listed below:
Object Type | Path to CustomizeDocumentFooter |
---|---|
GridExportEventArgs |
|
Remarks
Call the ExportToPdf method to export Grid data to PDF. An output document contains only a table with exported data. You can add the following elements to the document:
- Document Header
- Located on the first page before the data table. Handle the CustomizeDocumentHeader event to add and style this element.
- Document Footer
- Located on the last page after the data table. Handle the
CustomizeDocumentFooter
event to add and style this element. - Page Header
- Located on each page within the top margin. Handle the CustomizePageHeader event to add and style this element.
- Page Footer
- Located on each page within the bottom margin. Handle the CustomizePageFooter event to add and style this element.
In the following image, page headers/footers are colored blue and the document header/footer is colored red:
Handle the CustomizeDocument event to configure page settings and default formatting for all elements in the exported document.
The following example exports Grid data to PDF and customizes output document appearance:
@rendermode InteractiveServer
@using DevExpress.Drawing;
@inject WeatherForecastService ForecastService
<DxGrid @ref="Grid" Data="@forecasts">
<Columns>
<DxGridDataColumn Caption="Date" FieldName="Date" />
<DxGridDataColumn Caption="Temperature (C)" FieldName="TemperatureC" ExportWidth="300"/>
<DxGridDataColumn Caption="Temperature (F)" FieldName="TemperatureF" ExportWidth="300" />
<DxGridDataColumn Caption="Summary" FieldName="Summary" />
</Columns>
<ToolbarTemplate>
<DxToolbar>
<DxToolbarItem Text="Export to PDF" Click="ExportPdf_Click" BeginGroup="true" />
</DxToolbar>
</ToolbarTemplate>
</DxGrid>
@code {
IGrid Grid;
private WeatherForecast[]? forecasts;
DXFont defaultFont = new DXFont("Times New Roman", 12, DXFontStyle.Regular);
protected override async Task OnInitializedAsync() {
forecasts = await ForecastService.GetForecastAsync(DateOnly.FromDateTime(DateTime.Now));
}
async Task ExportPdf_Click() {
await Grid.ExportToPdfAsync("ExportResult", new GridPdfExportOptions() {
CustomizeDocument = OnCustomizeDocument, // Customizes exported document appearance
CustomizeDocumentHeader = OnCustomizeDocumentHeader, // Adds a document header
CustomizeDocumentFooter = OnCustomizeDocumentFooter, // Adds a document footer
CustomizePageHeader = OnCustomizePageHeader, // Adds page headers
CustomizePageFooter = OnCustomizePageFooter, // Adds page footers
});
}
void OnCustomizeDocument(GridDocumentExportCustomizeDocumentEventArgs args) {
args.DefaultElementStyle.Font = defaultFont;
args.PaperKind = DevExpress.Drawing.Printing.DXPaperKind.B5;
}
void OnCustomizeDocumentHeader(GridDocumentExportCustomizeDocumentHeaderFooterEventArgs args) {
args.ElementStyle.Font = new DXFont("Arial", 16);
args.Text = "Weather Forecast";
}
void OnCustomizeDocumentFooter(GridDocumentExportCustomizeDocumentHeaderFooterEventArgs args) {
args.ElementStyle.Font = new DXFont(defaultFont.Name, defaultFont.Size, DXFontStyle.Bold);
args.ElementStyle.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
args.Text = "The document data is intented for demonstration purposes only.";
}
void OnCustomizePageHeader(GridDocumentExportCustomizePageHeaderFooterEventArgs args) {
args.ElementStyle.Font = new DXFont(defaultFont.Name, defaultFont.Size, DXFontStyle.Italic);
args.Text = "Copyright © 1998-2025 Developer Express Inc.";
}
void OnCustomizePageFooter(GridDocumentExportCustomizePageHeaderFooterEventArgs args) {
args.ElementStyle.Font = new DXFont(defaultFont.Name, defaultFont.Size, DXFontStyle.Italic);
args.Text = "Page {0} of {1}";
}
}
Refer to the following topic for additional information: Export Blazor Grid Data to PDF.