vcl-dxpscore.md
A component printer.
TdxComponentPrinter = class(
TCustomdxComponentPrinter
)
A component printer is a non-visual component designed to print content of any control in your application. This component manages a list of print links (TBasedxReportLink class descendant instances) that import information from printed components.
Tip
The core print-related APIs are designed for simple document generation scenarios and print/content export operations available for the majority of DevExpress VCL Controls (shipped as part of ExpressQuantum Pack, VCL Subscription, and VCL Subscription+).
For most advanced report generation and BI/data analytics usage scenarios, we recommend that you use our ExpressReports and ExpressDashboards Suites (available as part of the VCL Subscription +). These advanced solutions include both the powerful report generator and customizable print preview, BI dashboard designer and viewer for data analytics (available both at design- and runtime), smart/AI functions, non-GUI/service-based document generation, and much more.
While TdxComponentPrinter is the main component required to print any control or export its content, you need to create print links to associate the component with all controls you need to print.
Double-click the component to display the Report Links editor dialog.
This dialog allows you to manage all print links in your application. Click the Add… button to open the Add Link dialog.
The Available Source(s) box lists all controls for which you can create a print link. For example, you can select a Chart control and click the OK button to create a print link (a TdxChartControlReportLink class instance) for the control.
Close the Report Links dialog. You can now use print link and component printer APIs to print Chart control content and display the Print Preview dialog for the control.
The following code example creates a report link for an existing Chart control, customizes report link settings, exports control content to a PDF document file, and deletes the created report link:
uses
dxPSdxChartControlLnk; // Declares the TdxChartControlReportLink class
// ...
var
AReportLink: TBasedxReportLink;
begin
// Creates a Chart control report link
AReportLink := dxComponentPrinter1.AddEmptyLinkEx(TdxChartControlReportLink, dxChartControl1);
AReportLink.Component := dxChartControl1; // Associates the created report link with the source control
try
AReportLink.PDFExportOptions.JPEGQuality := 80; // Adjusts the JPEG compression rate for export
AReportLink.PDFExportOptions.OpenDocumentAfterExport := True; // Opens the resulting document after export
AReportLink.ExportToPDF; // Displays "PDF Export Options" and "Save As" dialogs
finally
dxComponentPrinter1.DeleteLink(AReportLink.Index); // Deletes the report link after export
end;
end;
#include "dxPSdxChartControlLnk.hpp" // Declares the TdxChartControlReportLink class
// ...
TBasedxReportLink *AReportLink;
// Creates a Chart control report link
AReportLink = dxComponentPrinter1->AddEmptyLinkEx(__classid(TdxChartControlReportLink), dxChartControl1);
AReportLink->Component = dxChartControl1; // Associates the created report link with the source control
try
{
AReportLink->PDFExportOptions->JPEGQuality = 80; // Adjusts the JPEG compression rate for export
AReportLink->PDFExportOptions->OpenDocumentAfterExport = true; // Opens the exported document
AReportLink->ExportToPDF(); // Displays "PDF Export Options" and "Save As" dialogs
}
__finally
{
dxComponentPrinter1->DeleteLink(AReportLink->Index); // Deletes the report link after export
}
The list below outlines key members of the TdxComponentPrinter class. These members allow you to manage print links and print content of different controls in your application.
DateFormat | TimeFormatSpecify date and time formats.LoadFromFile | LoadFromStreamLoad component printer and print link settings from a file or stream.LoadFromIniFile | LoadFromRegistryLoad format settings from an INI file or the system registry.OptionsAllows you to disable or enable individual component printer behavior options.OverwriteExistingFilesSpecifies if the component printer overwrites existing report image files.SaveToIniFile | SaveToRegistrySave the current format settings to an INI file or the system registry.SaveToFile | SaveToStreamSave the current component printer and print link settings to a file or stream.
AddLink | AddLinkEx | AddEmptyLink | AddEmptyLinkExCreate new print links.AssignReportLinksCopies print links between component printers.CurrentLink | CurrentLinkIndexAllow you to change the active print link.DeleteLink | DeleteAllLinksDelete existing print links.ReportLinkProvides indexed access to all print links in the component printer.
EnumPagesAsImages | SavePagesAsImagesToDiskAllow you to export report content in bitmap formats.ExportToPDFExports report content to PDF.OnExportProgressAllows you to track export progress.Print | PrintEx | PrintPages | PrintPagesExAllow you to print a report.
PageSetup | PageSetupExDisplay the Page Setup dialog.PreviewOptionsAllows you to customize the Print Preview dialog.ShowCustomizeDlgDisplays the Edit Reports dialog.
TObject TPersistent TComponent TcxCustomComponent TcxComponent TcxScalableComponent TCustomdxComponentPrinter TdxComponentPrinter
See Also