How to: Export a Chart to PDF

This topic explains how to export chart content to a file and to a stream in the PDF format.

  1. Use the DevExpress Printing Library to export the chart. Add references to the following assemblies:

    • DevExpress.XtraPrinting.20.1
    • DevExpress.Printing.v20.1.Core
  2. Use the ChartControl.IsPrintingAvailable property to check whether the chart can be exported.

  3. Call the ChartControl.ExportToPdf method to export the chart.

using System.IO;
using DevExpress.XtraCharts;
// ...

private void OnButtonClick(object sender, EventArgs e) {
    if(chartControl1.IsPrintingAvailable) {
        // Exports the chart in the vector-based format to a PDF file.
        chartControl1.OptionsPrint.ImageFormat = DevExpress.XtraCharts.Printing.PrintImageFormat.Metafile;
        chartControl1.ExportToPdf("D://Output1.pdf", new DevExpress.XtraPrinting.PdfExportOptions { ConvertImagesToJpeg = false });

        // Exports to a stream as PDF.
        FileStream pdfStream = new FileStream("D://Output2.pdf", FileMode.Create);
        // ...