Skip to main content
All docs
V25.1
  • TreeListDocumentExportCustomizeDocumentEventArgs Class

    Contains information for the CustomizeDocument event.

    Namespace: DevExpress.Blazor

    Assembly: DevExpress.Blazor.v25.1.dll

    NuGet Package: DevExpress.Blazor

    Declaration

    public class TreeListDocumentExportCustomizeDocumentEventArgs :
        GridDocumentExportCustomizeDocumentEventArgsBase

    Remarks

    When exporting TreeList data to PDF, handle the CustomizeDocument event to configure style and page settings for the output document:

    @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);
        }
    }
    

    Inheritance

    Object
    GridDocumentExportCustomizeDocumentEventArgsBase
    TreeListDocumentExportCustomizeDocumentEventArgs
    See Also