TfrxHotPDFExport

FastReport 4 / FastReport VCL adapter (

 

QuickReport adapter  ReportBuilder device  DevExpress adapter

FastReport 4 / FastReport VCL PDF export filter,使用 HotPDF 作為底層 PDF backend,而不是 FastReport 自己內建的 PDF writer。適用於已嵌入 HotPDF,並希望整個應用程式共用單一 PDF backend 的專案

 

Delphi declaration:

type

  TfrxHotPDFExport = class(TfrxCustomExportFilter)

  published

    property Compressed: Boolean default True;

    property Title, Author, Subject, Keywords: string;

    property PDFVersion: TPDFVersType default pdf17;

    property CompressionLevel: TPDFCompressionLevel default clDefault;

    property RenderDPI: Integer default 200;

  end;

 

說明

TfrxHotPDFExport 繼承自 TfrxCustomExportFilter,因此不需修改 FastReport core,即可接入一般 MyReport.Export(MyExportInstance) workflow。該 unit 會呼叫 RegisterComponents('FastReport 4.0 Export Filters', [TfrxHotPDFExport]),所以一旦 unit 加入 package,filter 就會出現在 IDE component palette

 

adapter 不重新實作 FastReport 完整 per-object PDF emitter,而是將每個已準備頁面導入 HotPDF 的 enhanced-metafile importer:

 

1.

    property UserPassword, OwnerPassword: string;

    property CryptKeyLength: THPDFKeyType default k40;

    property ProtectOptions: THPDFProtectOptions default [];

    property EncryptMetadata: Boolean default True;

    property DialogDefaultFileName, DialogFilter, DialogTitle: string;

  end;

 

Description

TfrxHotPDFExport 繼承自 TfrxCustomExportFilter,因此不需修改 FastReport core,即可接入一般 MyReport.Export(MyExportInstance) workflow。該 unit 會呼叫 RegisterComponents('FastReport 4.0 Export Filters', [TfrxHotPDFExport]),所以一旦 unit 加入 package,filter 就會出現在 IDE component palette

 

ShowDialog 為 True 且未設定輸出串流時,匯出會用儲存對話框詢問檔名。DialogDefaultFileName 填入預設檔名(空值時依序用 FileName、Title、報表名稱),DialogFilter 設定檔案類型清單(空值時為 PDF 檔案與所有檔案),DialogTitle 設定對話框標題(空值時為 Export to PDF)。靜默匯出時這些屬性沒有作用

 

The adapter can export through one of three modes:

 

1. Start creates a fresh THotPDF instance and sets the document metadata (Title / Author / Subject / Keywords / PDFVersion / Compression)

2. PageRange optionally filters the FastReport pages before HotPDF page objects are sized or filled

3. StartPage sizes the new HotPDF page in points to match the FastReport report page's millimeter dimensions

4. hemPageMetafile keeps the original whole-page preview capture path and imports it through ShowEnhancedMetafile

5. THotPDF instance and sets the document metadata (Title / Author / Subject / Keywords / PDFVersion / Compression).

2. StartPage sizes the new HotPDF page in points to match the FastReport report page's millimeter dimensions.

3. ExportObject is a no-op (the whole page is captured at FinishPage time, not per-object).

4. FinishPage 透過 Report.PreviewPages.DrawPage 將已準備的 FastReport page render 到 TMetafile,然後透過 HotPDF 的 ShowEnhancedMetafile auto-scaling importer 播放該 metafile

5. Finish 呼叫 EndDoc,並在需要時將暫存 PDF 複製到呼叫端提供的 Stream

 Compressed - HotPDF stream compression on (default True). Set False for diagnostic PDFs (~5x larger files).

屬性Title / Author / Subject / Keywords - document metadata. When Title is empty the adapter falls back to Report.Name so the PDF always has a non-empty title

PageRange - optional one-based page filter using the same syntax as HotPDF page operations, such as 1, 1,3-5, or an empty string for all pages

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

CompressionLevel - FlateDecode level. Defaults to clDefault

RenderDPI - pixel density used when rasterising the FastReport page through TMetafileCanvas. Higher = crisper text and lines but larger metafile and PDF. 96 is FastReport's native screen DPI; 200 (default) gives print-quality results without enormous files

Compressed - HotPDF stream compression on (default True). Set False for diagnostic PDFs (~5x larger files).

Title / Author / Subject / Keywords - 檔案 metadata。Title 為空時,adapter 會 fallback 到 Report.Name,因此 PDF 一定有非空 titleAutoCreateURL - forwards to THotPDF.AutoCreateURL so native memo text can create URI annotations for detected URLs

PDFVersion - 檔案應目標的 PDF specification level。預設為 pdf17FontEmbedding and NotEmbeddedFonts - forward the usual HotPDF font embedding policy into the generated report PDF

ActivateProtection, UserPassword, OwnerPassword, CryptKeyLength, CompressionLevel - FlateDecode level. Defaults to clDefault.

RenderDPI - 透過 TMetafileCanvas rasterising FastReport page 時使用的 pixel density。值越高,文字與線條越銳利,但 metafile 與 PDF 越大。96 是 FastReport 的 native screen DPI;200(預設值)可提供列印品質結果,且不會產生過大檔案

 

Typical workflow

 

Exp := TfrxHotPDFExport.Create(nil);

try

  Exp.FileName := 'Report.pdf';

  Exp.Title := 'Monthly Statement';

  Exp.PDFVersion := pdf17;

  Exp.RenderDPI := 200;

  frxReport1.Export(Exp);

finally

  Exp.Free;

end;

 

Capabilities preserved

由 FastReport 標準 layout engine render 的 vector 與 raster page content(文字、線條、矩形、填色、bitmaps)。GDI-resolved text strings(HotPDF 透過一般 HotPDF font subset path 嵌入 Windows-resolved fonts)。檔案層級 metadata

 

Limitations of the metafile bridge

由於頁面會擷取為 enhanced metafiles,需要結構資訊的 FastReport-specific PDF features(AcroForm fields、named destinations、document outlines、PDF/A 或 PDF/X conformance gates)不會傳遞。輸出會忠實重現 FastReport render 到螢幕 / 印表機的視覺結果,但不是 structured PDF。需要 AcroForm 輸出或 PDF/A conformance 的專案,應直接透過 HotPDF native API 驅動

 

Packaging note

adapter 位於 Lib\Addons\FastReport4\,且不屬於主要 HotPDF*.dpk packages,因此 FastReport dependency 只會由選用此 adapter 的專案拉入。smoke test(smoke_frx_hotpdf.dpr)與該 unit 放在同一處

 

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

Capabilities preserved

Whole-page and object-canvas modes preserve vector and raster page content rendered by FastReport's standard layout engine. Native-object mode currently preserves supported memo text as PDF text with background, horizontal and vertical alignment, and frame styles; picture views as image XObjects; simple shapes as PDF geometry; line views as strokes; and view URLs as URI link annotations. Document-level metadata is preserved in every mode

 

Limitations

FastReport-specific PDF features that require additional structural mapping (AcroForm fields, named destinations, and document outlines) are not propagated by this adapter. PDF/A and PDF/X gate properties are forwarded to HotPDF, but standard-specific assets such as OutputIntent profiles remain the caller's responsibility

 

Packaging note

The adapter is distributed as an opt-in add-on rather than a dependency of the main HotPDF*.dpk packages, so projects without FastReport do not pull in FastReport units

 

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