TQRHotPDFExportFilter

QuickReport adapter (Lib\Addons\QuickReport\qrHotPDFExport.pas)

 

FastReport adapter  ReportBuilder device  DevExpress adapter

QuickReport export filter,使用 HotPDF 作為底層 PDF backend,而不是 QuickReport 自己的 QRPDFFilter。適用於已嵌入 HotPDF,並希望整個應用程式共用單一 PDF backend 的專案QRPDFFilter. Intended for projects that already embed HotPDF and want a single PDF backend across the whole application.

  TQRHotPDFExportFilter = class(TQRExportFilter)

  public

    constructor Create(Filename: string); override;

    procedure SetOutputStream(AStream: TStream);

    property Title, Author, Subject, Keywords: string;

    property PDFVersion: TPDFVersType;

    property Compressed: Boolean;

    property CompressionLevel: TPDFCompressionLevel;

  end;

 

說明

TQRHotPDFExportFilter 繼承自 TQRExportFilter,因此不需修改 QuickReport core,即可接入一般 MyReport.ExportToFilter(MyExporterInstance) workflow。由於 TQRExportFilter 不是 TComponent descendant(在 QuickReport 設計中是 plain class),因此沒有 IDE component registration;呼叫端需直接透過 Create('out.pdf') 建立 TQRHotPDFExportFilter

 

QuickReport 會將每個已準備頁面 render 成快取於 QRPrinter.PageList 的 TMetafile。adapter 不重新實作完整 per-component TextOut / AcceptGraphic / AcceptBand callback set,而是忽略它們(no-op overrides),並在 Finish 中收集各頁 metafiles:

 

1. Start(PaperWidth, PaperHeight, Font) - 建立 THotPDF instance、設定 metadata、呼叫 BeginDoc,並儲存 (PaperWidth, PaperHeight),讓 Finish 可正確 shaping pages

2. NewPage / EndPage / TextOut / AcceptGraphic - no-op (the metafile already has the rendered content).TQRHotPDFExportFilter directly via Create('out.pdf').

 

QuickReport renders each prepared page into a TMetafile cached in QRPrinter.PageList. Rather than re-implementing the entire per-component TextOut / AcceptGraphic / AcceptBand callback set, the adapter ignores those (no-op overrides) and harvests the per-page metafiles in Finish:

 

1. Start(PaperWidth, PaperHeight, Font) - create the THotPDF instance, set metadata, call BeginDoc, and save (PaperWidth, PaperHeight) so Finish can shape pages correctly.

2. NewPage / EndPage / TextOut / AcceptGraphic - no-op (the metafile already has the rendered content).

3. Finish - for each cached QRPrinter.PageList[i] metafile, add (or reuse) a HotPDF page sized to PaperWidth / PaperHeight in points and call ShowEnhancedMetafile. Then EndDoc and release.

3. Finish - 對每個快取的 QRPrinter.PageList[i] metafile,加入(或重用)尺寸為 PaperWidth / PaperHeight points 的 HotPDF page,並呼叫 ShowEnhancedMetafile。接著 EndDoc 並釋放

 

屬性Title / Author / Subject / Keywords - document metadata. When Title is empty the adapter falls back to Filename so the PDF always has a non-empty title. Set before ExportToFilter is called.

Title / Author / Subject / Keywords - 檔案 metadata。Title 為空時,adapter 會 fallback 到 Filename,因此 PDF 一定有非空 title。請在呼叫 ExportToFilter 前設定PDFVersion - PDF specification level the document should target. Defaults to pdf17.

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

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

CompressionLevel - FlateDecode level. Defaults to clDefault.

SetOutputStream(AStream) - route the PDF bytes into AStream instead of writing to disk. Call before ExportToFilter. Internally a temp file is used because HotPDF saves on CompressionLevel - FlateDecode level. Defaults to clDefault.

SetOutputStream(AStream) - 將 PDF bytes 導入 AStream,而不是寫入磁碟。請在 ExportToFilter 前呼叫。內部會使用暫存檔,因為 HotPDF 在 EndDoc 時儲存;bytes 會在 Finish 中串流回去

 

Typical workflow

 

Filter := TQRHotPDFExportFilter.Create('Report.pdf');

try

  Filter.Title := 'Monthly Statement';

  Filter.PDFVersion := pdf17;

  QuickRep1.ExportToFilter(Filter);

finally

  Filter.Free;

end;

 

Capabilities preserved

Vector and raster page content rendered by QuickReport's standard preview / printer pipeline. GDI-resolved text strings. Page sizing follows the PaperWidth / PaperHeight handed to Start by QuickReport.

 

Limitations of the metafile bridge

由於頁面會擷取為 enhanced metafiles,需要結構資訊的 QuickReport-specific PDF features(AcroForm fields、named destinations、outlines、PDF/A 或 PDF/X conformance gates)不會傳遞。輸出會忠實重現 QuickReport render 的視覺結果,但不是 structured PDF

 

Packaging note

adapter 位於 Lib\Addons\QuickReport\,且不屬於主要 HotPDF*.dpk packages,因此 QuickReport dependency 只會由選用此 adapter 的專案拉入。smoke test(smoke_qr_hotpdf.dpr)與該 unit 放在同一處Lib\Addons\QuickReport\ and is not part of the main HotPDF*.dpk packages, so the QuickReport dependency is only pulled in by projects that opt in to the adapter. A smoke test (smoke_qr_hotpdf.dpr) lives alongside the unit.

 

請參閱: TfrxHotPDFExport, TppHotPDFDevice, dxHotPDFExportReportLink, THPDFPage.ShowMetafile, Enhanced EMF/WMF Support