Back to Devexpress

TCustomdxComponentPrinter.AddLink(TComponent) Method

vcl-dxpscore-dot-tcustomdxcomponentprinter-dot-addlink-x28-system-dot-classes-dot-tcomponent-x29.md

latest4.3 KB
Original Source

TCustomdxComponentPrinter.AddLink(TComponent) Method

Creates a new print link for the specified component and adds the created link to the collection.

Declaration

delphi
function AddLink(AComponent: TComponent): TBasedxReportLink;

Parameters

NameTypeDescription
AComponentTComponent

The target component for the created print link.

The function automatically selects the print link class that corresponds to the target component type if your project includes the unit (in Delphi) or header (in C++Builder) where the print link class is declared.

|

Returns

TypeDescription
TBasedxReportLink

The created print link.

Cast the returned object to the corresponding terminal print link class to access all public API members. The type of the target component (AComponent) determines the actual print link class.

Important

The function returns nil (in Delphi) or nullptr (in C++Builder) if one of the following conditions is met:

  • The target component passed as the AComponent is not supported (has no registered print link classes).
  • The application project does not include the unit (in Delphi) or header (in C++Builder) file that declares the required print link class.

|

Remarks

Call the AddLink function to create a new print link and associate it with the component (AComponent). The created print link has the same owner as the TdxComponentPrinter component.

Note

To use the AddLink or AddLinkEx function in your project, you need to include all units (in Delphi) or headers (in C++Builder) where all required print link classes are declared. AddLink and AddLinkEx functions return nil (in Delphi) or nullptr (in C++Builder) if they cannot find the corresponding print link class declaration.

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

delphi
uses
  dxPSdxPDFViewerLnk; // Declares the TdxPDFViewerReportLink class
// ...
var
  AReportLink: TBasedxReportLink;
begin
  // Creates a PDF Viewer control print link
  AReportLink := dxComponentPrinter1.AddLink(dxPDFViewer1);
  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 "dxPSdxPDFViewerLnk.hpp" // Declares the TdxPDFViewerReportLink class
// ...
  TBasedxReportLink *AReportLink;
  // Creates a PDF Viewer control print link
  AReportLink = dxComponentPrinter1->AddLink(dxPDFViewer1);
  try
  {
    AReportLink->Print(false); // Prints chart content without user interaction
  }
  __finally
  {
    dxComponentPrinter1->DeleteLink(AReportLink->Index); // Deletes the print link after export
  }

See Also

TCustomdxComponentPrinter.AddEmptyLink Function

TCustomdxComponentPrinter.AddEmptyLinkEx Function

TCustomdxComponentPrinter.AddLinkEx Function

TCustomdxComponentPrinter Class

TCustomdxComponentPrinter Members

dxPSCore Unit