TfrxHotPDFExport

FastReport 4 / FastReport VCL adapter (Lib\Addons\FastReport4\frxHotPDFExport.pas)

 

QuickReport adapter  ReportBuilder device  DevExpress adapter

ตัวกรองส่งออก PDF สำหรับ FastReport 4 / FastReport VCL ที่ใช้ HotPDF เป็น PDF backend แทน PDF writer ในตัวของ FastReport เหมาะสำหรับโปรเจกต์ที่ฝัง 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 จึงเข้ากับ workflow ปกติ MyReport.Export(MyExportInstance) ได้โดยไม่ต้องแก้ FastReport core unit นี้เรียก RegisterComponents('FastReport 4.0 Export Filters', [TfrxHotPDFExport]) ดังนั้นเมื่อเพิ่ม unit เข้า package แล้ว filter จะปรากฏใน IDE component palette

 

แทนที่จะเขียน PDF emitter แบบ per-object ของ FastReport ใหม่ทั้งหมด adapter นี้ส่งแต่ละ prepared page ผ่าน enhanced-metafile importer ของ HotPDF:

 

1. Start creates a fresh 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 render หน้า FastReport ที่เตรียมไว้เป็น TMetafile ผ่าน Report.PreviewPages.DrawPage แล้วเล่น metafile ผ่าน auto-scaling importer ShowEnhancedMetafile ของ HotPDF

5. Finish เรียก EndDoc และคัดลอก temp PDF ไปยัง Stream ที่ caller ส่งเข้ามาเมื่อจำเป็น

 

คุณสมบัติ

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

Title / Author / Subject / Keywords - document metadata หาก Title ว่าง adapter จะ fallback ไปที่ Report.Name เพื่อให้ PDF มี title ที่ไม่ว่างเสมอ

PDFVersion - ระดับ PDF specification ที่ document ควร target ค่าเริ่มต้นคือ pdf17

CompressionLevel - FlateDecode level. Defaults to clDefault.

RenderDPI - pixel density ที่ใช้เมื่อ rasterise หน้า FastReport ผ่าน TMetafileCanvas ค่ายิ่งสูง text และ lines จะคมขึ้น แต่ metafile และ PDF จะใหญ่ขึ้น 96 คือ native screen DPI ของ FastReport ส่วน 200 ซึ่งเป็นค่าเริ่มต้นให้ผลระดับ print-quality โดยไม่ทำให้ไฟล์ใหญ่มาก

 

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

vector และ raster page content (text, lines, rectangles, fills, bitmaps) ที่ render โดย layout engine มาตรฐานของ FastReport รวมถึง text strings ที่ GDI resolve แล้ว โดย HotPDF ฝัง Windows-resolved fonts ผ่าน HotPDF font subset path ปกติ และ document-level metadata

 

Limitations of the metafile bridge

เนื่องจาก pages ถูกจับเป็น enhanced metafiles ฟีเจอร์ PDF เฉพาะของ FastReport ที่ต้องใช้ structural information เช่น AcroForm fields, named destinations, document outlines, PDF/A หรือ PDF/X conformance gates จะไม่ถูกส่งต่อ output คือการทำซ้ำภาพที่ FastReport render ไปยัง screen / printer อย่างถูกต้อง ไม่ใช่ structured PDF โปรเจกต์ที่ต้องการ AcroForm output หรือ PDF/A conformance ควรขับ HotPDF โดยตรงผ่าน native API

 

Packaging note

adapter อยู่ใน Lib\Addons\FastReport4\ และไม่เป็นส่วนหนึ่งของ package หลัก HotPDF*.dpk ดังนั้น dependency ของ FastReport จะถูกดึงเข้ามาเฉพาะโปรเจกต์ที่เลือกใช้ adapter เท่านั้น smoke test (smoke_frx_hotpdf.dpr) อยู่ถัดจาก unit

 

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