GridDocumentExportCustomizeDocumentEventArgsBase.Landscape Property
Specifies the page orientation for the exported document.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v25.1.dll
NuGet Package: DevExpress.Blazor
Declaration
[DefaultValue(false)]
public bool Landscape { get; set; }
Property Value
Type | Default | Description |
---|---|---|
Boolean | false |
|
Remarks
When exporting Grid or TreeList data to PDF, handle the CustomizeDocument
event to configure style and page settings for the output document. Enable the Landscape
event argument to switch the page orientation from portrait to landscape.
Grid Example
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" />
<DxGridDataColumn Caption="Temperature (F)" FieldName="TemperatureF" />
<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;
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
CustomizePageHeader = args => args.Text = "Weather Forecast", // Adds a page header
CustomizePageFooter = args => args.Text = "Page {0} of {1}", // Adds a page footer
});
}
void OnCustomizeDocument(GridDocumentExportCustomizeDocumentEventArgs args) {
// Sets default font settings for all elements in the exported document
args.DefaultElementStyle.Font = new DXFont("Times New Roman", 12, DXFontStyle.Regular);
// Switches the page orientation to landscape
args.Landscape = true;
// Sets page margins to 0.5 inches
args.Margins = new DXMargins(50, 50, 50, 50);
// Sets the page size to a custom value (width: 6 inches, height: 8 inches)
args.PaperKind = DevExpress.Drawing.Printing.DXPaperKind.Custom;
args.PageSize = new System.Drawing.Size(600, 800);
}
}
TreeList Example
The following example exports TreeList data to PDF and customizes output document appearance:
@rendermode InteractiveServer
@using DevExpress.Drawing
@inject SpaceObjectDataProvider SpaceObjectDataProvider
<DxTreeList @ref="TreeList" Data="TreeListData" ChildrenFieldName="Satellites">
<Columns>
<DxTreeListDataColumn FieldName="Name" />
<DxTreeListDataColumn FieldName="TypeOfObject" Caption="Type" />
<DxTreeListDataColumn FieldName="Mass10pow21kg" Caption="Mass, kg" DisplayFormat="N2" />
<DxTreeListDataColumn FieldName="MeanRadiusInKM" Caption="Radius, km" DisplayFormat="N2"/>
</Columns>
<ToolbarTemplate>
<DxToolbar>
<DxToolbarItem Text="Export to PDF" Click="ExportPdf_Click" BeginGroup="true" />
</DxToolbar>
</ToolbarTemplate>
</DxTreeList>
@code {
ITreeList TreeList { get; set; }
object TreeListData { get; set; }
protected override async Task OnInitializedAsync() {
TreeListData = SpaceObjectDataProvider.GenerateData();
}
async Task ExportPdf_Click() {
await TreeList.ExportToPdfAsync("ExportResult", new TreeListPdfExportOptions() {
CustomizeDocument = OnCustomizeDocument, // Customizes exported document appearance
CustomizePageHeader = args => args.Text = "Space Objects", // Adds a page header
CustomizePageFooter = args => args.Text = "Page {0} of {1}", // Adds a page footer
});
}
void OnCustomizeDocument(TreeListDocumentExportCustomizeDocumentEventArgs args) {
// Sets default font settings for all elements in the exported document
args.DefaultElementStyle.Font = new DXFont("Times New Roman", 12, DXFontStyle.Regular);
// Switches the page orientation to landscape
args.Landscape = true;
// Sets page margins to 0.5 inches
args.Margins = new DXMargins(50, 50, 50, 50);
// Sets the page size to a custom value (width: 6 inches, height: 8 inches)
args.PaperKind = DevExpress.Drawing.Printing.DXPaperKind.Custom;
args.PageSize = new System.Drawing.Size(600, 800);
}
}
See Also