TfrxHotPDFExport

FastReport 4 / FastReport VCL 配接器

 

QuickReport 配接器  ReportBuilder 裝置  DevExpress 配接器

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

 

Delphi 宣告:

type

  TfrxHotPDFExport = class(TfrxCustomExportFilter)

  published

    property Compressed: Boolean default True;

    property Title, Author, Subject, Keywords: string;

    property PageRange: string;

    property PDFVersion: TPDFVersType default pdf17;

    property PDFACompliance: string;

    property PDFXCompliance: string;

    property CompressionLevel: TPDFCompressionLevel default clDefault;

    property RenderDPI: Integer default 200;

    property ExportMode: TfrxHotPDFExportMode default hemPageMetafile;

    property AutoCreateURL: Boolean default False;

    property FontEmbedding: Boolean default True;

    property NotEmbeddedFonts: TStrings;

    property ActivateProtection: Boolean default False;

    property UserPassword, OwnerPassword: string;

    property CryptKeyLength: THPDFKeyType default k40;

    property ProtectOptions: THPDFProtectOptions default [];

    property EncryptMetadata: Boolean default True;

    property DialogDefaultFileName, DialogFilter, DialogTitle: string;

  end;

 

說明

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)。靜默匯出時這些屬性沒有作用

 

adapter 可透過下列三種模式之一匯出:

 

1. Start 會建立新的 THotPDF 實例,並設定文件 metadata(Title / Author / Subject / Keywords / PDFVersion / Compression)

2. PageRange 可在 HotPDF 頁面物件配置或填入之前,選擇性篩選 FastReport 頁面

3. StartPage 依 FastReport 報表頁面的毫米尺寸,以點為單位設定新 HotPDF 頁面大小

4. hemPageMetafile 保留原本的整頁預覽擷取路徑,並透過 ShowEnhancedMetafile 匯入

5. hemObjectCanvas 要求 FastReport 先將每個已備妥的 view 繪製到中繼頁面 metafile,再由 HotPDF 匯入該頁

6. hemNativeObjects 把支援的已備妥 view 直接對應到 HotPDF 頁面呼叫,讓 memo 文字可選取並帶背景、對齊、裁剪、字元間距與框線樣式,另可輸出點陣圖片 image XObjects、簡單圖形幾何、線條筆畫與 view URL 註解

7. Finish 會呼叫 EndDoc,需要時再把暫存 PDF 複製到呼叫端提供的 Stream

 

屬性

Compressed - 開啟 HotPDF 串流壓縮(預設 True)。設為 False 可產生診斷用 PDF(檔案約大 5 倍)。

Title / Author / Subject / Keywords - 文件 metadata。Title 為空時,adapter 會退回 Report.Name,確保 PDF 一定有非空 title

PageRange - 選用的 1 基底頁面篩選,語法與 HotPDF 頁面操作相同,例如 1、1,3-5,或空字串代表全部頁面

PDFVersion - 檔案應目標的 PDF specification level。預設為 pdf17

PDFACompliance 與 PDFXCompliance - 把 HotPDF 的標準合規閘門傳遞到產生的報表 PDF。在依賴最終合規宣告之前,呼叫端仍須透過一般 HotPDF 工作流程備妥所需的 ICC profile、OutputIntent、tagging 或印前資產

CompressionLevel - FlateDecode level。預設為 clDefault

RenderDPI - 經 TMetafileCanvas 點陣化 FastReport 頁面時使用的像素密度。數值越高,文字與線條越清晰,但 metafile 與 PDF 也越大。96 是 FastReport 原生的螢幕 DPI;200(預設)可在檔案不至於過大的前提下得到列印品質

ExportMode - 選擇整頁 metafile 匯出、逐物件 canvas 匯出,或針對目前對應的 FastReport view 類別採原生物件匯出

AutoCreateURL - 轉交給 THotPDF.AutoCreateURL,讓原生 memo 文字可為偵測到的 URL 建立 URI 註解

FontEmbedding 與 NotEmbeddedFonts - 把 HotPDF 慣用的字型嵌入策略傳遞到產生的報表 PDF

ActivateProtection、UserPassword、OwnerPassword、CryptKeyLength、ProtectOptions 與 EncryptMetadata - 需要加密報表輸出時,傳遞 HotPDF 的密碼安全設定

 

Typical workflow

 

Exp := TfrxHotPDFExport.Create(nil);

try

  Exp.FileName := 'Report.pdf';

  Exp.Title := 'Monthly Statement';

  Exp.PDFVersion := pdf17;

  Exp.PDFACompliance := '3B';

  Exp.PageRange := '1,3-5';

  Exp.RenderDPI := 200;

  Exp.ExportMode := hemNativeObjects;

  Exp.AutoCreateURL := True;

  Exp.FontEmbedding := True;

  Exp.NotEmbeddedFonts.Add('Courier New');

  Exp.ActivateProtection := True;

  Exp.CryptKeyLength := aes256;

  Exp.OwnerPassword := 'owner';

  Exp.UserPassword := 'viewer';

  Exp.ProtectOptions := [prPrint, prInformationCopy];

  frxReport1.Export(Exp);

finally

  Exp.Free;

end;

 

Capabilities preserved

整頁與物件 canvas 模式都會保留 FastReport 標準 layout engine 輸出的向量與點陣頁面內容。原生物件模式目前會保留支援的 memo 文字(輸出為 PDF 文字,含背景、水平與垂直對齊及框線樣式)、圖片 view(輸出為 image XObjects)、簡單圖形(輸出為 PDF 幾何)、線條 view(輸出為筆畫)與 view URL(輸出為 URI 連結註解)。文件層級 metadata 在所有模式下都會保留

 

限制

需要額外結構對應的 FastReport-specific PDF features(AcroForm fields、named destinations 與 document outlines)不會由此 adapter 傳遞。PDF/A 與 PDF/X 的閘門屬性會轉給 HotPDF,但 OutputIntent profiles 等標準專屬資產仍由呼叫端負責

 

封裝說明

adapter 以選用式 add-on 形式發佈,而不是主要 HotPDF*.dpk packages 的相依項,因此沒有 FastReport 的專案不會拉入 FastReport units

 

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