TppHotPDFDevice

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

 

FastReport adapter  QuickReport adapter  DevExpress adapter

ReportBuilder 자체 ppPDFDevice 대신 HotPDF를 기본 PDF backend로 사용하는 ReportBuilder device class입니다. 이미 HotPDF를 내장하고 있으며 전체 application에서 단일 PDF backend를 사용하려는 project를 위한 것입니다

 

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 Compressed: Boolean;

    property CompressionLevel: TPDFCompressionLevel;

  end;

 

설명

TppHotPDFDeviceTppGraphicsDevice(TppCustomScreenDevice / TppImageDevice보다 한 단계 위)에서 파생되므로 TppReport.PrinterDevice에 할당하거나 TppPublisher의 publisher device로 사용할 때 ReportBuilder device chain에 들어갑니다. DeviceName'HotPDF'로 보고됩니다. ReportBuilder의 device registration은 RegisterComponents가 아니라 ppRptDeviceMap을 통해 이루어지므로 IDE component palette entry는 없습니다. 호출자는 TppHotPDFDevice를 직접 instantiate합니다

 

TppGraphicsDevice.ReceivePage를 통해 들어오는 각 page는 임시 TMetafileCanvas(BeforeRenderPage에서 생성되고 AfterRenderPage에서 finalise)에 그려집니다. 캡처된 TMetafile은 이후 HotPDF의 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. 상속된 RenderPageDrawCommands를 순회하고 GraphicsContext를 통해 metafile canvas로 라우팅합니다

4. AfterRenderPage는 metafile을 finalise(canvas 해제)하고, mmWidth x mmHeight 크기(PDF point로 변환)의 새 HotPDF page를 추가한 뒤 ShowEnhancedMetafile로 metafile을 재생합니다

5. EndJobHotPDF.EndDoc을 호출합니다. Output이 Stream이면 내부에서 작성한 temp file의 byte를 복사합니다

 

속성

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

Title / Author / Subject / Keywords - document metadata입니다. Title이 비어 있으면 device는 FileName으로 fallback하여 PDF가 항상 비어 있지 않은 title을 갖도록 합니다

PDFVersion - 문서가 대상으로 삼을 PDF specification level입니다. 기본값은 pdf17입니다

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

CompressionLevel - FlateDecode level. Defaults to clDefault.

SetOutputStream(AStream) - PDF byte를 disk에 쓰는 대신 AStream으로 라우팅합니다. Report가 StartJob을 발생시키기 전에 호출하십시오

 

Typical workflow

 

Dev := TppHotPDFDevice.Create(nil);

try

  Dev.FileName := 'Report.pdf';

  Dev.Title := 'Monthly Statement';

  Dev.PDFVersion := pdf17;

  ppReport1.DeviceType := 'HotPDF';

  ppReport1.PrinterDevice := Dev;

  ppReport1.Print;

finally

  Dev.Free;

end;

 

Capabilities preserved

ReportBuilder의 standard draw-command pipeline으로 렌더링된 vector 및 raster page content를 지원합니다. Text string은 GDI로 resolve됩니다. 기본 200 DPI metafile capture(상속된 PixelsPerInch로 구성 가능)는 지나치게 큰 파일 없이 print-quality output을 제공합니다

 

Limitations of the metafile bridge

Page가 enhanced metafile로 캡처되므로 structural information이 필요한 ReportBuilder-specific PDF feature(AcroForm fields, named destinations, outlines, PDF/A 또는 PDF/X conformance gates)는 전파되지 않습니다. Output은 ReportBuilder가 렌더링하는 내용을 충실히 시각적으로 재현한 것이며 structured PDF가 아닙니다

 

Packaging note

Device는 Lib\Addons\ReportBuilder\에 있으며 main HotPDF*.dpk package의 일부가 아니므로, ReportBuilder dependency는 이 device를 opt in하는 project에서만 끌어옵니다. Smoke test(smoke_pp_hotpdf.dpr)는 unit 옆에 있습니다

 

참조: TfrxHotPDFExport, TQRHotPDFExportFilter, dxHotPDFExportReportLink, THPDFPage.ShowMetafile, Enhanced EMF/WMF Support