TppHotPDFDevice

ReportBuilder adapter (Lib\Addons\ReportBuilder\ppHotPDFDevice.pas)

 

FastReport adapter  QuickReport adapter  DevExpress adapter

ReportBuilder device class that uses HotPDF as the underlying PDF backend instead of ReportBuilder's own ppPDFDevice. Intended for projects that already embed HotPDF and want a single PDF backend across the whole application.

 

Delphi declaration:

type

  TppHotPDFDevice = class(TppGraphicsDevice)

  public

    class function DeviceName: String; override;

    procedure StartJob; override;

    procedure EndJob; override;

    procedure CancelJob; override;

    procedure SetOutputStream(AStream: TStream);

    property FileName: string;

    property Title, Author, Subject, Keywords: string;

    property PDFVersion: TPDFVersType;

    property PDFACompliance: string;

    property PDFXCompliance: string;

    property Compressed: Boolean;

    property CompressionLevel: TPDFCompressionLevel;

    property RenderMode: TppHotPDFRenderMode;

  end;

 

Description

TppHotPDFDevice descends from TppGraphicsDevice (one level above TppCustomScreenDevice / TppImageDevice), so it slots into ReportBuilder's device chain when assigned to TppReport.PrinterDevice or used as a publisher device on a TppPublisher. DeviceName is reported as 'HotPDF'. Because device registration in ReportBuilder is done via ppRptDeviceMap rather than RegisterComponents, there is no IDE component palette entry - callers instantiate TppHotPDFDevice directly.

 

Each page coming through TppGraphicsDevice.ReceivePage is drawn onto a transient TMetafileCanvas (created in BeforeRenderPage, finalised in AfterRenderPage). The captured TMetafile is then fed to HotPDF's ShowEnhancedMetafile auto-scaling importer:

 

1. StartJob creates the THotPDF instance, sets metadata, and calls BeginDoc.

2. BeforeRenderPage creates a TMetafile sized to spWidth x spHeight plus a TMetafileCanvas, and sets it as the inherited Canvas.

3. RenderPage (inherited) walks the DrawCommands and routes them through the GraphicsContext onto our metafile canvas.

4. AfterRenderPage finalises the metafile (free canvas), adds a new HotPDF page sized to mmWidth x mmHeight (converted to PDF points), then either plays the metafile via ShowEnhancedMetafile or emits supported draw commands natively when RenderMode is hprmNativeDrawCommands.

5. EndJob calls HotPDF.EndDoc; if the output is a Stream, copies bytes from the temp file written internally.

 

Properties

FileName - target PDF path. Used unless SetOutputStream has installed a stream.

Title / Author / Subject / Keywords - document metadata. When Title is empty the device falls back to FileName so the PDF always has a non-empty title.

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

PDFACompliance and PDFXCompliance - forward HotPDF standards-conformance gates into the generated report PDF. Callers still prepare any required ICC profile, OutputIntent, tagging, or prepress assets through the normal HotPDF workflow before relying on the final conformance claim.

Compressed - HotPDF stream compression on (default True). Set False for diagnostic PDFs.

CompressionLevel - FlateDecode level. Defaults to clDefault.

RenderMode - defaults to hprmPageMetafile for the original visual bridge. Set hprmNativeDrawCommands to map supported ReportBuilder draw commands directly to HotPDF text, vector, image, and URI link operations. Pages containing unsupported commands automatically fall back to the metafile bridge.

SetOutputStream(AStream) - route the PDF bytes into AStream instead of writing to disk. Call before the report fires StartJob.

 

Typical workflow

 

Dev := TppHotPDFDevice.Create(nil);

try

  Dev.FileName := 'Report.pdf';

  Dev.Title := 'Monthly Statement';

  Dev.PDFVersion := pdf17;

  Dev.PDFACompliance := '3B';

  Dev.RenderMode := hprmNativeDrawCommands;

  ppReport1.DeviceType := 'HotPDF';

  ppReport1.PrinterDevice := Dev;

  ppReport1.Print;

finally

  Dev.Free;

end;

 

Capabilities preserved

Vector and raster page content rendered by ReportBuilder's standard draw-command pipeline. GDI-resolved text strings. Default 200 DPI metafile capture (configurable via the inherited PixelsPerInch) gives print-quality output without enormous files. Native draw-command mode maps common text, shape, line, image, and URI hyperlink commands directly to HotPDF page operations when the page contains only supported commands.

 

Limitations of the metafile bridge

Because pages are captured as enhanced metafiles, ReportBuilder-specific PDF features that require structural information (AcroForm fields, named destinations, and outlines) are not propagated. PDF/A and PDF/X gate properties are forwarded to HotPDF, but standard-specific assets such as OutputIntent profiles remain the caller's responsibility.

Native draw-command mode currently covers the common ReportBuilder draw command set and deliberately falls back to the metafile bridge for pages containing unsupported commands such as complex custom renderers or gradients, preserving visual output instead of partially emitting a page.

 

Packaging note

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

 

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