If your document uses a format that is registered for printing, you might use the PowerShell (e.g. by writing a script executed from your console application):
start-process -File-Path "path-to-document" -Verb Print
Otherwise you have to prepare your data to be in a format understood by the printer (raw data).
All the following applies only if you have plain text data and your printer has a text mode.
Then prepare the print data by placing the command to select the text mode (see printer language documentation), followed by the text (which might require to be converted to a different character set), and optionally the command to leave the text mode.
Once you have that, you can use
CreateFile
and
WriteFile
to send the data to the printer. This requires having the device name for the printer. In the good old times of the Centronics interface this was just "LPT1". With modern USB or network printers you have to enumerate the printers (explaining how to do this would exceed quick answer) or look it up in the registry.
It might be also possible to use the Windows Print and Sppol API but I have never used it:
HOWTO: Send Raw Data to a Printer by Using the Win32 API[
^]