Back to Devexpress

TdxRichEditControlReportLink Class

vcl-dxpsricheditcontrollnk.md

latest9.5 KB
Original Source

TdxRichEditControlReportLink Class

A report link that associates a Rich Edit control with a TdxComponentPrinter component.

Declaration

delphi
TdxRichEditControlReportLink = class(
    TBasedxReportLink,
    IdxPSPreviewMeasurementUnitsProvider
)

Remarks

The TdxRichEditControlReportLink class implements the functionality required to print a document displayed in a Rich Edit control.

To be able to print a rich text document or export it to a PDF file, you need to create a report link to associate the Rich Edit control with a TdxComponentPrinter component in your application.

Main API Members

The list below outlines key members of the TdxRichEditControlReportLink class that allow you to define how a document in the Rich Edit control is printed and exported to PDF.

Caption | DescriptionSpecify caption and description for the report link.IsCurrentLinkAllows you to identify if the report link is active.ShowPageHeader | ShowPageFooterSpecify if page headers and footers are visible.ReportTitle | ReportTitleMode | ReportTitleTextAllow you to add a custom title to printed pages.PrinterPageProvides access to printer page settings.PreviewExistsIdentifies whether the Print Preview dialog is visible.PreviewDisplays the Print Preview dialog.PDFExportOptions | ExportToPDFAllow you to configure PDF export settings and export a rich text document to a PDF file.PageSetup | PageSetupExDisplay the Page Setup dialog.Print | PrintEx | PrintPages | PrintPagesExPrint the associated Rich Edit control.

To create a report link for a Rich Edit control at design time, add a TdxComponentPrinter component to a form. Double-click the component to open the Report Links editor dialog.

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

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

Close the Report Links dialog. Now you can use report link and component printer APIs to print a document in the Rich Edit control and display the Print Preview dialog for the control.

To delete an existing report link at design time, double-click the TdxComponentPrinter component to open the Report Links editor dialog. Select the required report link in the Available Source(s) box and click the Delete button.

You can manage report links in a component printer, configure print settings, and execute any print and export operations in code.

The following code example creates a report link for an existing Rich Edit control, customizes report link settings, exports the displayed text document to a PDF file, and deletes the created report link:

delphi
uses
  dxRichEdit.Control, // Declares the TdxRichEditControl class
  dxPSCore, // Declares the TdxComponentPrinter class
  dxPSRichEditControlLnk; // Declares the TdxRichEditControlReportLink class
// ...

var
  AReportLink: TBasedxReportLink;
begin
  // Creates a Rich Edit control report link
  AReportLink := dxComponentPrinter1.AddEmptyLinkEx(TdxRichEditControlReportLink, dxRichEditControl1);
  AReportLink.Component := dxRichEditControl1; // 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;
cpp
#include "dxRichEdit.Control.hpp" // Declares the TdxRichEditControl class
#include "dxPSCore.hpp" // Declares the TdxComponentPrinter class
#include "dxPSRichEditControlLnk.hpp" // Declares the TdxRichEditControlReportLink class

// Add the following linker directives to the corresponding CPP source file
#pragma link "dxRichEdit.Control" // Required to use dxRichEdit.Control declarations
#pragma link "dxPSCore" // Required to use dxPSCore.hpp declarations
#pragma link "dxPSRichEditControlLnk" // Required to use dxPSRichEditControlLnk.hpp declarations
// ...
  TBasedxReportLink *AReportLink;
  // Creates a Rich Edit control report link
  AReportLink = dxComponentPrinter1->AddEmptyLinkEx(__classid(TdxRichEditControlReportLink), dxRichEditControl1);
  AReportLink->Component = dxRichEditControl1; // 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
  }

To see the Rich Edit print functionality in action, run the Word Processing RTF demo in the VCL Demo Center installed with compiled DevExpress demos. Click the Print or Print Preview button to open 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 Rich Edit control demo in the following folder:

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

Implements

IdxPSPreviewMeasurementUnitsProvider

Inheritance

TObject TPersistent TComponent TcxCustomComponent TcxComponent TcxScalableComponent TBasedxReportLink TdxRichEditControlReportLink

See Also

TdxComponentPrinter Class

TdxRichEditControlReportLink Members

dxPSRichEditControlLnk Unit