Categories
blog howto linux

Send PCL code for landscape to raw printer in Linux

When the CUPS printer is in RAW mode (no driver or PPD file), you can send PCL codes to the printer in plain text. You can just insert & append the codes on your job.
Here is how I did it:

#!/bin/bash
#
# Created on 01 march 2011 by Stan Gobien
# http://ares.gobien.be:8080/2011/03/pcl-code-landscape-raw-linux/
#
# Insert PCL code for landscape at beginning and append PCL reset code at end
# PCL codes tested on HP Laserjet
# The script expects input via stdin and sends output to stdout
# usage: cat somefile | ./landscape.sh | lp -dPRINTER
cat | sed -e ‘1i^[&l1O’ | sed -e ‘$a^[E’

Note: You can’t simply copy/paste the ^[ code. This is the VI representation of the ESCAPE character. You have to create it like this: CTRL+V ESC (this means press CONTROL and V key together then press ESCAPE key). Tested on Vi IMproved 7.0

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.