Back to Devexpress

Print and Export

windowsforms-118249-controls-and-libraries-chart-control-end-user-features-print-and-export.md

latest11.1 KB
Original Source

Print and Export

  • Sep 23, 2025
  • 4 minutes to read

You can print a chart and export it to multiple file formats.

A project should reference the DevExpress.XtraPrinting.25.2 and DevExpress.Printing.v25.2.Core assemblies to execute print and export operations.

Use the following code to print a chart:

csharp
private void onButtonClick(object sender, EventArgs e) {
    if (chartControl.IsPrintingAvailable) {
        chartControl.Print();
    }
}
vb
Private Sub onButtonClick(sender As Object, e As EventArgs)
    If chartControl.IsPrintingAvailable Then
        chartControl.Print()
    End If
End Sub

The table below lists related API members:

MemberDescription
ChartControl.PrintPrints the chart.
ChartControl.IsPrintingAvailableIndicates whether the chart can be printed.

You can display a Print Preview that contains the toolbox or the Ribbon.

MethodDescription
ChartControl.ShowPrintPreviewInvokes the chart’s Print Preview that contains the toolbox.
ChartControl.ShowRibbonPrintPreviewInvokes the chart’s Print Preview that contains the Ribbon.

The following code invokes the chart’s Print Preview that contains the Ribbon:

csharp
private void onButtonClick(object sender, RoutedEventArgs e) {
    chartControl.ShowRibbonPrintPreview();
}
vb
Private Sub onButtonClick(sender As Object, e As RoutedEventArgs)
    chartControl.ShowRibbonPrintPreview()
End Sub

Click the Quick Print item to print a chart:

The Print Preview

The Ribbon Print Preview

Use the Print item to show the standard print dialog:

The Print Preview

The Ribbon Print Preview

Select a file format in the Export drop-down list to export the chart:

The Print Preview

The Ribbon Print Preview

Export a Chart from Code

The following methods export a chart to different formats:

MethodDescription
ChartControl.ExportToHtmlExports a chart to an HTML file.
ChartControl.ExportToImageExports a chart to an image.
ChartControl.ExportToMhtExports a chart to an MHT file.
ChartControl.ExportToPdfExports a chart to a PDF file.
ChartControl.ExportToXlsExports a chart to an XLS file.
ChartControl.ExportToXlsxExports a chart to an XLSX file.
ChartControl.ExportToRtfExports a chart to an RTF file.
ChartControl.ExportToDocxExports a chart to a DOCX file.
ChartControl.ExportToSvgExports a chart to an SVG image.

The following code exports a chart to a PDF file:

csharp
private void onButtonClick(object sender, EventArgs e) {
    // Exports a vector-based chart to a PDF file.
    chartControl.OptionsPrint.ImageFormat = DevExpress.XtraCharts.Printing.PrintImageFormat.Metafile;
    chartControl.ExportToPdf("D://document.pdf", 
                              new DevExpress.XtraPrinting.PdfExportOptions { ConvertImagesToJpeg = false });
}
vb
Private Sub onButtonClick(sender As Object, e As EventArgs)
    ' Exports a vector-based chart to a PDF file.
    chartControl.OptionsPrint.ImageFormat = DevExpress.XtraCharts.Printing.PrintImageFormat.Metafile
    chartControl.ExportToPdf("D://document.pdf", New DevExpress.XtraPrinting.PdfExportOptions With {
        .ConvertImagesToJpeg = False
    })
End Sub

Configure Print/Export Options

You can configure chart options before print or export. The following example prints the chart as a bitmap image:

csharp
private void onButtonClick(object sender, EventArgs e) {
    chartControl.OptionsPrint.SizeMode = PrintSizeMode.Stretch;
    chartControl.OptionsPrint.ImageFormat = PrintImageFormat.Bitmap;
    if (chartControl.IsPrintingAvailable) {
        chartControl.Print();
    }
}
vb
Private Sub onButtonClick(sender As Object, e As EventArgs)
    chartControl.OptionsPrint.SizeMode = PrintSizeMode.Stretch
    chartControl.OptionsPrint.ImageFormat = PrintImageFormat.Bitmap
    If chartControl.IsPrintingAvailable Then
        chartControl.Print()
    End If
End Sub

The example above uses the following properties.

PropertyDescription
ChartControl.OptionsPrintContains print options.
ChartOptionsPrint.SizeModeSpecifies how a chart is resized.
ChartOptionsPrint.ImageFormatSpecifies an image format used to display the chart in the Print Preview.

Custom Print/Export

You can use a PrintableComponentLink object to customize the layout of a printed/exported document.

The following example shows the Print Preview of a landscape-orientated document that contains a chart that is stretched to fit the page:

csharp
using System.Drawing.Printing;
using DevExpress.XtraCharts;
using DevExpress.XtraPrinting;
//...
PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem());
splineChart.OptionsPrint.SizeMode = DevExpress.XtraCharts.Printing.PrintSizeMode.Stretch;
pcl.Component = splineChart;
pcl.Landscape = true;
pcl.PaperKind = PaperKind.A4;
pcl.ShowPreviewDialog();
vb
Imports System.Drawing.Printing
Imports DevExpress.XtraCharts
Imports DevExpress.XtraPrinting

'...
splineChart.OptionsPrint.SizeMode = DevExpress.XtraCharts.Printing.PrintSizeMode.Stretch
pcl.Component = splineChart
pcl.Landscape = True
pcl.PaperKind = PaperKind.A4
pcl.ShowPreviewDialog()

Related API members:

PropertyDescription
ChartOptionsPrint.SizeModeSpecifies how a chart is resized.
PrintableComponentLinkBase.ComponentSpecifies the control that is printed.
LinkBase.LandscapeIndicates whether the page orientation is landscape.
LinkBase.PaperKindSpecifies the paper size.

See the following help topic for more information: How to: Use the PrintableComponentLink to Print DevExpress Controls.

Use an object of the CompositeLink class to print or export a chart with another control. Create PrintableComponentLink objects for each control and add them to the CompositeLinkBase.Links collection. The following example shows the Print Preview of a document that contains a chart and a grid:

csharp
using DevExpress.XtraCharts;
using DevExpress.XtraPrinting;
using DevExpress.XtraPrintingLinks;
// ...
CompositeLink composLink = new CompositeLink(new PrintingSystem());
PrintableComponentLink pcLink1 = new PrintableComponentLink();
PrintableComponentLink pcLink2 = new PrintableComponentLink();
pcLink1.Component = this.chartControl1;
pcLink2.Component = this.gridControl1;
composLink.Links.Add(pcLink1);
composLink.Links.Add(pcLink2);
composLink.Landscape = true;
composLink.ShowPreview();
vb
Imports DevExpress.XtraCharts
Imports DevExpress.XtraPrinting
Imports DevExpress.XtraPrintingLinks
'...
Dim composLink As CompositeLink = New CompositeLink(New PrintingSystem())
Dim pcLink1 As PrintableComponentLink = New PrintableComponentLink()
Dim pcLink2 As PrintableComponentLink = New PrintableComponentLink()
pcLink1.Component = Me.chartControl1
pcLink2.Component = Me.gridControl1
composLink.Links.Add(pcLink1)
composLink.Links.Add(pcLink2)
composLink.Landscape = True
composLink.ShowPreview()

See also: How to: Combine Links via the CompositeLink.

See Also

How to: Print a Chart and Show Its Print Preview

How to: Export a Chart to PDF

How to: Export a Chart to HTML and MHT

How to: Export a Chart to XLS

How to: Export a Chart to Image