[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Printing with a HP DeskJet 960c.



On Sat, 26 Dec 1998, Yarin Benado wrote:

> I have this blody printer but i cant print with it normally in linux.
> (slackware 3.6)
> 
> can someone give me full instructions with a filter, printcap entry
> and stuff like that?

I am attaching 3 files, one being the printcap, and two being the text and
the PS filter.

I also am enclosing `horaot hatkana'.

----
   Before we begin, you need to find out one thing, which is if
ghostscript is installed on your system. In order to do that, type:

/usr/bin/gs -h|grep cdeskjet

If you get a line like:

	bj10e bj200 bjc600 cdeskjet cdjcolor cdjmono cdj500 cdj550

If that includes the cdeskjet word in it, that is fine.

Ok. You'll have to add to the /etc/printcap file the contents of the
printcap file I sent you, you can simply (as root) do:

cat printcap >> /etc/printcap 

and it will append it to your current printcap file.

After you added these, do:

mkdir /var/spool/lpd
mkdir /var/spool/lpd/text /var/spool/lpd/ps
cd /var/spool/lpd/text
touch log acct
cd /var/spool/lpd/ps
touch log acct
mkdir /usr/local/lib/filters

Put the two attached files (hpdjtext & hpdjps) there. After you put them
there, do:

cd /usr/local/lib/filters
chmod +x hpdjflt ps

After all this is done, type:

lpq -Ptext

The output should be:

no entries

Same goes for doing lpq -Pps

Now, send a postscript file to the printer:

lpr -Pps somefile.ps

Then, send a text file to the printer (like /etc/group), by doing:

lpr -Ptext /etc/group

I hope you get the picture.


--Ariel

   +---------------------------------------------------------------+
   | Ariel Biener                                                  |
   | e-mail: ariel@post.tau.ac.il           Work phone: 03-6406086 |
   | fingerprint = 07 D1 E5 3E EF 6D E5 82 0B E9 21 D4 3C 7D 8B BC |
   +---------------------------------------------------------------+



text:\
       :lp=/dev/null:\
       :sd=/var/spool/lpd/text:\
       :mx#0:\
       :if=/usr/local/lib/filters/hpdjtext:\
       :lf=/var/spool/lpd/text/log:\
       :af=/var/spool/lpd/text/acct:\
       :sh:

ps:\
       :lp=/dev/null:\
       :sd=/var/spool/lpd/ps:\
       :mx#0:\
       :if=/usr/local/lib/filters/hpdjps:\
       :lf=/var/spool/lpd/ps/log:\
       :af=/var/spool/lpd/ps/acct:\
       :sh:
#!/bin/sh -f

#        file: /usr/lib/hpdjflt
#     version: 1.01
#          by: Johan Svensson, Josnet Internetworking AB
#              email: johan@jos.net
#   copyright: This is freeware!
#              You may distribute and modify this filter as long as
#              you don't make money on it and keep the copyright
#              notice within each filter.
#              Copyright (C) 1994-95 Josnet Internetworking AB, Sweden
#        date: 94-03-17
# last update: 95-08-21
# description: A HP DeskJet 510 in/out filter for BSD'ish lpr.
#              This must be the most complete text-filter!
#              Should work OK with most PCL-printers (even laser).
#       notes: I intend to refine this filter in the future, but who
#              knows...
#  disclaimer: The commands are taken from the Swedish version of
#              "HP DeskJet 510 - Printer for IBM PC and compatible
#              computers - Instruction Manual" and I can't guarantee
#              that everything works to a hundred percent and I don't
#              take the responsibility (neither does Josnet Internetworking AB)
#              if all your printers burn up...
#     support: You're on your own on this one! If you find anything inte-
#              resting or even bugs, you may contact the author.
#              
#              Good Luck!



# Sample /etc/printcap:
# ---------------------
# # Hp DeskJet 510
# hpdj|HP-DeskJet 510 on knuth:\
#	:lp=/dev/lp1:\
#	:sd=/usr/spool/hpdj:\
#	:mx=0:\
#	:of=/usr/lib/hpdjflt:\
#	:sh:\
#	:lf=/usr/adm/lpd-errs:

#################
# hpdjflt BEGIN #
#################

# Set up your minimal environment (your mileage may vary):
RM="/bin/rm"
CAT="/bin/cat"
SLEEP="/usr/bin/sleep"

# A suitable area to put temporary files at:
TMPAREA="/tmp"

# A suitable filename:
HPFILE=$TMPAREA/hpdjflt.$$

# redirect stdin to temporary file:
$CAT - > $HPFILE

# start by resetting the printer:
echo -ne '\033E'

# Edit the following for your needs!
# This file is more of a cookbook...



# ---------------
# PRINTER CONTROL
# ---------------
	# Reset printer:
	# echo -ne '\033E'

	# Function test:
	# echo -ne '\033z'



# ------------
# PAPER SOURCE
# ------------
	# Automatic sheet feeder:
	echo -ne '\033&l0H'

	# Manual sheet feeder:
	# echo -ne '\033&l1H'

	# Envelope feeder:
	# echo -ne '\033&l3H'



# ---------------
# PRINT DIRECTION
# ---------------
	# Left to right:
	# echo -ne '\033&k0W'

	# Bidirectional:
	echo -ne '\033&k1W'

	# Right to left:
	# echo -ne '\033&k2W'



# ---------
# UNDERLINE
# ---------
	# Single fixed:
	# echo -ne '\033&d1D'

	# Double fixed:
	# echo -ne '\033&d2D'

	# Single proportional:
	# echo -ne '\033&d3D'

	# Double proportional:
	# echo -ne '\033&d4D'

	# None:
	echo -ne '\033&d@'



# ----------------
# LINE TERMINATION
# ----------------
	# CR=>CR, LF=>LF, FF=>FF
	# echo -ne '\033&k0G'

	# CR=>CR+LF, LF=>LF, FF=>FF
	# echo -ne '\033&k1G'

	# CR=>CR, LF=>CR+LF, FF=>CR+FF
	echo -ne '\033&k2G'

	# CR=>CR+LF, LF=>CR+LF, FF=>CR+FF
	# echo -ne '\033&k3G'



# --------
# AUTOWRAP
# --------
	# Allow:
	echo -ne '\033&s0C'

	# Turn off:
	# echo -ne '\033s1C'



# ----------------
# OH PRINTOUT MODE
# ----------------
	# Number of bit-groups:
	# echo -ne '\033&p#X[data]



# -------------------
# WINDOWING FUNCTIONS
# -------------------
	# On:
	# echo -ne '\033Y'

	# Off:
	# echo -ne '\033Z'



# -------------------------
# EXTENDED PRINTING CONTROL
# -------------------------
	# Row-by-row on:
	echo -ne '\033&k0E'

	# Row-by-row off:
	# echo -ne '\033&k1F'



# ----------
# SHEET SIZE
# ----------
	# Standard:
	# echo -ne '\033&l0A'

	# US Letter:
	# echo -ne '\033&l2A'

	# US Legal:
	# echo -ne '\033&l3A'

	# US Executive:
	# echo -ne '\033&l1A'

	# A4:
	echo -ne '\033&l26A'

	# Nr.10 envelope:
	# echo -ne '\033&l-81A'

	# E65 (DL) envelope:
	# echo -ne '\033&l-90A'



# -----------
# ORIENTATION
# -----------
	# Portrait ("and-ell-zero-oh"):
	echo -ne '\033&l0O'

	# Landscape ("and-ell-one-oh"):
	# echo -ne '\033&l1O'



# ------------
# ROW DISTANCE
# ------------
	# Rows per inch:
	# echo -ne '\033&1#D'



# -----------
# PAGE LENGTH
# -----------
	# Number of rows:
	# echo -ne '\033&l#P'



# -----------
# PAGE BREAKS
# -----------
	# On:
	# echo -ne '\033&l1L'

	# Off:
	# echo -ne '\033&l0L'



# -----------
# HEAD MARGIN
# -----------
	# Number of rows:
	# echo -ne '\033&l#E'



# -----------
# TEXT LENGTH
# -----------
	# Number of rows:
	# echo -ne '\033&l#F'



# -------------------
# HORIZONTAL MARGINS:
# -------------------
	# Left margin:
	# echo -ne '\033&a#L'
	# 8 columns:
	echo -ne '\033&a8L'

	# Right margin:
	# echo -ne '\033&a#M'
	# 3 columns:
	echo -ne '\033&a3M'

	# Remove margins:
	# echo -ne '\0339'



# --------------------
# ROW DISTANCE CONTROL
# --------------------
	# On:
	# echo -ne '\033&k6W'

	# Off:
	# echo -ne '\033&k5W'



# ----------------
# CURSOR MOVEMENT:
# ----------------
	# Horizontal movement index (nr of 1/120 inch movements):
	# echo -ne '\033&k#H'

	# Move to column nr #:
	# echo -ne '\033&a#C'

	# Horizontal nr (tenths of a point):
	# echo -ne '\033&a#H'

	# Horizontal nr (points):
	# echo -ne '\033*p#X'

	# Vertical movement index (nr of 1/48 inch movements):
	# echo -ne '\033&l#C'

	# Move to row nr #:
	# echo -ne '\033&a#R'

	# Vertical nr (tenths of a point):
	# echo -ne '\033&a#V'

	# Vertical nr (points):
	# echo -ne '\033*p#Y'



# --------
# CHARSET:
# --------
	# PC-8:
	# echo -ne '\033(10U'

	# HP Roman8:
	# echo -ne '\033(8U'

	# PC-8 Danish/Norwegian:
	# echo -ne '\033(11U'

	# PC-850:
	# echo -ne '\033(12U'

	# ECMA-94 Latin 1:
	# echo -ne '\033(0N'

	# German (ISO 21):
	# echo -ne '\033(1G'

	# French (ISO 69):
	# echo -ne '\033(1F'

	# Italian (ISO 15):
	# echo -ne '\033(0I'

	# Spanish (ISO 17):
	# echo -ne '\033(2S'

	# Swedish Names (ISO 11):
	# echo -ne '\033(0S'

	# Swedish (ISO 10):
	# echo -ne '\033(3S'

	# Norwegian1 (ISO 60):
	# echo -ne '\033(0D'

	# Norwegian2 (ISO 61):
	# echo -ne '\033(1D'

	# Portugese (ISO 16):
	# echo -ne '\033(4S'

	# British (ISO 4):
	# echo -ne '\033(1E'

	# ANSI ASCII (ISO 6):
	echo -ne '\033(0U'

	# JIS ASCII:
	# echo -ne '\033(0K'

	# HP Legal:
	# echo -ne '\033(1U'

	# ISO IRV:
	# echo -ne '\033(2U'

	# Line Draw (optional):
	# echo -ne '\033(0L'

	# Math7 (optional):
	# echo -ne '\033(0M'

	# Math 8 (optional):
	# echo -ne '\033(8M'

	# Math8a (optional):
	# echo -ne '\033(0Q'

	# Math8b (optional):
	# echo -ne '\033(1Q'

	# PIFont (optional):
	# echo -ne '\033(15U'

	# PIFonta (optional):
	# echo -ne '\033(2Q'



# ------------------
# FIXED/PROPORTIONAL
# ------------------
	# Proportional:
	# echo -ne '\033(s1P'

	# Fixed:
	echo -ne '\033(s0P'



# -----
# PITCH
# -----
	# Characters per inch:
	# echo -ne '\033(s#H'

	# 8 cpi:
	# echo -ne '\033(s8H'

	# 10 cpi:
	 echo -ne '\033(s10H'

	# 12 cpi:
	#echo -ne '\033(s12H'

	# 14 cpi:
	# echo -ne '\033(s14H'

	# 16 cpi:
	# echo -ne '\033(s16H'



# -------------
# TYPEFACE SIZE
# -------------
	# Number of points:
	# echo -ne '\033(s#V'

	# 6p:
	# echo -ne '\033(s6V'

	# 8p:
	# echo -ne '\033(s8V'

	# 9p:
	# echo -ne '\033(s9V'

	# 10p:
	# echo -ne '\033(s10V'

	# 12p:
	# echo -ne '\033(s12V'

	# 14p:
	# echo -ne '\033(s14V'

	# 16p:
	# echo -ne '\033(s16V'

	# 18p:
	echo -ne '\033(s18V'

	# 20p:
	# echo -ne '\033(s20V'

	# 24p:
	# echo -ne '\033(s24V'

	# 32p:
	# echo -ne '\033(s32V'

	# 46p:
	# echo -ne '\033(s46V'

	# 64p:
	# echo -ne '\033(s64V'

	# 72p:
	# echo -ne '\033(s72V'



# ----------
# TEXT STYLE
# ----------
	# Antiqua:
	# echo -ne '\033(s0S'

	# Italic:
	# echo -ne '\033(s1S'



# -------
# DENSITY
# -------
	# Normal:
	echo -ne '\033(s0B'

	# Bold:
	# echo -ne '\033(s3B'

	# Extra bold (optional):
	# echo -ne '\033(s7B'



# ----
# FONT
# ----
	# Courier:
	#echo -ne '\033(s3T'

	# CG Times:
	# echo -ne '\033(s4101T'

	# Letter Gothic:
	# echo -ne '\033(s6T'

	# Univers:
	# echo -ne '\033(s52T'

	# Pica (optional):
	# echo -ne '\033(s1T'

	# Line Printer (optional):
	# echo -ne '\033(s0T'

	# Prestige (optional):
	# echo -ne '\033(s8T'

	# Elite (optional):
	# echo -ne '\033(s2T'

	# Script (optional):
	# echo -ne '\033(s7T'

	# Helvetica (optional):
	# echo -ne '\033(s4T'

	# Presentations (optional):
	# echo -ne '\033(s11T'

	# Times Roman (optional):
	 echo -ne '\033(s5T'

	# CG Century Schoolbook (optional):
	# echo -ne '\033(s23T'

	# Brush (optional):
	# echo -ne '\033(s32T'

	# Dom Casual (optional):
	# echo -ne '\033(s61T'

	# Univers Condensed (optional):
	# echo -ne '\033(s85T'

	# Garamond (optional):
	# echo -ne '\033(s101T'

	# CG Triumvirate (optional):
	# echo -ne '\033(s4T'



# -------------
# PRINT QUALITY
# -------------
	# Letter (fine):
	echo -ne '\033(s2Q'

	# Draft:
	# echo -ne '\033(s1Q'



# -------------
# FONT HANDLING
# -------------
	# Font ID nr:
	# echo -ne '\033*c#D'

	# ASCII code nr:
	# echo -ne '\033*c#E'

	# Erase all fonts:
	# echo -ne '\033*c0F'

	# Erase all temporary fonts:
	# echo -ne '\033*c1F'

	# Erase latest font:
	# echo -ne '\033*c2F'

	# Create a temporary font:
	# echo -ne '\033*c4F'

	# Create a permanent font:
	# echo -ne '\033*c5F'

	# Create a loadable font (bytes):
	# echo -ne '\033)s#W[data]'

	# Load character (bytes):
	# echo -ne '\033(s#W[data]'

	# Choose primary font ID:
	# echo -ne '\033(#X'

	# Choose secondary font ID:
	# echo -ne '\033)#X'



# -----------------------
# CHOICE OF PRIMARY FONTS
# -----------------------
	# Primary standard:
	# echo -ne '\033(#@'

	# Standard character set:
	# echo -ne '\033(0@'

	# Current primary character set:
	# echo -ne '\033(2@'

	# Standard font:
	# echo -ne '\033(3@'



# -------------------------
# CHOICE OF SECONDARY FONTS
# -------------------------
	# Secondary standard:
	# echo -ne '\033)#@'

	# Standard character set:
	# echo -ne '\033)0@'

	# Standard primary character set;
	# echo -ne '\033)1@'

	# Current primary character set:
	# echo -ne '\033)2@'

	# Standard secondary font:
	# echo -ne '\033)3@'



# ---------------------
# START BITMAP GRAPHICS
# ---------------------
	# Left margin:
	# echo -ne '\033*r0A'

	# Current cursor position:
	# echo -ne '\033*r1A'



# -------------------
# END BITMAP GRAPHICS
# -------------------
	# End graphics:
	# echo -ne '\033*rbC'



# ----------
# RESOLUTION
# ----------
	# 75 dots per inch:
	# echo -ne '\033*t75R'

	# 100 dots per inch:
	# echo -ne '\033*t100R'

	# 150 dots per inch:
	# echo -ne '\033*t150R'

	# 300 dots per inch:
	# echo -ne '\033*t300R'



# ----------------------------
# SET WIDTH OF BITMAP GRAPHICS
# ----------------------------
	# Number of bitmap columns:
	# echo -ne '\033*r#S'



# ---------------
# SET COMPRESSION
# ---------------
	# Method 0 (uncoded):
	# echo -ne '\033*b0M'

	# Method 1 (length coded):
	# echo -ne '\033*b1M'

	# Method 2 (TIFF):
	# echo -ne '\033*b2M'

	# Method 3 (Delta Row):
	# echo -ne '\033*b3M'

	# Method 9:
	# echo -ne '\033*b9M'

	# Seed Row Source:
	# echo -ne '\033*b#S'



# ------------------------
# TRANSFER BITMAP GRAPHICS
# ------------------------
	# Number of bitgroups (bytes):
	# echo -ne '\033*b#W[data]'

	# Transfer bitmap data with planes:
	# echo -ne '\033*b#V[data]'



# -----------------
# OFFSET IN HEIGHTH
# -----------------
	# Number of bitmap rows:
	# echo -ne '\033*b#Y'



# -------------------
# SET GRAPHIC QUALITY
# -------------------
	# Draft (Graphics):
	# echo -ne '\033*r1Q'

	# Letter (Graphics):
	# echo -ne '\033*r2Q'



# -----------------------------------
# SET NUMBER OF BITMAP PLANES PER ROW
# -----------------------------------
	# Foreground colour:
	# echo -ne '\033v#S'

	# One-plane palette:
	# echo -ne '\033*r1U'



# ------------------------
# ASSORTED BITMAP COMMANDS
# ------------------------
	# Bitmap Shingling:
	# echo -ne '\033*o#Q'

	# Bitmap Depletion:
	# echo -ne '\033*o#D'



# print out the temporary file:
$CAT $HPFILE

# end by resetting the printer:
echo -ne '\033E'

# give the system som time to process the data
# and remove the temp-file
# WARNING! This may corrupt the printout on some
#          systems - leave the rm for now and figure
#          out how you should deal with the temp-file.
$SLEEP 5
$RM $HPFILE

# END
#!/bin/sh -f
#

exec 9>&1 1>&2
device=cdeskjet

gsoutput="cat 1>&9"
gs -q -dNOPAUSE -sDEVICE=${device} \
-dBitsPerPixel=24 \
-dNOPLATFONTS \
-sPAPERSIZE=a4 \
-sOutputFile=\|"${gsoutput}" -