<< Click to Display Table of Contents >> Navigation: »No topics above this level« PDF export |
THtDocument has two class methods for PDF export:
class function HTMLtoPDF(const AHTML: hstring; const AStyles: hstring = ''): TBytes;
class procedure HTMLtoPDFFile(const AHTML, FileName: string);
If you need to explicitly set some document properties, use the following code:
D := THtDocument.Create(HtDefaultCanvasClass.PrintCanvasClass); // or HtFMXDefaultCanvasClass for FMX
try
D.Parse(AHTML);
D.GeneratePagesForPrint;
D.Surface.SavetoPDF(FileName);
finally
D.Free
end;
There are several PDF export implementations included:
Add htoffice to uses list (requires Office library).
Using SynPDF library: add htsynpdf unit to uses list.
Using SKIA: add htcanvasSkia to uses list and call
THtPagedExporter.RegisterExporter('PDF', THtSkiaPDFExport);
Set THtCanvasOSX as FMX default canvas class or pass it to document constructor in code above.
Set THtCanvasAndroid as default canvas class or pass it to document constructor in code above.
Set THtCanvasiOS as default canvas class or pass it to document constructor in code above.