I don't know whether i am on right path but this may help..
Linux provides a program called lpr that accepts standard input and sends it to the printer.
Ex:
cat poorly_formatted_report.txt | fmt | pr | lpr
we use cat to read the file and output it to standard output, which is piped into the standard input of fmt. fmt formats the text into neat paragraphs and outputs it to standard output, which is piped into the standard input of pr. prsplits the text neatly into pages and outputs it to standard output, which is piped into the standard input of lpr. lpr takes its standard input and sends it to the printer.