Example E44
Visible to All Users

How to Export a Report to PDF and Specify Export Options

This example uses the XtraReport.ExportToPdf method to export a report to PDF, and calls the ExportOptionsTool.EditExportOptions method to invoke the dialog that allows the user to specify multiple export options.

Report Export to PDF and Preview

Files to Look At

Documentation

More Examples

Example Code

ReportExportPdfSample/Form1.cs(vb)
C#
using DevExpress.XtraPrinting; using System; using System.Collections.Generic; using System.Windows.Forms; namespace ReportExportPdfSample { public partial class Form1 : DevExpress.XtraEditors.XtraForm { public Form1() { InitializeComponent(); } private void simpleButton1_Click(object sender, EventArgs e) { this.pdfViewer1.CloseDocument(); XtraReport1 report = new XtraReport1(); PdfExportOptions pdfOptions = report.ExportOptions.Pdf; // Specify the pages to export. pdfOptions.PageRange = "1, 3-5"; // Specify the quality of exported images. pdfOptions.ConvertImagesToJpeg = false; pdfOptions.ImageQuality = PdfJpegImageQuality.Medium; // Specify the PDF/A-compatibility. pdfOptions.PdfACompatibility = PdfACompatibility.PdfA3b; // The following options are not compatible with PDF/A. // The use of these options will result in PDF validation errors. //pdfOptions.NeverEmbeddedFonts = "Tahoma;Courier New"; //pdfOptions.ShowPrintDialogOnOpen = true; // (Optional) You can specify the security and signature options. //pdfOptions.PasswordSecurityOptions //pdfOptions.SignatureOptions // (Optional) You can add metadata and attachments, // to produce a ZUGFeRD-compatible PDF. //pdfOptions.AdditionalMetadata //pdfOptions.Attachments // Specify the document options. pdfOptions.DocumentOptions.Application = "Test Application"; pdfOptions.DocumentOptions.Author = "DX Documentation Team"; pdfOptions.DocumentOptions.Keywords = "DevExpress, Reporting, PDF"; pdfOptions.DocumentOptions.Producer = Environment.UserName.ToString(); pdfOptions.DocumentOptions.Subject = "Document Subject"; pdfOptions.DocumentOptions.Title = "Document Title"; // Check the validity of PDF export options // and return a list of any detected inconsistencies. IList<string> result = pdfOptions.Validate(); if (result.Count > 0) Console.WriteLine(String.Join(Environment.NewLine, result)); else { report.CreateDocument(); if (ExportOptionsTool.EditExportOptions(pdfOptions, report.PrintingSystem) == DialogResult.OK) { report.ExportToPdf("result.pdf", pdfOptions); this.pdfViewer1.LoadDocument("result.pdf"); } } } } }

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.