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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sample/Information for PCL or PJL line/box drawing (HP Laserjet) 2

Status
Not open for further replies.
Jun 15, 2002
31
US
I'm working on a project and need info on box drawing and line drawing
in PCL or PJL for HP Laserjet 4350 series printers. We need to manually code
to fit custom forms and data.
Samples would be great. I have found the PJL code PD, PU and SD but need to know the
parameters.
Thanks
 
Output as requested:
I have the three boxes printing.

0001: ^027E
0002: ^027&l1O
0003: Landscape Mode
0004: ^027&l5.45C
0005: ^027*p0x370Y
0006: ^027*c750a300b0P^027*p+1075X^027*c750a300b0P^027*p+950X^027*c750a300b0P
0007: ^027*p5x375Y
0008: ^027*c745a290b1P^027*p+1080X^027*c740a290b1P^027*p+950X^027*c740a290b1P^
027*p0x2750Y^027*c1100a6b0P
0009: ^027E

Thanks
 
Desired Result

-------------------- ------------------ ----------------
| | | | | |
| | | | | |
| | | | | |
-------------------- ------------------ ----------------

| | | |
| | | |
| | | |
| | | |


------------------------------------------------------------

With text printed within the columns and boxes.

Thanks
 
You are missing the point. I want the EXACT data that is going to the printer.

You are showing line numbers and apparent LFs, so I can gleen absolutely nothing from
that code.

Your landscape and init command should show...

