Back to Devexpress

VCL Chart Print Functionality

vcl-404723-expresscharts-print-and-export-vcl-chart-print-functionality.md

latest10.8 KB
Original Source

VCL Chart Print Functionality

  • Mar 24, 2026
  • 5 minutes to read

The Chart control relies on the ExpressPrinting System to print content and export it to PDF. To be able to print chart content in your application, you need to add a TdxComponentPrinter component and create a print link for the Chart control.

You can use the following main API members to print and export chart content when a print link connects a Chart control and a component printer:

Print Link API Member[1]Component Printer API Member[1]Description
PreviewPreviewDisplay the Print Preview dialog for the source Chart control.
PageSetupPageSetupInvoke the Page Setup dialog.
PrintPrintInvoke the Print dialog or print chart content as is without user interaction.
PrintExPrintExLike Print, these methods print chart content but accept additional parameters, such as the number of copies.
ExportToPDFExportToPDFInvoke the PDF Export Options dialog or export chart content to a PDF document without user interaction.

Tip

Refer to TdxChartControlReportLink and TdxComponentPrinter class descriptions for detailed information on all available options.

Double-click the TdxComponentPrinter to invoke the Report Links editor dialog.

This dialog allows you to manage all print links in your application. Click the Add… button to invoke the Add Link dialog.

The Available Source(s) box lists all controls for which you can create a print link. Select the target Chart control and click the OK button to create a print link (a TdxChartControlReportLink class instance) for the control in the TdxComponentPrinter component.

Close the Report Links dialog. Now you can use print link and component printer APIs to print Chart control content and invoke the Print Preview dialog for the control.

Code Examples

The following code example creates a print link for an existing Chart control, prints its content without user interaction, and deletes the created print link:

delphi
uses
  dxPSdxChartControlLnk; // Declares the TdxChartControlReportLink class
// ...
var
  AReportLink: TBasedxReportLink;
begin
  // Creates a Chart control print link
  AReportLink := dxComponentPrinter1.AddEmptyLinkEx(TdxChartControlReportLink, dxChartControl1);
  AReportLink.Component := dxChartControl1; // Associates the created print link with the source control
  try
    AReportLink.Print(False); // Prints chart content without user interaction
  finally
    dxComponentPrinter1.DeleteLink(AReportLink.Index); // Deletes the print link after export
  end;
end;
cpp
#include "dxPSdxChartControlLnk.hpp" // Declares the TdxChartControlReportLink class
// ...
  TBasedxReportLink *AReportLink;
  // Creates a Chart control print link
  AReportLink = dxComponentPrinter1->AddEmptyLinkEx(__classid(TdxChartControlReportLink), dxChartControl1);
  AReportLink->Component = dxChartControl1; // Associates the created print link with the source control
  try
  {
    AReportLink->Print(false); // Prints chart content without user interaction
  }
  __finally
  {
    dxComponentPrinter1->DeleteLink(AReportLink->Index); // Deletes the print link after export
  }

Export Chart Content to PDF

The following code example creates a print link for an existing Chart control, configures print link settings, exports control content to a password-protected PDF document with a digital signature without user interaction, and deletes the created print link:

delphi
uses
// ...
  dxX509Certificate, dxPSPDFExportCore, dxPSdxChartControlLnk;
// ...
var
  AExportSettings: TdxPSPDFReportExportOptions;
  AReportLink: TBasedxReportLink;
  ACertificate: TdxX509Certificate;
begin
  // Creates a Chart control print link
  AReportLink := dxComponentPrinter1.AddEmptyLinkEx(TdxChartControlReportLink, dxChartControl1);
  AReportLink.Component := dxChartControl1; // Associates the created print link with the source control
  AExportSettings := TdxPSPDFReportExportOptions.Create; // Creates default export settings
  // Loads an X.509 certificate required to create a digital signature
  ACertificate := TdxX509Certificate.Create('123.pfx', '123456');
  try
    // Configures PDF export settings
    AExportSettings.Author := 'DevExpress VCL';
    AExportSettings.Keywords := 'PDF, Chart, VCL, DevExpress';
    AExportSettings.CompressStreams := True;
    // Enables password protection
    AExportSettings.SecurityOptions.UserPassword := '123';
    AExportSettings.SecurityOptions.Enabled := True;
    // Adds a digital signature to the exported document
    AExportSettings.SignatureOptions.Reason := 'Approved';
    AExportSettings.SignatureOptions.Certificate := ACertificate;
    AExportSettings.SignatureOptions.Enabled := True;
    // Exports chart content to a PDF file in the application directory without user interaction
    AReportLink.ExportToPDF('output.pdf', False, ASettings);
  finally
    dxComponentPrinter1.DeleteLink(AReportLink.Index); // Deletes the print link after export
    AExportSettings.Free; // Destroys the created export settings instance to free up reserved memory
    ACertificate.Free; // Releases the X.509 certificate used to create a digital signature
  end;
end;
cpp
// ...
  #include "dxX509Certificate.hpp"
  #include "dxPSPDFExportCore.hpp"
  #include "dxPSdxChartControlLnk.hpp"
  // ...
  TBasedxReportLink *AReportLink;
  TdxPSPDFReportExportOptions *AExportSettings;
  TdxX509Certificate *ACertificate;
  // Creates a Chart control print link
  AReportLink = dxComponentPrinter1->AddEmptyLinkEx(__classid(TdxChartControlReportLink), dxChartControl1);
  AReportLink->Component = dxChartControl1; // Associates the created print link with the source control
  AExportSettings = new TdxPSPDFReportExportOptions(); // Creates default export settings
  // Loads an X.509 certificate required to create a digital signature
  ACertificate = new TdxX509Certificate("123.pfx", "123456");
  try
  {
    // Configures PDF export settings
    AExportSettings->Author = "DevExpress VCL";
    AExportSettings->Keywords = "PDF, Chart, VCL, DevExpress";
    AExportSettings->CompressStreams = true;
    // Enables password protection
    AExportSettings->SecurityOptions->UserPassword = "123";
    AExportSettings->SecurityOptions->Enabled = true;
    // Adds a digital signature to the exported document
    AExportSettings->SignatureOptions->Reason = "Approved";
    AExportSettings->SignatureOptions->Certificate = ACertificate;
    AExportSettings->SignatureOptions->Enabled = true;
    // Exports chart content to a PDF file in the application directory without user interaction
    AReportLink->ExportToPDF("output.pdf", false, ASettings);
  }
  __finally
  {
    dxComponentPrinter1->DeleteLink(AReportLink->Index); // Deletes the print link after export
    delete AExportSettings; // Destroys the created export settings instance to free up reserved memory
    delete ACertificate; // Releases the X.509 certificate used to create a digital signature
  }

To see the Chart print functionality in action, run the Chart Control demo in the VCL Demo Center installed with compiled DevExpress VCL demos. Click the Print or Print Preview button to invoke the corresponding dialog.

Download: Compiled VCL Demos

Tip

Compiled DevExpress demos ship with source code installed in the Public Documents folder (%Public%) for all users ( default ). You can find all project and source code files for the Chart control demo in the following folder:

%Public%\Documents\DevExpress VCL Demos\MegaDemos\Product Demos\ExpressChart

Footnotes

  1. You can use corresponding API members of the TdxComponentPrinter and TdxChartControlReportLink components interchangeably if the print link for the source Chart control is set as current.

See Also

Print and Export

VCL Chart Data Export