dxHotPDFExportReportLink

DevExpress ExpressPrinting System adapter (Lib\Addons\DevExpress\dxHotPDFExport.pas)

 

FastReport adapter  QuickReport adapter  ReportBuilder device

DevExpress ExpressPrinting System (XtraPrinting / XtraReports / cxGrid printable links / and similar) PDF export adapter that uses HotPDF as the underlying PDF backend instead of DevExpress's own dxPSExportToPDF / TdxPSPDFExport emitter. Intended for projects that already embed HotPDF and want a single PDF backend across the whole application.

 

Options record:

type

  TdxHotPDFExportOptions = record

    Title, Author, Subject, Keywords: string;

    PDFVersion : TPDFVersType;  // default pdf17

    Compression: TPDFCompressionLevel;  // default clDefault

    RenderDPI  : Integer;  // default 200

  end;

 

function dxHotPDFDefaultOptions: TdxHotPDFExportOptions;

 

File-based entry points:

function dxHotPDFExportReportLinkToFile(

  AReportLink: TBasedxReportLink;

  const AOutputFileName: string;

  const AOptions: TdxHotPDFExportOptions): Boolean; overload;

function dxHotPDFExportReportLinkToFile(

  AReportLink: TBasedxReportLink;

  const AOutputFileName: string): Boolean; overload;

 

Stream-based entry points:

function dxHotPDFExportReportLinkToStream(

  AReportLink: TBasedxReportLink;

  AOutputStream: TStream;

  const AOptions: TdxHotPDFExportOptions): Boolean; overload;

function dxHotPDFExportReportLinkToStream(

  AReportLink: TBasedxReportLink;

  AOutputStream: TStream): Boolean; overload;

 

Description

DevExpress's printing system centers on TBasedxReportLink - the abstract link that bridges a printable component (cxGrid, cxRichEdit, cxScheduler, cxPivotGrid, and similar) to a TdxComponentPrinter. The printer / link composes pages, then exposes a protected PaintPage(ACanvas, APageBounds, APageIndex, AContinuousIndex, AZoomFactor) method that draws a single page to any TCanvas.

 

This adapter mirrors the loop in DevExpress's own TdxPSPDFReportExportProvider.Build, but instead of routing PaintPage's output into a DevExpress PDF canvas, it routes it into a TMetafileCanvas. The resulting metafile is then fed to HotPDF's ShowEnhancedMetafile auto-scaling importer:

 

1. The caller invokes dxHotPDFExportReportLinkToFile or dxHotPDFExportReportLinkToStream with the prepared TBasedxReportLink.

2. The adapter calls AReportLink.RebuildReport to compose pages.

3. For each page index, it asks the link for RenderInfo.GetActualPageRenderInfo, computes the page size in PDF points (using DevExpress's own PointsPerInch / UnitsPerInch ratio), builds a TMetafile at the chosen render DPI, and renders the page through PaintPage(MetaCanvas, ...).

4. A new HotPDF page is added (or the auto-created first page is reused), sized to the computed point dimensions, and the metafile is played via ShowEnhancedMetafile.

5. HotPDF.EndDoc writes the PDF; for the stream overloads, the temp file is then copied into the caller-supplied TStream.

 

Options

Title / Author / Subject / Keywords - document metadata. When Title is empty the adapter falls back to AReportLink.ReportTitle.Text, then to AReportLink.Name, so the PDF always has a non-empty title.

PDFVersion - the PDF specification level the document should target. Defaults to pdf17.

Compression - FlateDecode level. Defaults to clDefault.

RenderDPI - pixel density used when rasterising each page through TMetafileCanvas. Higher = crisper text and lines but larger metafile and PDF. 200 (default) gives print-quality results without enormous files. Values ≤ 0 are clamped to 200.

 

Typical workflow

 

dxComponentPrinter1.CurrentLink := cxGridReportLink1;

dxHotPDFExportReportLinkToFile(cxGridReportLink1, 'Grid.pdf');

 

Or with custom options:

 

Opts := dxHotPDFDefaultOptions;

Opts.Title := 'Q1 Sales';

Opts.RenderDPI := 300;

dxHotPDFExportReportLinkToFile(cxGridReportLink1, 'Grid.pdf', Opts);

 

Supported link families

Any descendant of TBasedxReportLink. This covers cxGrid, cxRichEdit, cxScheduler, cxPivotGrid, plus any custom links derived from the same base class. The adapter does not depend on the specific link type because the PaintPage contract is defined on the base.

 

Capabilities preserved

Vector and raster page content emitted by every DevExpress link family (cxGrid, cxScheduler, cxRichEdit, cxPivotGrid, custom links). GDI-resolved text strings (DevExpress renders text via TCanvas; the metafile records the GDI text calls faithfully).

 

Limitations of the metafile bridge

Because pages are captured as enhanced metafiles, DevExpress-specific PDF features that require structural information (interactive AcroForm fields, named destinations, bookmarks / outlines, PDF/A or PDF/X conformance gates) are not propagated. The output is a faithful visual reproduction of what DevExpress renders, not a structured PDF.

 

Packaging note

The adapter lives in Lib\Addons\DevExpress\ and is not part of the main HotPDF*.dpk packages, so the DevExpress ExpressPrinting dependency is only pulled in by projects that opt in to the adapter. A smoke test (smoke_dx_hotpdf.dpr) lives alongside the unit.

 

See also: TfrxHotPDFExport, TQRHotPDFExportFilter, TppHotPDFDevice, THPDFPage.ShowMetafile, Enhanced EMF/WMF Support