下面的示例演示了如何把图表数据以 PDF 文档格式导出到文件或流。

C#CopyCode image复制代码
using System.IO;
// ...

if (chartControl1.IsPrintingAvailable){
   // Exports to a PDF file.
   chartControl1.ExportToPdf("Output.pdf");

   // Exports to a stream as PDF.
   FileStream pdfStream = new FileStream("Output.pdf", FileMode.Create);
   chartControl1.ExportToPdf(pdfStream);
   // ...

   pdfStream.Close();
}
Visual BasicCopyCode image复制代码
Imports System.IO
' ...

If ChartControl1.IsPrintingAvailable Then
   ' Exports to a PDF file.
   ChartControl1.ExportToPdf("Output.pdf")

   ' Exports to a stream as PDF.
   Dim pdfStream As New FileStream("Output.pdf", FileMode.Create)
   ChartControl1.ExportToPdf(pdfStream)
   ' ...

   pdfStream.Close()
End If