| | |
Trying to use c++ to print to a usb printer
![]() |
•
•
Join Date: Jan 2006
Posts: 32
Reputation:
Solved Threads: 0
Does anyone know how to get a c++ program to output to a usb printer or at the very least an acrobat distiller? I am trying to use the following:
ofstream print;
print.open("lpt1:", ios::out);
print<<"blah blah blah";
but I guess I have a usb printer and not a lpt1 printer. PLease help...I am going crazy here!!! :-)
MuthuIVS
ofstream print;
print.open("lpt1:", ios::out);
print<<"blah blah blah";
but I guess I have a usb printer and not a lpt1 printer. PLease help...I am going crazy here!!! :-)
MuthuIVS
You can use the printer's device driver and win32 API OpenPrinter and associated functions. (Scroll down to the bottom of the page and you will find other links).
Do you have to print to the printer directly? And is this related to your other thread?
dwk
Seek and ye shall find.
"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.
"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison
"The only real mistake is the one from which we learn nothing."
-- John Powell
Seek and ye shall find.
"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.
"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison
"The only real mistake is the one from which we learn nothing."
-- John Powell
•
•
Join Date: Jan 2006
Posts: 32
Reputation:
Solved Threads: 0
Actually it is related to my other thread about making labels. I have tried outputting to a text file with 4 labels across and 20 vertically. The problem I am running into is that once it starts printing the next line it works ok but it starts shifting up a little so by the time the program prints anywhere between the middle and last rows are all shifted and the text isnt aligning with labels.
Is there a way to at least reduce my endl character to 0.5 points or something?
Is there a way to at least reduce my endl character to 0.5 points or something?
•
•
•
•
Originally Posted by muthuivs
Where is the printer name, What is a printer hadle and printer defaults. I am not sure what to pass into these parameter : OpenPrinter(PrinterName ,PrintHandle,&PrinterDefault)
Sorry, just have never had to print directly to a printer other than in COBOL.
MuthuIVS
There are some printer MFC and non-MFC c++ classes at www.codeproject.com that you can use as examples. Printing can become pretty complex, especially if you want lines such as on a form.
•
•
•
•
The problem I am running into is that once it starts printing the next line it works ok but it starts shifting up a little so by the time the program prints anywhere between the middle and last rows are all shifted and the text isnt aligning with labels.
C++ Syntax (Toggle Plain Text)
foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo ba r foo bar foo bar foo bar foo bar foo b ar foo bar foo bar foo bar foo bar foo
dwk
Seek and ye shall find.
"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.
"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison
"The only real mistake is the one from which we learn nothing."
-- John Powell
Seek and ye shall find.
"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.
"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison
"The only real mistake is the one from which we learn nothing."
-- John Powell
•
•
Join Date: Jan 2006
Posts: 32
Reputation:
Solved Threads: 0
No, the verticle distance of the printed charachters start to get smaller. but I have decided to get the program to write to a rtf file and use a rtf label template. It seem to work better than text files and simpler than a USB printer headache.
MuthuIVS
MuthuIVS
•
•
•
•
Originally Posted by dwks
Like this?
C++ Syntax (Toggle Plain Text)
foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo ba r foo bar foo bar foo bar foo bar foo b ar foo bar foo bar foo bar foo bar foo
![]() |
Similar Threads
- Using VB Code - Silent download pdf from server and print to local printer (Visual Basic 4 / 5 / 6)
- Sending PCL3 Laserjet files to USB printer (USB Devices and other Peripherals)
- HELPPPPPPPP, Need to know about Windows XP and QuickBasic USB printer driver access (Legacy and Other Languages)
Other Threads in the C++ Forum
- Previous Thread: making labels with c++
- Next Thread: Forbidden function names in Dev_C++?
| Thread Tools | Search this Thread |
api array based binary bitmap business c++ c/c++ char class classes code coding commentinghelp compile console conversion count decide delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error faq file forms fstream function functions game givemetehcodez graph gui hash homeworkhelp homeworkhelper iamthwee ifpug ifstream infinite input int integer java lib linkedlist linker loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem proficiency program programming project python random read recursion reference rpg string strings temperature template templates test text text-file tree url variable vector video win32 windows winsock word wordfrequency wxwidgets






