|
FastReport 4 / FastReport VCL PDF export filter that uses HotPDF as the underlying PDF backend instead of FastReport's own built-in PDF writer. Intended for projects that already embed HotPDF and want a single PDF backend across the whole application
Delphi declaration:
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;
Description
TfrxHotPDFExport descends from TfrxCustomExportFilter, so it slots into the regular MyReport.Export(MyExportInstance) workflow without any FastReport core changes. The unit calls RegisterComponents('FastReport 4.0 Export Filters', [TfrxHotPDFExport]), so the filter shows up in the IDE component palette once the unit is added to a package
When ShowDialog is True and no output stream is set, the export asks for the file with a save dialog. DialogDefaultFileName fills in the file name (empty: FileName, then Title, then the report name), DialogFilter sets the file type list (empty: PDF files and all files) and DialogTitle the caption (empty: Export to PDF). They have no effect on silent exports
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. hemObjectCanvas asks FastReport to draw each prepared view to an intermediate page metafile before HotPDF imports that page
6. hemNativeObjects maps supported prepared views directly to HotPDF page calls for selectable memo text with background, alignment, clipping, character spacing, and frame styling, raster picture image XObjects, simple shape geometry, line strokes, and view URL annotations
7. Finish calls EndDoc and copies the temp PDF to the caller-supplied Stream if needed
Properties
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 rasterizing 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
ExportMode - chooses whole-page metafile export, per-object canvas export, or native-object export for the currently mapped FastReport view classes
AutoCreateURL - forwards to THotPDF.AutoCreateURL so native memo text can create URI annotations for detected URLs
FontEmbedding and NotEmbeddedFonts - forward the usual HotPDF font embedding policy into the generated report PDF
ActivateProtection, UserPassword, OwnerPassword, CryptKeyLength, ProtectOptions, and EncryptMetadata - forward HotPDF password-security settings when encrypted report output is required
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
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
|