Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing to variable length forms using Linage is clause

Status
Not open for further replies.

HRayT

Programmer
Oct 30, 2000
12
0
0
US
I am using MF cobol both 16 and 32 bit on Windows NT4.0.
In a program that prints invoices, different invoice formats are provided for various reasons. These forms may vary in length. To set the correct forms lenght I have used a, linage is invoice-length, clause. This works fine if the printing is sent to an Okidata 320 printer by assinging the file to lpt1. If the same printing is sent to either an HP ink jet or laser the top of forms drops down the page on each following form. I can remove the linage is clause and the printing will work fine as a 11 inch form but I can no longer use other forms on the OK printer. I have viewed the file using a hex editor and without the linage is I get h'0d0a' after each line and multiples at the end of each page. With the linage is clause included it get the h'od0a' but then a string of h'0a0a0a' .
Any help or suggestions would be appreciated.
****************************
000250 SELECT PRINT-FILE
000260 ASSIGN TO PRINT-DEVICE
000270 ORGANIZATION IS LINE SEQUENTIAL
000280 FILE STATUS IS WSWRK-FSTATUS.
***********************************
000790 FD PRINT-FILE.
000800* LINAGE IS INVOICE-SIZE.
000810 01 PRT-FULL.
000820 03 FILLER PIC X(85).
000830 01 PH1-RECORD.
000840 03 FILLER PIC X(30).
000850 03 PH1-CO-NAME PIC X(25).
000860 03 FILLER PIC X(30).
000870

 
As starter info the hex 0d is a Carriage Return and the hex 0a is a Line Feed so what you are seeing are printer control characters telling it to line feed the print. This information controls the spacing of lines on the page.

With a laser printer (and HP LaserJet for instance) the control of lines on the page is through CR and LF's but the physical size of the page and the printable area on the page is controlled by the printers setup. You can only change this setup by changing the printers settings through it's hardware interface (the actual control panel) or by sending it an initialization string. The necessary string of characters to change the MARGINS, PAGE SIZE ... etc can be found in the manual describing the PJL (Printer Job Language) and PCL (Page Control Language).

 
Thanks, KidHoss
Could you tell me which manual you are referring to.
HRayT
 
For HP the USER MANUAL for the printer contains a section on writing the PJL and PCL and the coding (both in hex and decimal) for the "init string" you need to create. Since all of my experience is with the HP lines I have to assume the other printers include info in their user manuals on their PJL and PCL. Many other printers I have worked with (COMPAQ and LEXMARK for example) will emulate HP PCL so you only have to write one init string.
 
A PCL-printjob will look like :

(ESC = Escape-character, hex. 1B, dec. = 27)

ESC%-12345X
ESCE
... here will be the print data ...
ESCE
ESC%-12345X

explanation :

ESC%-12345X : UEL-Command (Universal Exit Language)
ESCE : Printer Reset Command

ESC&l#O Logical page orientation Command
(l is lowercase L, O is uppercase o)

# = 0 Portrait
1 Landspace
2 Reverse Portrait
3 Reverse Landscape

ESC&l#A Page size command
(l is lowercase L)

# = 1 Executive (7.5 inch x 10.5 inch)
2 Letter (8.5 inch x 11 inch)
3 Legal (8.5 inch x 14 inch)
6 Ledger (11 inch x 17 inch)
26 A4 (210mm x 297mm)
27 A3 (297mm x 420mm)

To select a legal page size, send : ESC&l3A

ESC&a#L Left Margin command

# = Column number

ESC&a#M Right Margin command

# = Column number

ESC&l#E Top Margin command (l is lowercase L)

# = Number of lines


Example :

working-storage section.
01 hex-char pic x value x'1b'.

*** if your compiler does not supper hex literals :
*** 01 hex-char-def pic 9(4) comp value 27.
*** 01 filler redefines hex-char-def.
*** 05 filler pic x.
*** 05 hex-char pic x.


procedure division.
...
move space to printline.
string hex-char '%-12345X'
delmited by size into printline.
write printline before 0.
move space to printline.
string hex-char 'E'
delimited by size into printline.
write printline before 0.
move space to printline.
*** set page orientation to landscape
string hex-char '&l1O'
delimited by size into printline.
write printline before 0.
move space to printline.
move 'This is print line no.1' to printline.
write printline before 1.
move 'This is print line no. 2' to printline.
write printline before 1.
move space to printline.
string hex-char 'E'
delimited by size into printline.
write printline before 0.
move space to printline.
string hex-char '%-12345X'
delimited by size into printline.
write printline before 0.
...


For more information see HP Manual PCL Printer Language – Technical Reference Manual

Please try.

 
I understand the example if you know what printer will be used. How would you handle if you had no control of the printer or printer type that would be used. We develope software for resale and customers chose their own printers.
HRAYT
 
Most inkjet and laser printers will support PCL commands (at least standard PCL commands). So you don't have to take care if it is an Epson or a HP or a Canon printer (or anything else) as long as it supports PCL.

Of course if you use vendor dependend enhancements of the PCL language you might get into trouble.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top