Controlling a Printer Directly with PCL CommandsHere are some of the more common
codes that can be programmed on the host as a print job sent to MacWise for controlling a HP or compatible PCL printer:
In PCL each sequence of command typically starts with the Escape character, a start character, a value in text form, then ends in a capital letter. You can combine more than one command which start with the same two characters after the Escape by changing the last letter of the first part to lower case and leaving off the next start letter, eg: [ESC] &l1O [ESC] &l1E [ESC]&l0L would become [ESC] &l1o1e0L It is often necessary to combine the commands like this as older programs typically only allow 10 or 12 characters to be entered for each effect. To make an uppercase letter into lowercase add 32 to it's ASCII code. eg to Put a HP LaserJet 5Si into 132 column mode with 66 lines in landscape the following should work: [ESC] E [ESC] & l 1 o 0 e 6 6 f 9 D [ESC] & a 0 l 1 3 2 M [ESC] ( s 1 3 H Which is Reset, Landscape, 0 Top Margin, 66 Bottom Margin, 9 Lines per Inch, 0 Left Margin, 132 Right Margin, 13 Pitch Font. From a DOS batch file you can often send codes to a printer using ECHO commands which have been entered using EDIT. This could be to a local printer or captured to a network printer, eg: ECHO ~E~&l1o0e66f9D~&a0l132M~(s13H > LPT1: where ~ is the [ESC] character which in edit can be entered with Control P then Control [ and shows as an arrow pointing to the left. Note in Windows 2000 and XP the & symbol is used to run two or more commands from the same command line therefore it is not possible to send a command exactly as above. Workarounds include adding a double quote (") character prior to the escape string, e.g. ECHO "rest of the string" but this leaves the " character printed on the paper or adding the codes to a text file using EDIT then sending the text file to the printer with a line such as: COPY textfile.txt LPT1: I have since found that you can use a circumflex character (^) to escape the ampersand (&) to make it show as text rather than be interpreted by Windows, e.g. ECHO ~E~^&l1o0e66f9D~^&a0l132M~(s13H > LPT1: From a simple DOS based BASIC such as Quick Basic 4.5 (QB45) you can send codes in a number of ways. The easiest is to assign some codes to variables and use those in print # or lprint statements to the printer port. You use the chr$() function to send unprintable codes such as Escape and Form Feed or those difficult to enter such as the double quote " which is chr$(34) i.e.: esc$=CHR$(27) boldon$=esc$+"(s3B" boldoff$=esc$+"(s0B" formfeed$=chr$(12) filenum=FREEFILE OPEN "lpt1:" FOR OUTPUT AS filenum PRINT #filenum, boldon$ + "This is in bold" + boldoff$ CLOSE #filenum LPRINT boldon$ + "This is in bold" + boldoff$ Changing Printer Display The following code sent to a HP Printer will change the message on the display to "Any message": [ESC]%-12345X@PJL JOB @PJL RDYMSG DISPLAY="Any message" @PJL EOJ [ESC]%-12345X [ESC] is ascii 27, Control [. Enter in EDIT using Control P, Control [. PCL Technical Reference Manual. Printing_Direct_With_PCL_MacWise.html
|