Print to a Printer

Reuse the layout and records in the PDF example. Replace its TFormer_SetPrinterType and TFormer_SetOutputName calls with the appropriate pair below. Keep CHECK, the later TFormer_Print(form) call, and cleanup unchanged; the result is a print job, not output.pdf.

Windows: Default or Named Printer

To use the current user's default Windows printer through GDI:

CHECK(TFormer_SetPrinterType(form, ePrinterType_Win32));
CHECK(TFormer_SetPrinterName(form, NULL, NULL));

For a named printer, replace the first NULL in TFormer_SetPrinterName with its installed Windows printer name, for example "YOUR_WINDOWS_PRINTER". The last NULL keeps the printer's default device settings. The printer must be available to the account running the application.

Linux: Named CUPS Printer

Use the Linux build setup, with CUPS installed and a queue configured for the runtime account. Replace YOUR_CUPS_QUEUE with that queue's name:

CHECK(TFormer_SetPrinterType(form, ePrinterType_Cups));
CHECK(TFormer_SetPrinterName(form, "YOUR_CUPS_QUEUE", NULL));

On Linux, the last argument supplies optional CUPS options; NULL uses the defaults. Use UTF-8 strings. After the output call succeeds, check the printer queue and printed output instead of opening a PDF file.

Search documentation

Search in
More scopes
Additional scopes

All contents