Skip to main content
A newer version of this page is available. .

PrintPreviewOptions.DefaultFileName Property

Gets or sets the file name to which, by default, a document is exported from the Print Preview.

Namespace: DevExpress.XtraPrinting

Assembly: DevExpress.Printing.v18.2.Core.dll

Declaration

[DefaultValue("Document")]
[XtraSerializableProperty]
public string DefaultFileName { get; set; }

Property Value

Type Default Description
String "Document"

A String which represents the default file name.

Property Paths

You can access this nested property as listed below:

Library Object Type Path to DefaultFileName
Cross-Platform Class Library ExportOptions
.PrintPreview.DefaultFileName
WPF Controls ExportOptionsContainer
.PrintPreview.DefaultFileName

Remarks

Use the PrintPreviewOptions.DefaultDirectory and DefaultFileName properties to specify the directory and the file name, to which the Save File dialog will point when an end-user exports a document from the Print Preview.

Note

To implement silent exporting in the Print Preview (when no Save File dialog is displayed for an end-user), you should provide the correct file path using the PrintPreviewOptions.DefaultDirectory and DefaultFileName properties, and set the PrintPreviewOptions.SaveMode property to SaveMode.UsingDefaultPath.

Example

This example illustrates how to specify the primary export options of a report by using the XtraReport.ExportOptions property. These options are taken into account when a document is being exported from a print preview.

This example presumes that a report is exported silently, without prompting an end-user to customize the export options.

All available export options are listed in the ExportOptionKind enumeration.

using System;
using System.Drawing.Imaging;
using System.Globalization;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraPrinting;
// ...

namespace WindowsFormsApplication1 {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        private XtraReport1 report;

        private void Form1_Load(object sender, EventArgs e) {
            report = new XtraReport1();
            documentViewer1.DocumentSource = report;
            report.CreateDocument();

            PrintingSystemBase printingSystem1 = report.PrintingSystem;

            // Obtain the current export options.
            ExportOptions options = printingSystem1.ExportOptions;

            // Set Print Preview options.
            options.PrintPreview.ActionAfterExport = ActionAfterExport.AskUser;
            options.PrintPreview.DefaultDirectory = "C:\\Temp";
            options.PrintPreview.DefaultFileName = "Report";
            options.PrintPreview.SaveMode = SaveMode.UsingDefaultPath;
            options.PrintPreview.ShowOptionsBeforeExport = false;

            // Set E-mail options.
            options.Email.RecipientAddress = "someone@somewhere.com";
            options.Email.RecipientName = "Someone";
            options.Email.Subject = "Test";
            options.Email.Body = "Test";

            // Set CSV-specific export options.
            options.Csv.Encoding = Encoding.Unicode;
            options.Csv.Separator =
                CultureInfo.CurrentCulture.TextInfo.ListSeparator.ToString();

            // Set HTML-specific export options.
            options.Html.CharacterSet = "UTF-8";
            options.Html.RemoveSecondarySymbols = false;
            options.Html.Title = "Test Title";

            // Set Image-specific export options.
            options.Image.Format = ImageFormat.Jpeg;

            // Set MHT-specific export options.
            options.Mht.CharacterSet = "UTF-8";
            options.Mht.RemoveSecondarySymbols = false;
            options.Mht.Title = "Test Title";

            // Set PDF-specific export options.
            options.Pdf.Compressed = true;
            options.Pdf.ImageQuality = PdfJpegImageQuality.Low;
            options.Pdf.NeverEmbeddedFonts = "Tahoma;Courier New";
            options.Pdf.DocumentOptions.Application = "Test Application";
            options.Pdf.DocumentOptions.Author = "Test Team";
            options.Pdf.DocumentOptions.Keywords = "Test1, Test2";
            options.Pdf.DocumentOptions.Subject = "Test Subject";
            options.Pdf.DocumentOptions.Title = "Test Title";

            // Set Text-specific export options.
            options.Text.Encoding = Encoding.Unicode;
            options.Text.Separator =
                CultureInfo.CurrentCulture.TextInfo.ListSeparator.ToString();

            // Set XLS-specific export options.
            options.Xls.ShowGridLines = true;
            options.Xls.SheetName = "Page 1";
            options.Xls.TextExportMode = TextExportMode.Value;

            // Set XLSX-specific export options.
            options.Xlsx.ShowGridLines = true;
            options.Xlsx.SheetName = "Page 1";
            options.Xlsx.TextExportMode = TextExportMode.Value;
        }
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the DefaultFileName property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also