TppHotPDFDevice

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

 

FastReport adapter  QuickReport adapter  DevExpress adapter

Classe device ReportBuilder che usa HotPDF come backend PDF sottostante invece del ppPDFDevice di ReportBuilder. Pensata per progetti che incorporano già HotPDF e vogliono un unico backend PDF in tutta l'applicazione

 

Delphi declaration:

type

  TppHotPDFDevice = class(TppGraphicsDevice)

  public

    class function DeviceName: String; override;

    procedure StartJob; override;

    procedure EndJob; override;

    procedure CancelJob; override;

SetOutputStream(AStream) - instrada i byte PDF in AStream invece di scrivere su disco. Chiamare prima che il report avvii StartJob

    property FileName: string;

    property Title, Author, Subject, Keywords: string;

    property PDFVersion: TPDFVersType;

    property Compressed: Boolean;

    property CompressionLevel: TPDFCompressionLevel;

  end;

 

Descrizione

TppHotPDFDevice deriva da TppGraphicsDevice (un livello sopra TppCustomScreenDevice / TppImageDevice), quindi si inserisce nella device chain ReportBuilder quando assegnato a TppReport.PrinterDevice o usato come publisher device su un TppPublisher. DeviceName viene riportato come 'HotPDF'. Poiché la registrazione dei device in ReportBuilder avviene tramite ppRptDeviceMap invece di RegisterComponents, non esiste una entry nella palette componenti IDE: i chiamanti istanziano direttamente TppHotPDFDevice

 

Ogni pagina che arriva tramite TppGraphicsDevice.ReceivePage viene disegnata su un TMetafileCanvas transiente (creato in BeforeRenderPage e finalizzato in AfterRenderPage). Il TMetafile catturato viene poi passato all'importer auto-scaling ShowEnhancedMetafile di HotPDF

 

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. RenderPage (ereditato) percorre i DrawCommands e li instrada tramite GraphicsContext sulla nostra metafile canvas

4. AfterRenderPage finalizza il metafile (libera la canvas), aggiunge una nuova pagina HotPDF dimensionata a mmWidth x mmHeight (convertiti in PDF points) e riproduce il metafile tramite ShowEnhancedMetafile

5. EndJob chiama HotPDF.EndDoc; se l'output è uno Stream, copia i byte dal file temporaneo scritto internamente

 

Proprietà

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

Title / Author / Subject / Keywords - metadata del documento. Quando Title è vuoto, il device ripiega su FileName, così il PDF ha sempre un title non vuoto

PDFVersion - livello della specifica PDF a cui il documento deve puntare. Il valore predefinito è pdf17

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

CompressionLevel - FlateDecode level. Defaults to clDefault.

SetOutputStream(AStream) - instrada i byte PDF in AStream invece di scriverli su disco. Chiamare prima che il report generi StartJob

 

Workflow tipico

 

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;

 

Capacità preservate

Contenuto pagina vector e raster renderizzato dalla pipeline draw-command standard di ReportBuilder. Stringhe testo risolte da GDI. La cattura metafile predefinita a 200 DPI (configurabile tramite l'inherited PixelsPerInch) fornisce output di qualità stampa senza file enormi

 

Limiti del bridge metafile

Poiché le pagine vengono catturate come enhanced metafiles, le funzionalità PDF specifiche ReportBuilder che richiedono informazioni strutturali (AcroForm fields, named destinations, outlines, gate di conformità PDF/A o PDF/X) non vengono propagate. L'output è una riproduzione visiva fedele di ciò che ReportBuilder renderizza, non un PDF strutturato

 

Nota di packaging

Il device vive in Lib\Addons\ReportBuilder\ e non fa parte dei package principali HotPDF*.dpk, quindi la dipendenza ReportBuilder viene inclusa solo dai progetti che scelgono il device. Uno smoke test (smoke_pp_hotpdf.dpr) vive accanto all'unit

 

Vedi anche: TfrxHotPDFExport, TQRHotPDFExportFilter, dxHotPDFExportReportLink, THPDFPage.ShowMetafile, Supporto EMF/WMF migliorato