Paper size
Orientation
Line Spacing
Top Margin(stated in lines)
Form Length(stated in # number of lines to bottom margin)

It is not clear to me at all as to how these lines are top be laid out. You said you wanted three vertical lines, but your code only shows one horizontal line.

Jim Asman
 
I don't understand at all.

Are these vertical lines to be inside the three boxes or does this have nothing to do with the first three boxes?

How tall are these lines to be and how far apart are they to be?

I have always found it considerably quicker to type raw PCL code into a file until I get what I waqnt and only then see about integrating that into your real application. Like the sample files I have posted.




Jim Asman
 
Jim;

This is the captured output file:
I have not set margins, length or spacing. Just using the defaults.

E
&l1O
Landscape Mode
&l5.45C
*p0x370Y
*c750a300b0P *p+1075X *c750a300b0P *p+950X *c750a300b0P
*p5x375Y
*c745a290b1P *p+1080X *c740a290b1P *p+950X *c740a290b1P *p0x2750Y *c1100a6b0P
E

All lines except 'Landscape Mode' start with <esc>.
 
I've been vaguely following this thread for the last couple of days, and (like Jim) I'm somewhat confused about what is actually required; the post stating the desired results doesn't show any boxes at all (presumably because this forum has removed multiple spaces (between sets of "|" characters) and replaced them with a single space in each case.

You could also clarify just what you mean by "x-axis" in your comments; in PCL terms, the x-axis is the horizontal axis, and the y-axis is the vertical axis, respectively referring to movement across and down the logical page; on a landscape page the x-axis is parallel to the long edge of the paper, but on a portrait page, the x-axis is parallel to the short edge.

Jim's tribox.pcl sample prints three boxes (wider than they are deep), equidistant along the long-edge of a landscape page; your modification of this prints three similar boxes (but which are not equidistant, and with the right-hand sides missing); it also attempts to print a horizontal black line under the three boxes, but this is not printed, since it is off the page.

I agree with Jim's comments regarding:
[ul]
[li]Use of CarriageReturn and/or LineFeed characters; these are only required when printing text in which each line is not preceded by explicit cursor positioning sequences. CarriageReturn will place the horizontal cursor back to the left margin (whatever that is set or defaulted to) and LineFeed will advance the vertical cursor by one line (the line depth defined by whatever is the current vertical motion index value).[/li]
[li]The difficulty in following PCL written in pseudo-code in some undisclosed source language (BASIC?).[/li]
[li]Defaults; do not rely on these, as changes to defaults set on the printer itself can have significant effects on PCL which does not include initialisation sequences.[/li]
[li]Addressing off the page; your vertical cursor movement to position 2750 (prior to printing the final long horizontal line) in your latest pseudo-capture snippet will place the cursor off the bottom of a landscape page (assuming that the default PCL unit-of-measure is 300 units-per-inch and that the default top-margin is (probably) 0.5 inch).[/li]
[/ul]

As mentioned above, there are also other errors in your latest snippet, which results in the white boxes not sitting exactly within the the back boxes.
 
Gentlemen;
Thank you. I'm an old time coder and have most of the HP Laserjet font,orientation,style functionality under control. The graphics have been more than challenging.
This project runs on an HP-UX box using a former IBM PostRelational Database (UniVerse).
The programming language is BASIC which is then compiled into psuedo-code.
I am converting an old style pin-feed shipping document to be produced on a Laserjet.
Three boxes on the top, Bill-To Info, Ship-To Info, box 3 Order, Order Dt, Page of...
The multiple 'vertical' lines separate the item#, product, description, ordered, shipped, backorder. This form is to be printed in landscape mode.
All suggestion and advice is greatly appreciated.
GrotonGroup
 
... and here is a sample (based on Jim's tribox.pcl) which (I think) does what you want:

[ul]
[li]Prints a landscape page on Letter size paper.[/li]
[li]Sets the PCL unit-of measure to 300 units-per-inch (this is the standard default on LaserJet devices).[/li]
[li]Sets line spacing at 6 lines-per-inch (equivalent to VMI of 8/48 inch), and a top-margin of 3 lines at that spacing.[/li]
[li]Sets text length at 45 lines (although as the sample doesn't use LineFeed-positioning for text, this is irrelevant).[/li]
[li]Defaults the left-margin to column zero (the left-edge of the logical page).[/li]
[li]Draws three boxes (each of width 750 units, depth 300 units, line width 5 units) equidistantly along the long edge of the (landscape) page.[/li]
[li]Draws four vertical lines (each of depth 900 units) underneath the line of boxes; the left-most and right-most lines align with the left and right sides of the first and third boxes, and use a line-width of 5 units; the other two lines are offset from the left and right sides of the middle box, and use a line-width of 3 units.[/li]
[li]Draws a horizontal line (of width 2850 units and depth 5 units) underneath the vertical lines.[/li]
[li]Selects the Courier Bold font, at 12 characters-per-inch, with the ISO-8859-1 character set.[/li]
[li]Prints some text ("Landscape page") at the top of the page.[/li]
[li]Prints some text ("Box n") in each box.[/li]
[li]Selects the Courier Regular font, at 16-characters-per-inch.[/li]
[li]Prints some text ("text n") in the space underneath each box, between the vertical lines.[/li]
[/ul]

Here is the (pseudo-)PCL which does the above (any spaces (except those within text strings) and line feeds are merely to make the set of sequences easier to understand - the actual PCL code doesn't include any):

Code:
<Esc>E            Printer Reset
<Esc>&u300D       Unit-of-Measure (300 PCL units per inch)
<Esc>&l2a         Page Size: Letter
       1o         Orientation: Landscape
       6d         Line Spacing (6 lines-per-inch)
       3e         Top Margin (3 lines)
       45F        Text Length (45 lines)
<Esc>*p0x         Cursor Position Horizontal (0 PCL units)
       350Y       Cursor Position Vertical   (350 PCL units)
<Esc>*c750a       Rectangle Size Horizontal (750 PCL units)
       300b       Rectangle Size Vertical   (300 PCL units)
       0P         Fill Rectangular Area: Solid Area
<Esc>*p+1050X     Cursor Position Horizontal (+1050 PCL units)
<Esc>*c750a       Rectangle Size Horizontal (750 PCL units)
       300b       Rectangle Size Vertical   (300 PCL units)
       0P         Fill Rectangular Area: Solid Area
<Esc>*p+1050X     Cursor Position Horizontal (+1050 PCL units)
<Esc>*c750a       Rectangle Size Horizontal (750 PCL units)
       300b       Rectangle Size Vertical   (300 PCL units)
       0P         Fill Rectangular Area: Solid Area
<Esc>*p5x         Cursor Position Horizontal (5 PCL units)
       355Y       Cursor Position Vertical   (355 PCL units)
<Esc>*c740a       Rectangle Size Horizontal (740 PCL units)
       290b       Rectangle Size Vertical   (290 PCL units)
       1P         Fill Rectangular Area: Solid White Areas
<Esc>*p+1050X     Cursor Position Horizontal (+1050 PCL units)
<Esc>*c740a       Rectangle Size Horizontal (740 PCL units)
       290b       Rectangle Size Vertical   (290 PCL units)
       1P         Fill Rectangular Area: Solid White Areas
<Esc>*p+1050X     Cursor Position Horizontal (+1050 PCL units)
<Esc>*c740a       Rectangle Size Horizontal (740 PCL units)
       290b       Rectangle Size Vertical   (290 PCL units)
       1P         Fill Rectangular Area: Solid White Areas
<Esc>*p0x         Cursor Position Horizontal (0 PCL units)
       350Y       Cursor Position Vertical   (350 PCL units)
<Esc>*p0x         Cursor Position Horizontal (0 PCL units)
       700Y       Cursor Position Vertical   (700 PCL units)
<Esc>*c5a         Rectangle Size Horizontal (5 PCL units)
       900b       Rectangle Size Vertical   (900 PCL units)
       0P         Fill Rectangular Area: Solid Area
<Esc>*p+900X      Cursor Position Horizontal (+900 PCL units)
<Esc>*c3a         Rectangle Size Horizontal (3 PCL units)
       900b       Rectangle Size Vertical   (900 PCL units)
       0P         Fill Rectangular Area: Solid Area
<Esc>*p+1050X     Cursor Position Horizontal (+1050 PCL units)
<Esc>*c3a         Rectangle Size Horizontal (3 PCL units)
       900b       Rectangle Size Vertical   (900 PCL units)
       0P         Fill Rectangular Area: Solid Area
<Esc>*p+900X      Cursor Position Horizontal (+900 PCL units)
<Esc>*c5a         Rectangle Size Horizontal (5 PCL units)
       900b       Rectangle Size Vertical   (900 PCL units)
       0P         Fill Rectangular Area: Solid Area
<Esc>*p0x         Cursor Position Horizontal (0 PCL units)
       1750Y      Cursor Position Vertical   (1750 PCL units)
<Esc>*c2850a      Rectangle Size Horizontal (2850 PCL units)
       5b         Rectangle Size Vertical   (5 PCL units)
       0P         Fill Rectangular Area: Solid Area
<Esc>(0N          Primary Font: Symbol Set (0N = ISO 8859-1 Latin 1)
<Esc>(s0p         Primary Font: Spacing: Fixed
       12h        Primary Font: Pitch (12 characters per inch)
       0s         Primary Font: Style (Upright, solid)
       3b         Primary Font: Stroke Weight: Bold
       4099T      Primary Font: Typeface (4099 = Courier)
<Esc>*p0x         Cursor Position Horizontal (0 PCL units)
       200Y       Cursor Position Vertical   (200 PCL units)
Landscape page
<Esc>*p50x        Cursor Position Horizontal (50 PCL units)
       450Y       Cursor Position Vertical   (450 PCL units)
Box 1
<Esc>*p1100X      Cursor Position Horizontal (1100 PCL units)
Box 2
<Esc>*p2150X      Cursor Position Horizontal (2150 PCL units)
Box 3
<Esc>(s0p         Primary Font: Spacing: Fixed
       16h        Primary Font: Pitch (16 characters per inch)
       0s         Primary Font: Style (Upright, solid)
       0b         Primary Font: Stroke Weight: Medium
       4099T      Primary Font: Typeface (4099 = Courier)
<Esc>*p50x        Cursor Position Horizontal (50 PCL units)
       800Y       Cursor Position Vertical   (800 PCL units)
text 1
<Esc>*p1100X      Cursor Position Horizontal (1100 PCL units)
text 2
<Esc>*p2150X      Cursor Position Horizontal (2150 PCL units)
text 3
<Esc>E            Printer Reset
 
... and what the PCL produces when sent to my local LaserJet 1320n:

 
>> ... Well, a LF moves the cursor too ...

Indeed it does, but if (as in my sample PCL) all the positioning (for both rectangular area graphics and text) is done using explicit 'set cursor' sequences, this is irrelevant.
 
As described, this form is essentially like an invoice or customer statement with a header, line items, and maybe some kind of a total section.

This absolutely begs to be set up as a macro, enabled as an automatic overlay. Most certainly, HP-GL/2 to do the line work. So if your basic or whatever can 'cat' a pre-existing file to the printer at the head of the job, your basic code need only to issue the overlay enabling code of a few bytes.

I do quite a bit of this kind of thing and the big "win" is that all the tricky cursor positioning and font changes are in the overlay, so your basic need only spit out the variable data and may very well need NO PCL codes other than the page format and other initializations. I typically just print the data in Courier.

I assume that you may need a "carbon" or two which may or may not need a slightly different overlay, but as the overlay file will probably be <5K there's not much overhead in sending all three in the init. Then, in your variable data enable the appropriate one for that page.

If you are cloning a pinfeed form, there can be an issue where the original form covers the entire sheet and of course you can't print edge to edge on your LaserJet. If that is the case here, you CAN use PCL/HP-GL/2 scaling facilities to create an overlay to use your EXISTING code to print the data onto the laser form.

Food for thought.

Jim Asman
 
Gentlemen;
The information in this last post was excellent.
I have been able to take the examples and info, make the modifications
and add the logic needed to fullfil the project requirements.
Thank you,
GrotonGroup
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top