.NET Standard 2.0+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+

How to: Customize Export Options of the Printing System

  • 4 minutes to read

In a Windows Forms XAF application, end-users have an ability to export View print previews to various formats. Before exporting, an Export Options dialog is invoked. The format-specific options can be changed using this dialog, for example, the HTML title or XLS sheet name.



A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E2108.


To learn how to specify export options for reports, refer to the How to: Customize the Report Export Options topic.

  • The PrintingController, supplied with the System module, exposes the PrintingController.PrintingSettingsLoaded event. You can handle this event to access the PrintingSystem object and modify default export options. To do this, implement the following View Controller:

    using DevExpress.XtraPrinting;
    using DevExpress.ExpressApp.Win.SystemModule;
    // ...
    public class ConfigurePrintingSystemViewController : ViewController {
        private PrintingController printingService;
        protected override void OnActivated() {
            printingService = Frame.GetController<PrintingController>();
            if (printingService != null)
                printingService.PrintingSettingsLoaded += printingService_PrintingSettingsLoaded;
        private void printingService_PrintingSettingsLoaded(
            object sender, PrintableComponentLinkEventArgs e) {
        private void ConfigurePrintingSystem(PrintingSystemBase printingSystem) {
        private static void SetXlsOptions(XlsExportOptions xlsExportOptions) {
            // XLS-specific options:
            xlsExportOptions.SheetName = "CustomXlsSheetTitle";
            xlsExportOptions.ShowGridLines = true;
        private static void SetPdfOptions(PdfExportOptions pdfExportOptions) {
            // PDF-specific options:
            pdfExportOptions.DocumentOptions.Title = "CustomPdfTitle";
            pdfExportOptions.ImageQuality = PdfJpegImageQuality.Medium;
        private static void SetHtmlOptions(HtmlExportOptions htmlExportOptions) {
            // HTML-specific options:
            htmlExportOptions.Title = "CustomHtmlTitle";
            htmlExportOptions.ExportMode = HtmlExportMode.SingleFilePageByPage;
            htmlExportOptions.PageBorderColor = System.Drawing.Color.Gray;
            htmlExportOptions.EmbedImagesInHTML = true;
        private static void SetGeneralOptions(PrintPreviewOptions printPreviewOptions) {
            // General options:
            printPreviewOptions.DefaultFileName = "CustomFileName";
        protected override void OnDeactivated() {
            if (printingService != null)
                printingService.PrintingSettingsLoaded -= printingService_PrintingSettingsLoaded;

    The ShowPreviewDialog method is an extension method implemented in the DevExpress.XtraPrinting.v20.1.dll assembly. A reference to this assembly is required to compile the code above.

    You can access various export options in the ConfigurePrintingSystem, SetXlsOptions, SetPdfOptions, SetHtmlOptions and SetGeneralOptions methods. The following classes provide the available properties:


    You can implement additional methods for other export formats, and call them from the ConfigurePrintingSystem method.

  • Run the Windows Forms application. Execute the PrintPreview Action in any View. In the invoked Preview dialog, click File | Export Document... and select the export format. You will see that the default export settings are changed (modified settings are highlighted in the screenshot).


    The default file name in the Save As dialog is also changed to "CustomFileName"

  • If it is required to disable the Export Options dialog and always use the default options, add the following code to the SetGeneralOptions method:

    private static void SetGeneralOptions(PrintPreviewOptions printPreviewOptions) {
        // ...
        printPreviewOptions.ShowOptionsBeforeExport = false;
See Also