Solved

Printing text to a printer - need example

Posted on 2006-11-14
2
193 Views
Last Modified: 2010-04-01
I am new to C++ and I need some help.
I need to know how to print text to a printer in a cosole application.

I can print to the screen but I can't rint to the printer.

Thanks!
0
Comment
Question by:koneill99
2 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 17939592
You can write to the printer using an ofstream with 'PRN' as the filename, e.g.

#include <fstream>
using namespace std;

void test_printer() {

ofstream printer("PRN");

printes << "This is a test" << endl;

}
0
 
LVL 6

Accepted Solution

by:
_iskywalker_ earned 250 total points
ID: 17940570
you could also generate a text, save it as txt file then call:
char filename[]="my.txt";
char command[256];
sprintf(command,"a2ps %s -o my.ps",filename);
system(command);
sprintf(command," lpr my.ps");
system(command);
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question