×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Printing a Color Box using PCL code

Printing a Color Box using PCL code

Printing a Color Box using PCL code

(OP)
I am new to PCL coding and am running into some walls finding a way to print a simple colored box.

I am printing to HP Color LaserJet CP2025 printer using a text file to send directly to the printer.

I have figured out how to use the simple colors to print a basic green box, but my users would like to see a lime green or "bright" green box instead.

This is what I am currently using:
<esc>-12345x
<esc>*p000x000Y
<esc>*c1000A
<esc>*c300B
<esc>*r3U
<esc>*v2s
<esc>*c0P
<esc>-12345x

I am assuming I will need to use a more complex color set up and have been playing a with a few but without success. Any help in getting this box to print would be appreciated.

Thank you.

RE: Printing a Color Box using PCL code

Assuming your printer DOES support PCL5 color try this ...

<esc>E
#Configure RGB, indexed by pixel, max 4 entries, 8 bits ea RGB value
<esc>*v6W 00 01 02 08 08 08 (those are 6 hex bytes followinw the W
#Define colors 0-2 (0=black,1=white,2=lime)
<esc>*v0a0b0c0I <esc>*v255a255b255c1I <esc>130a255b0c2I
#select lime color as defined in index 2
<esc>*v2S
#position cursor a print lime rectangle
<esc>*p500x500Y<esc>*c800a800b0P
Back to black
<esc>*v0S
#position cursor and print text
<esc>*p100x1500YBack to black
<esc>E

Get the PCL5c reference manual for a proper explanation
Don't include the comment lines beginning with a #
I hope I haven't made any typos. How you get the 6 hex bytes into
your file will depend on the capabilities of your editor.
I usually just enter some dummy bytes, and then go in using a
hex editor and change the dummies to the correct values.

Jim Asman
http://www.spectracolorservices.com

RE: Printing a Color Box using PCL code

Just to correct a few errors in the original 'simple colour' sample; it should be:

CODE -->

<Esc>%-12345X     Universal Exit Language (UEL)
<Esc>*p000x       Cursor Position Horizontal (000 PCL units)
       000Y       Cursor Position Vertical   (000 PCL units)
<Esc>*c1000A      Rectangle Size Horizontal (1000 PCL units)
<Esc>*c300B       Rectangle Size Vertical   (300 PCL units)
<Esc>*r3U         Simple Colour: 3-Plane RGB Palette
<Esc>*v2S         Foreground Colour (index = 2)
<Esc>*c0P         Fill Rectangular Area: Solid Area
<Esc>%-12345X     Universal Exit Language (UEL) 

where <Esc> represents the non-graphic control-code Escape character (decimal code 27, or hexadecimal 1B).

RE: Printing a Color Box using PCL code

... and the 'palette colour' example is missing an '*v'; it should be (omitting the original comment lines):

CODE -->

<Esc>E            Printer Reset
<Esc>*v6W         Configure Image Data (data length = 6)
[ 6 bytes ]       [ 00 01 02 08 08 08 ]
<Esc>*v0a         Colour Component 1 (primary value = 0)
       0b         Colour Component 2 (primary value = 0)
       0c         Colour Component 3 (primary value = 0)
       0I         Assign Colour Index (index = 0)
<Esc>*v255a       Colour Component 1 (primary value = 255)
       255b       Colour Component 2 (primary value = 255)
       255c       Colour Component 3 (primary value = 255)
       1I         Assign Colour Index (index = 1)
<Esc>*v130a       Colour Component 1 (primary value = 130)
       255b       Colour Component 2 (primary value = 255)
       0c         Colour Component 3 (primary value = 0)
       2I         Assign Colour Index (index = 2)
<Esc>*v2S         Foreground Colour (index = 2)
<Esc>*p500x       Cursor Position Horizontal (500 PCL units)
       500Y       Cursor Position Vertical   (500 PCL units)
<Esc>*c800a       Rectangle Size Horizontal (800 PCL units)
       800b       Rectangle Size Vertical   (800 PCL units)
       0P         Fill Rectangular Area: Solid Area
<Esc>*v0S         Foreground Colour (index = 0)
<Esc>*p100x       Cursor Position Horizontal (100 PCL units)
       1500Y      Cursor Position Vertical   (1500 PCL units)
Back to black
<Esc>E            Printer Reset 

By the way, I can't access the 'mkcolor.pcl' file (I get a 404 error).

RE: Printing a Color Box using PCL code

(OP)
Thank you for all the suggestions.

The process I am working with is creating a text file of PCL code that I send to the printer to print. I am still having difficulties with the line:

<Esc>*v6W Configure Image Data (data length = 6)
[ 6 bytes ] [ 00 01 02 08 08 08 ]

Are the bytes already in HEX or do I need to convert those numbers into their equivalent values? Is there a command to get it to read them as HEX?

RE: Printing a Color Box using PCL code

... and here is an analysis of Jim's file:

CODE -->

<Esc>E            Printer Reset
<CR>              Carriage Return
<LF>              Line Feed
<Esc>(s3B         Primary Font: Stroke Weight: Bold
<CR>              Carriage Return
<LF>              Line Feed
<Esc>*p100x       Cursor Position Horizontal (100 PCL units)
       200Y       Cursor Position Vertical   (200 PCL units)
Some black text
<CR>              Carriage Return
<LF>              Line Feed
<Esc>*v6W         Configure Image Data (data length = 6)
[ 6 bytes ]       [ 00 01 02 08 08 08 ] <-- these are the binary values
<CR>              Carriage Return
<LF>              Line Feed
<Esc>*v0a         Colour Component 1 (primary value = 0)
       0b         Colour Component 2 (primary value = 0)
       0c         Colour Component 3 (primary value = 0)
       0I         Assign Colour Index (index = 0)
<Esc>*v255a       Colour Component 1 (primary value = 255)
       255b       Colour Component 2 (primary value = 255)
       255c       Colour Component 3 (primary value = 255)
       1I         Assign Colour Index (index = 1)
<Esc>*v130a       Colour Component 1 (primary value = 130)
       250b       Colour Component 2 (primary value = 250)
       0c         Colour Component 3 (primary value = 0)
       2I         Assign Colour Index (index = 2)
<CR>              Carriage Return
<LF>              Line Feed
<Esc>*v2S         Foreground Colour (index = 2)
<CR>              Carriage Return
<LF>              Line Feed
<Esc>*p500x       Cursor Position Horizontal (500 PCL units)
       500Y       Cursor Position Vertical   (500 PCL units)
<Esc>*c800a       Rectangle Size Horizontal (800 PCL units)
       800b       Rectangle Size Vertical   (800 PCL units)
       0P         Fill Rectangular Area: Solid Area
<CR>              Carriage Return
<LF>              Line Feed
<Esc>*v0S         Foreground Colour (index = 0)
<CR>              Carriage Return
<LF>              Line Feed
<Esc>*p188x       Cursor Position Horizontal (188 PCL units)
       1500Y      Cursor Position Vertical   (1500 PCL units)
Back to black
<CR>              Carriage Return
<LF>              Line Feed
<Esc>E            Printer Reset
<CR>              Carriage Return
<LF>              Line Feed 

Note that the Carriage Return (hexadecimal 0D) and Line Feed (hexadecimal 0A) characters are not really required in this file - they are probably there as a consequence of how the PCL file was saved.

RE: Printing a Color Box using PCL code

(OP)
Is anyone aware of a good way to embed the binary into a text file programmatically? We work with Unix, Windows, or Javascript/HTML.

RE: Printing a Color Box using PCL code

it depends on the programming language.

In c, if you want 0x00, then aa=0; 0x08 aa=8;

In Basic, 0x00 aa=chr$(0), 0x08 aa=chr$(8), 0xA2 aa=chr$(162)

Bourne shell, 0x00 aa=`echo "\000"` 0x08 aa=`echo "\010"` 0xA2 aa=`echo "\242"`
Note that those are 3 digit octal values after the "\"

As I sugested earlier put in ascii placeholders and later edit with a Hex editor; e.g.,

<esc>*v6WXXXXXX

Then with the hex editor change the XXXXXX to 00 01 02 08 08 08

Jim Asman
http://www.spectracolorservices.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close