[Migrated content. Thread originally posted on 20 August 2004]
Guys,
How do I send control codes to a windows printer?
I'm new to all this, so please excuse me if this is a stupid question.
For what its worth, previously in unix, we just have the relevant hex control codes inside the print file.
Now we're using the windows spooler, it just appears to do its best in printing the characters out!
Regards,
Shaun
You have to print to the device "-P SPOOLER-DIRECT".
[Migrated content. Thread originally posted on 20 August 2004]
Guys,
How do I send control codes to a windows printer?
I'm new to all this, so please excuse me if this is a stupid question.
For what its worth, previously in unix, we just have the relevant hex control codes inside the print file.
Now we're using the windows spooler, it just appears to do its best in printing the characters out!
Regards,
Shaun
Another tip, if you are in the process of porting reports from Unix (or any other non windows environment) to Windows, check out the -Q option.
Say you have a printer named HP Deskjet IX.
Say you want to print Courier New, 10 pitch, 66 lines 132 cols landscape mode.
Say you in your select statement uses PRINTER1.
Then you could put the following in your configuration file:
PRINTER1 -Q HP Deskjet IX;FONT=Courier New;PITCH=10;LINES=66;COLS=132;ORIENTATION=LANDSCAPE
Which would make your report print just nicely on your nearest windows printer.
How do I get the printer name? You could either use the prndemox.cbl in your template directory, or else:
IDENTIFICATION DIVISION.
PROGRAM-ID. EnumPrinters.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
FILE-CONTROL.
SELECT EnumPrinter ASSIGN TO "Printerlist.txt"
ORGANIZATION IS LINE SEQUENTIAL.
FILE SECTION.
FD EnumPrinter.
01 EprintRec PIC X(100).
WORKING-STORAGE SECTION.
01 PRINTERNNN.
03 FILLER PIC X(07) VALUE "PRINTER".
03 PrinterNo3 PIC 9(3).
03 FILLER PIC X(4) VALUE " -Q ".
03 FILLER PIC X(1) VALUE x"00".
01 PRINTERNN.
03 FILLER PIC X(07) VALUE "PRINTER".
03 PrinterNo2 PIC 9(2).
03 FILLER PIC X(4) VALUE " -Q ".
03 FILLER PIC X(1) VALUE x"00".
01 PRINTERN.
03 FILLER PIC X(07) VALUE "PRINTER".
03 PrinterNo1 PIC 9(1).
03 FILLER PIC X(4) VALUE " -Q ".
03 FILLER PIC X(1) VALUE x"00".
77 CALL-RESULT SIGNED-INT VALUE 0.
78 WINPRINT-GET-PRINTER-INFO-EX VALUE 28.
77 TmpStr PIC X(15).
01 WINPRINT-SELECTION.
03 WINPRINT-NAME PIC X(80).
03 WINPRINT-PORT PIC X(80).
03 WINPRINT-DRIVER PIC X(80).
03 WINPRINT-DRV-VERSION SIGNED-INT.
03 WINPRINT-NO-OF-PRINTERS SIGNED-SHORT.
03 WINPRINT-IS-DEFAULT SIGNED-SHORT.
03 WINPRINT-COPIES SIGNED-SHORT.
03 WINPRINT-ORIENTATION SIGNED-SHORT.
03 WINPRINT-QUALITY SIGNED-SHORT.
03 WINPRINT-CURR-ORIENTATION SIGNED-SHORT.
03 WINPRINT-CURR-COPIES SIGNED-SHORT.
03 WINPRINT-DUPLEX SIGNED-SHORT.
03 WINPRINT-COLLATE SIGNED-SHORT.
03 WINPRINT-COLOR SIGNED-SHORT.
03 WINPRINT-CURR-DUPLEX SIGNED-SHORT.
03 WINPRINT-CURR-COLLATE SIGNED-SHORT.
03 WINPRINT-CURR-PAPERSIZE SIGNED-SHORT.
03 WINPRINT-CURR-TRAY SIGNED-SHORT.
03 WINPRINT-CURR-COLOR SIGNED-SHORT.
03 WINPRINT-JOB-TITLE PIC X(80).
PROCEDURE DIVISION.
MAIN SECTION.
MAIN-001.
OPEN OUTPUT EnumPrinter.
INITIALIZE WINPRINT-SELECTION.
MOVE 1 TO WINPRINT-NO-OF-PRINTERS.
CALL "WIN$PRINTER" USING
WINPRINT-GET-PRINTER-INFO-EX
WINPRINT-SELECTION
GIVING CALL-RESULT.
PERFORM UNTIL CALL-RESULT NOT > 0
IF CALL-RESULT
EXIT PERFORM CYCLE
END-IF
INITIALIZE EPrintRec
TmpStr
PERFORM NUMBER-IT
INSPECT WINPRINT-NAME REPLACING TRAILING
SPACES BY LOW-VALUES
STRING TmpStr
WINPRINT-NAME DELIMITED BY
LOW-VALUES
INTO EPrintRec
WRITE EPrintRec
ADD 1 TO WINPRINT-NO-OF-PRINTERS
CALL "WIN$PRINTER" USING
WINPRINT-GET-PRINTER-INFO-EX
WINPRINT-SELECTION
GIVING CALL-RESULT
END-CALL
END-PERFORM.
CLOSE EnumPrinter.
STOP RUN.
MAIN-900.
MAIN-EXIT.
EXIT.
NUMBER-IT SECTION.
NUMBER-IT-001.
MOVE WINPRINT-NO-OF-PRINTERS TO
PrinterNo3
PrinterNo2
PrinterNo1.
IF WINPRINT-NO-OF-PRINTERS
MOVE PRINTERN TO
TmpStr
ELSE IF WINPRINT-NO-OF-PRINTERS
MOVE PRINTERNN TO
TmpStr
ELSE
MOVE PRINTERNNN TO
TmpStr
END-IF.
NUMBER-IT-900.
NUMBER-IT-EXIT.
EXIT.
You should remove your escape sequences using this technique, but then you would be 100% printer independent as well. On the other side, say you absolutely need to use the escape sequences, you can do this, but then lack all functionality except setting printer:
PRINTER1 -Q HP Deskjet IX;DIRECT=ON
You can also set the number of copies, like:
COPIES=nnn
[Migrated content. Thread originally posted on 20 August 2004]
Guys,
How do I send control codes to a windows printer?
I'm new to all this, so please excuse me if this is a stupid question.
For what its worth, previously in unix, we just have the relevant hex control codes inside the print file.
Now we're using the windows spooler, it just appears to do its best in printing the characters out!
Regards,
Shaun
Thanks Gisle,
I can't get away from control codes in this case.
It because of point of sale receipt printers. I need to tell the stupid printer to cut the paper and open the cash drawer.
Why it cant do this all by itself after it stops receiving data is beyond me.....anyway
Thanks,
Shaun