TMS FNC Core provides a layered print library. Use the level that matches your needs:
Class
Level
Use when
TTMSFNCPrinter (via TMSFNCPrinter)
Low-level
Full control over drawing; draw directly on printer canvas.
TTMSFNCGraphicsPrintIO
Mid-level
Print FNC components or graphics with header, footer, and page number.
TTMSFNCGridPrintIO
Component-specific
Multi-page grid export with repeat-fixed-cells and other grid options.
TTMSFNCRichEditorPrintIO
Component-specific
RichEditor export with automatic line breaks and new pages.
Add the appropriate unit to your uses clause based on the chosen framework (FMX., VCL., or WEBLib.).
TTMSFNCPrinter
The low-level printer. Use the global TMSFNCPrinter instance. Place all drawing inside the OnDrawContent callback and call EndDoc at the end of the callback.
Warning
On Android, BeginDoc is asynchronous — drawing code after BeginDoc does not execute sequentially. Place all drawing inside OnDrawContent. Also add FNCPrintDocumentAdapter.jar (or the combined FNC JAR) to your project libraries.
Start a new print document. On Android this triggers the asynchronous print flow; place all drawing in OnDrawContent.
EndDoc
Close the document and send it to the printer. Call this at the end of OnDrawContent.
NewPage
Add a new page to the document.
TMSFNCPrinter Events
Event
Description
OnDrawContent
Fired when the printer is ready to receive drawing commands. Place all TTMSFNCGraphics calls here and call EndDoc at the end. On Android this is the only supported location for drawing code.
TMSFNCPrinter Properties
Property
Description
Device
Active printer name (not used on WEB, Android, iOS)
DPI
Printer DPI (settable on WEB and Android)
Graphics
TTMSFNCGraphics for drawing on the printer canvas
Orientation
poPortrait or poLandscape
PageWidth / PageHeight
Page dimensions in pixels (PageWidth/PageHeight settable on WEB)
PageNumber
Zero-based index of the current page
PrintJobName
Android: print job name
PrintSize
Android: paper size
PrintCompleted
iOS: True when print is complete
TTMSFNCGraphicsPrintIO
A mid-level wrapper that adds header, footer, page number, and layout margins on top of TTMSFNCPrinter. It can also export FNC components directly.
TTMSFNCPrintIOOptions for header, footer, page number, margins, and device settings
ExportObject
Sets the FNC component to export (alternative to passing via Print())
BitmapContainer
TTMSFNCBitmapContainer attached to the graphics context during export, so named bitmaps resolve correctly when the exported component draws them
Events
Event
Description
OnBeforeDrawHeader / OnAfterDrawHeader
Before/after header drawing; set ADefaultDraw := False for custom drawing
OnBeforeDrawFooter / OnAfterDrawFooter
Before/after footer drawing
OnBeforeDrawPageNumber / OnAfterDrawPageNumber
Before/after page number drawing
OnBeforeDrawContent / OnAfterDrawContent
Before/after each export object drawing
OnAfterDraw
Fired once when all drawing (including headers, footers, and all export objects) is complete
OnCanCreateNewPage
Control whether a new page is created before the next component
OnGetExportRect
Modify the export rectangle before rendering
Custom header with multi-component export
The example below exports a chart and a grid on the same page, attaches a bitmap container for image resolution, and draws a logo in the header alongside the default header text.
uses
FMX.TMSFNCPrintIO, FMX.TMSFNCBitmapContainer, FMX.TMSFNCGraphicsTypes;
procedure TForm1.PrintReportClick(Sender: TObject);
var
objs: TTMSFNCPrintIOExportObjectArray;
rects: TTMSFNCPrintIOExportRectArray;
topMargin, leftMargin: Single;
begin
// Attach a bitmap container so embedded images render during export
TMSFNCGraphicsPrintIO1.BitmapContainer := TMSFNCBitmapContainer1;
TMSFNCGraphicsPrintIO1.Options.Header := 'Quarterly Report';
TMSFNCGraphicsPrintIO1.Options.HeaderSize := 40;
TMSFNCGraphicsPrintIO1.Options.PageNumber := pnFooter;
TMSFNCGraphicsPrintIO1.Options.PageNumberFormat := 'Page %d';
// Draw a logo in the right half of the header area instead of default text
TMSFNCGraphicsPrintIO1.OnBeforeDrawHeader :=
procedure(AExportObject: TTMSFNCPrintIOExportObject; APageIndex: Integer;
ARect: TRectF; AGraphics: TTMSFNCGraphics; AHeader: string;
var ADefaultDraw: Boolean)
var
logoRect: TRectF;
begin
logoRect := RectF(ARect.Right - 80, ARect.Top + 4, ARect.Right - 4, ARect.Bottom - 4);
AGraphics.DrawBitmapName('logo', logoRect);
ADefaultDraw := True; // still draw the text on the left side
end;
// Place chart above the grid, each object on its own portion of the page
leftMargin := TMSFNCGraphicsPrintIO1.Options.Margins.Left;
topMargin := TMSFNCGraphicsPrintIO1.Options.Margins.Top;
SetLength(objs, 2);
objs[0] := TMSFNCChart1;
objs[1] := TMSFNCGrid1;
SetLength(rects, 2);
rects[0] := RectF(leftMargin, topMargin,
leftMargin + TMSFNCChart1.Width,
topMargin + TMSFNCChart1.Height);
rects[1] := RectF(leftMargin, rects[0].Bottom + 8,
leftMargin + TMSFNCGrid1.Width,
rects[0].Bottom + 8 + TMSFNCGrid1.Height);
TMSFNCGraphicsPrintIO1.Print(objs, rects);
end;
TTMSFNCGridPrintIO
Extends TTMSFNCGraphicsPrintIO for multi-page grid export. Assign the grid to the Grid property and call Print. The component handles page breaks automatically.
Extends TTMSFNCPrintIOOptions with grid-specific output control:
Property
Default
Description
CellLayout
gclFull
How cells are rendered: gclFull (full cell with borders and background), gclColor (color only, no borders), gclNone (plain text)
RepeatFixedRows
False
Repeat fixed rows at the top of each new page
RepeatFixedColumns
False
Repeat fixed columns at the left of each new page
FitToPage
True
Scale the grid width to fit the printable page width
TTMSFNCGridPrintIO Events
Event
Description
OnRowIsPageBreak
Fired before each row is printed. Set IsPageBreak := True to force a page break before the row. Use this to keep logical groups of rows together.
OnBeforeDrawContent / OnAfterDrawContent
Inherited from TTMSFNCGraphicsPrintIO
TTMSFNCRichEditorPrintIO
Prints TTMSFNCRichEditor content with automatic line break detection and multi-page flow. Assign the editor to the RichEditor property and call Print. The component calculates where lines wrap at the page width and inserts page breaks automatically — no manual pagination is needed.