Skip to main content

XtraReport.ExportToPdf(Stream, PdfExportOptions) Method

Exports a report to the specified stream in PDF format.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v23.2.dll

NuGet Package: DevExpress.Reporting.Core

Declaration

public void ExportToPdf(
    Stream stream,
    PdfExportOptions options = null
)

Parameters

Name Type Description
stream Stream

A Stream for output data.

Optional Parameters

Name Type Default Description
options PdfExportOptions null

The PDF export options. You can omit this parameter to use the current report export options.

Remarks

The following code exports a report to PDF in a web application:

using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
using Microsoft.AspNetCore.Mvc;
using ReportingAspNetCorePrintWithoutPreview.PredefinedReports;
using System.IO;
using System.Threading.Tasks;
// ...
    [Route("api/[controller]")]
    public class ExportController : Controller
    {
    // ...
        [HttpGet("[action]")]
        public ActionResult Export(string format = "pdf")
        {
            format = format.ToLower();
            XtraReport report = new TestReport();
            string contentType = string.Format("application/{0}", format);
            using (MemoryStream ms = new MemoryStream())
            {
                switch (format)
                {
                    case "pdf":
                        contentType = "application/pdf";
                        report.ExportToPdf(ms);
                        break;
                        // ...
                }
                return File(ms.ToArray(), contentType);
            }
        }
    }

View Example: How to Print and Export a Report in the ASP.NET Core Application without the Document Viewer

Use the ExportToPdfAsync(Stream, PdfExportOptions, CancellationToken) method instead of ExportToPdf to export a report asynchronously in a separate task.

The following code snippets (auto-collected from DevExpress Examples) contain references to the ExportToPdf(Stream, PdfExportOptions) method.

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