vcl-dxpsdxpdfviewerlnk.md
A report link that associates a PDF Viewer control with a TdxComponentPrinter component.
TdxPDFViewerReportLink = class(
TBasedxReportLink
)
The TdxPDFViewerReportLink class implements the functionality required to print a document displayed in a PDF Viewer control.
To be able to print a PDF document, you need to create a report link to associate the PDF Viewer control with a TdxComponentPrinter component in your application.
The list below outlines key members of the TdxPDFViewerReportLink class. These members allow you to define how the PDF Viewer control prints the currently displayed document.
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.PageSetup | PageSetupExDisplay the Page Setup dialog.Print | PrintEx | PrintPages | PrintPagesExPrint the document loaded into the associated PDF Viewer control.
To create a report link for a PDF Viewer 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 open the Add Link dialog.
The Available Source(s) box lists all controls for which you can create a report link. Select the target Chart control and click the OK button to create a report link (a TdxPDFViewerReportLink 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 the document displayed in the PDF Viewer 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.
The following code example creates a report link for an existing PDF Viewer control, prints its content without user interaction, and deletes the created report link:
uses
dxPSdxPDFViewerLnk; // Declares the TdxPDFViewerReportLink class
// ...
var
AReportLink: TBasedxReportLink;
begin
// Creates a PDF Viewer control report link
AReportLink := dxComponentPrinter1.AddEmptyLinkEx(TdxPDFViewerReportLink, dxPDFViewer1);
AReportLink.Component := dxPDFViewer1; // Associates the created report link with the source control
try
AReportLink.Print(False); // Prints chart content without user interaction
finally
dxComponentPrinter1.DeleteLink(AReportLink.Index); // Deletes the report link after export
end;
end;
#include "dxPSdxPDFViewerLnk.hpp" // Declares the TdxPDFViewerReportLink class
// ...
TBasedxReportLink *AReportLink;
// Creates a PDF Viewer control report link
AReportLink = dxComponentPrinter1->AddEmptyLinkEx(__classid(TdxPDFViewerReportLink), dxPDFViewer1);
AReportLink->Component = dxPDFViewer1; // Associates the created report link with the source control
try
{
AReportLink->Print(false); // Prints chart content without user interaction
}
__finally
{
dxComponentPrinter1->DeleteLink(AReportLink->Index); // Deletes the report link after export
}
The PDF Viewer report link does not support export to PDF. An ExportToPDF procedure call and settings accessible through the PDFExportOptions property have no effect.
Tip
If you need to save a modified PDF document to a file or stream, call the SaveToFile or SaveToStream procedure of the TdxPDFDocument container that stores the document.
To see the PDF Viewer print functionality in action, run the PDF Viewer demo in the VCL Demo Center installed with compiled DevExpress demos. Click the Print bar button to display the corresponding dialog.
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 PDF Viewer control demo in the following folder:
%Public%\Documents\DevExpress VCL Demos\MegaDemos\Product Demos\ExpressPDFViewer
TObject TPersistent TComponent TcxCustomComponent TcxComponent TcxScalableComponent TBasedxReportLink TdxPDFViewerReportLink
See Also