Print to a Printer

Reuse the layout and data setup in the PDF example. Replace its PrinterType, OutputName, and Print() lines with one of the following variants; keep the using block and exception handling. These calls submit a print job instead of creating a PDF file.

When adapting the downloadable Quick Start, also replace its PDF-file existence check and Created PDF: message with a print-job result message. Check the selected printer's queue and printed output, rather than looking for a PDF file.

Windows: Default or Named Printer

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

job.PrinterType = PrinterType.Win32;
job.PrinterName = "";
job.Print();

For a named printer, replace the empty string with its installed Windows printer name, for example job.PrinterName = "YOUR_WINDOWS_PRINTER";. The printer must be available to the account running the application. PrinterName selects the printer; OutputName, if set for Windows printing, is the spool-job title, not the printer name.

Linux: Named CUPS Printer

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

job.PrinterType = PrinterType.Cups;
job.PrinterName = "YOUR_CUPS_QUEUE";
job.Print();

Search documentation

Search in
More scopes
Additional scopes

All contents