please, how do you dump pirnter commands Like

LF, CF, CR

with font commands etc to a printer port for the pirnter to obey? I had thought that when these commands are mixed with data in a text format and copied to a port eg.

"copy prncmd lpt1"

on the command prompt the printer would be able to strip out the commands from plain printable text (I hope I am not sounding naive!).
What I am getting is the whole commands being printed with the data part. Pleaase help!

Recommended Answers

All 8 Replies

For a plain textfile, the commands used to be unprintable control characters (the original use of the CTRL key). Those instructions were for a line printer or a teletype - single-font impact printers and some dot-matrix printers.

But now that Wordstar, Windows, and laser printers ruined everything (from this point of view), you have to insert formatting codes with a text editor. Each printer has its own set of instructions (many do not understand the concept of a line of type - they think in pixels). The print driver puts the correct adjustments to the text in when the text editor prints the page.

This is why old computers can't use new printers. The new printers can't understand the stream of text and control characters the old computers generate.

What's CF? Never heard of it.

If you are using an old inpact printer, the ASCII codes are:

letter A = hex 41 (for reference)
Carriage Return = hex 0D (old ctrl M)
Linefeed = Hex 0A (old ctrl J)
Backspace = Hex 08 (old ctrl H)
Formfeed (top of page) = Hex 0C (old ctrl L)

But on the IBM PC screen, these characters were used for special symbols.

Thanks alot for your response, midiMagic.
I am trying to program a particular brand of ticket printer. The documentation is sparse. They have a template manager where tickets are designed and then outputed to the port.
Unfortunately this template manager is not available. but a similar documentatiion is. Here special commands like LF, CR etc are said to be dumped with the data onto the printer ports. My understanding is that the printer is able to stripout the data from the commands.

Since the printer is not behaving as expected, My question now is -does "copy prncmd lpt1" rightly constitute dumping data to a port? This is because from the documentation is shows that when these commands are dumped to the port it is supposed to work!
What I am having now is the printing of both command and text.

I would be glad for any other insight(s)
CF is a typho! sorry about that!!

This printer might be a line printer. If so the character codes I mentioned above are valid.

The hard part is getting the codes into the printer with a program. Usually this is done through a printer driver. Do you have a driver for this printer?

There used to be a DOS Text Printer driver, but Microsoft, in it's infinite stupidity, seems to have removed it. For some reason, Microsoft doesn't seem to want people to use old equipment. But maybe you can find such a driver.

The alternative is using a program to write directly to the port. This requires the codes the printer actually uses, plus the character codes for the characters themselves. Often these are the ASCII or ISO chracter sets. This page has the character codes for ASCII:

http://www.asciitable.com/

Thanks once again midiMagic!
Yes indeed the printer is a line printer. Yes the printer was properly installed on the system with its driver and all. Like I pointed out, the documentation is sparse and some what grey in some aspects.

Below is an example of what is required to be done for me to print a line(s) of data.


1. Send an ESC @ command to initialize the printer.
2. Select the font.
3. Set any supporting features for the font.
4. Send the print data for one line.
5. End the line of data with a CR LF (carriage return, line feed).
6. Repeat steps 2 through 5 for each line on the page.
7. End the printing with an FF command (form feed).

For item 2 and 3, the document provides for what codes to send for choosing the fonts.
All the commands mentioned above have their hexadecimal equivalents.

So I hope my challenge is seen in a better light. When these commands are "sent" to the port, the printer does not respond as desired. Or is my "sending" mechanism/understanding not correct?

Thanks once again for your concern!
Hope to hear from you soon.

Those instructions may be for assembly language programming or older compilers or BASIC interpreters.

The driver may automatically do the setup and font selection for you when you start Windows.

Your programming language should automatically send the carriage return and line feed for you when you print successive lines using the language. The driver makes sure the codes are the right ones.

The formfeed is the command your language uses to send the printer to a new page.

The rest will depend on what language you are writing the program in. What language are you using? The commands are different in each programming language.

Thanks once again Midimagic for your response!
I use vb.net/asp.net. I will keep troubleshooting until I get it!


Those instructions may be for assembly language programming or older compilers or BASIC interpreters.

The driver may automatically do the setup and font selection for you when you start Windows.

Your programming language should automatically send the carriage return and line feed for you when you print successive lines using the language. The driver makes sure the codes are the right ones.

The formfeed is the command your language uses to send the printer to a new page.

The rest will depend on what language you are writing the program in. What language are you using? The commands are different in each programming language.

In vb, the char$ function lets you put in codes.

LPRINT automatically puts in the CR LF, unless you put a semicolon at the end of the statement.

char$(13) is carriage return
char$(10) is line feed
char$(12) is form feed
char$(27) is escape

I am pretty thankful for your insights:)
I am still trying to get it right. You have been most helpful. I will definitely get back to you. thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.