📄 foo2hp2600-wrapper.in
字号:
#!/bin/sh#* Copyright (C) 2005-2006 Rick Richardson#*#* This program is free software; you can redistribute it and/or modify#* it under the terms of the GNU General Public License as published by#* the Free Software Foundation; either version 2 of the License, or#* (at your option) any later version.#*#* This program is distributed in the hope that it will be useful,#* but WITHOUT ANY WARRANTY; without even the implied warranty of#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the#* GNU General Public License for more details.#*#* You should have received a copy of the GNU General Public License#* along with this program; if not, write to the Free Software#* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.#*#* Authors: Rick Richardson <rick.richardson@comcast.net>VERSION='$Id: foo2hp2600-wrapper.in,v 1.54 2007/10/18 17:54:10 rick Exp $'## Printer Notes:## hp2600 -#PROGNAME="$0"BASENAME=`basename $PROGNAME`PREFIX=/usrSHARE=$PREFIX/share/foo2hpPATH=$PATH:/sw/bin:/opt/local/bin## Log the command line, for debugging and problem reports#if [ -x /usr/bin/logger ]; then logger -t "$BASENAME" -p lpr.info -- "$BASENAME $@" </dev/nullfiusage() { cat <<EOFUsage: $BASENAME [options] [ps-file] Foomatic printer wrapper for the foo2hp2600 printer driver. This script reads a Postscript ps-file or standard input and converts it to Zenographics ZjStream printer format.Normal Options:-b bits Bits per plane (1 or 2) [$BPP]-c Print in color (else monochrome)-d duplex Duplex code to send to printer [$DUPLEX] 1=off, 2=longedge, 3=shortedge-m media Media code to send to printer [$MEDIA] 1=standard, 2=transparency, 3=glossy, 257=envelope, 259=letterhead, 261=thickstock, 262=postcard, 263=labels-p paper Paper code [$PAPER] 1=letter, 5=legal, 7=executive, 9=A4, 11=A5, 13=B5 20=env#10, 27=envDL 28=envC5 34=envB5 37=envMonarch-n copies Number of copies [$COPIES]-r <xres>x<yres> Set device resolution in pixels/inch [$RES]-s source Source code to send to printer [$SOURCE] 1=tray2, 2=tray3, 4=manual/tray1, 7=auto Code numbers may vary with printer model.-t Draft mode. Every other pixel is white.-2/-3/-4/-6/-8/-10/-12/-14/-15/-16/-18 Print with N-up (requires psutils)-o orient For N-up: -op is portrait, -ol is landscape, -os is seascape.Printer Tweaking Options:-u <xoff>x<yoff> Set offset of upper left printable in pixels [varies]-l <xoff>x<yoff> Set offset of lower right printable in pixels [varies]-L mask Send logical clipping values from -u/-l in ZjStream [3] 0=no, 1=Y, 2=X, 3=XY-P Do not output START_PLANE codes. May be needed by some monochrome-only printers.-X padlen Add extra zero padding to the end of BID segments [16]Color Tweaking Options:-g gsopts Additional options to pass to Ghostscript, such as -dDITHERPPI=nnn, etc. May appear more than once. []-G profile.icm Convert profile.icm to a Postscript CRD using icc2ps and adjust colors using the setcolorrendering PS operator. $SHARE/icm/ will be searched for profile.icm.-I intent Select profile intent from ICM file [$INTENT] 0=Perceptual, 1=Colorimetric, 2=Saturation, 3=Absolute-G gamma-file.ps Prepend gamma-file to the Postscript input to perform color correction using the setcolortransfer PS operator.Debugging Options:-S plane Output just a single color plane from a color print [all] 1=Cyan, 2=Magenta, 3=Yellow, 4=Black-D lvl Set Debug level [$DEBUG]-V $VERSIONEOF exit 1}## Report an error and exit#error() { echo "$BASENAME: $1" >&2 exit 1}dbgcmd() { if [ $DEBUG -ge 1 ]; then echo "$@" >&2 fi "$@"}## Portable version of 'which'#pathfind() { if [ "$1" = -p ]; then optp=1 shift else optp=0 fi OLDIFS="$IFS" IFS=: for p in $PATH; do if [ -x "$p/$*" ]; then if [ $optp = 1 ]; then echo "$p/$*" fi IFS="$OLDIFS" return 0 fi done IFS="$OLDIFS" return 1}## Returns true if $1 is 32-bit binary#is32() { if pathfind file; then path=`pathfind -p "$*"` is32=`file -L "$path" | grep 32-bit` if [ "$is32" = "" ]; then return 1 else return 0 fi else return 1 fi}## N-up-ify the job. Requires psnup from psutils package#nup() { case "$NUP" in [2368]|1[0458]) tr '\r' '\n' | psnup $NUP_ORIENT -d2 -$NUP -m.3in -p$paper -q ;; [49]|1[26]) tr '\r' '\n' | psnup $NUP_ORIENT -d2 -$NUP -m.5in -p$paper -q ;; *) error "Illegal call to nup()." ;; esac}## Process the options## Try to use a local copy of GhostScript 8.54, if available. Otherwise,# fallback to whatever the Linux distro has installed (usually 7.07)## N.B. := operator used here, when :- would be better, because "ash"# doesn't have :-if gs.foo -v >/dev/null 2>&1; then GSBIN=${GSBIN:-gs.foo}else GSBIN=${GSBIN:-gs}fiCMDLINE="$*"DEBUG=0DUPLEX=1BPP=1COLOR=COLORMODE=defaultQUALITY=1QUALITY=wtsMEDIA=1COPIES=1PAPER=1RES=600x600SOURCE=7NUP=CLIP_UL=CLIP_LR=CLIP_LOG=BC=AIB=NOPLANES=COLOR2MONO=GAMMAFILE=defaultINTENT=0GSOPTS=EXTRAPAD=SAVETONER=NUP_ORIENT=GSDEV=-sDEVICE=pbmrawSEGFAULT=0# What mode to use if the user wants us to pick the "best" modecase `$GSBIN --version` in7*) DEFAULTCOLORMODE=10 ;;8.1*) # Buggy 8.14/8.15 in Ubuntu DEFAULTCOLORMODE=10 if is32 $GSBIN; then GAMMAFILE=km2430_2.icm else GAMMAFILE=hpclj2600n-0.icm SEGFAULT=1 fi QUALITY=1 ;;*) DEFAULTCOLORMODE=10 ;;esacwhile getopts "1:23456789o:b:cC:d:g:l:u:L:m:n:p:q:r:s:tABS:D:G:I:PX:Vh?" optdo case $opt in b) BPP="$OPTARG";; c) COLOR=-c;; d) DUPLEX="$OPTARG";; g) GSOPTS="$GSOPTS $OPTARG";; m) MEDIA="$OPTARG";; n) COPIES="$OPTARG";; p) PAPER="$OPTARG";; q) QUALITY="$OPTARG";; r) RES="$OPTARG";; s) SOURCE="$OPTARG";; t) SAVETONER="-t";; l) CLIP_LR="-l $OPTARG";; u) CLIP_UL="-u $OPTARG";; L) CLIP_LOG="-L $OPTARG";; A) AIB=-A;; B) BC=-B;; C) COLORMODE="$OPTARG";; S) COLOR2MONO="-S$OPTARG";; D) DEBUG="$OPTARG";; G) GAMMAFILE="$OPTARG";; I) INTENT="$OPTARG";; P) NOPLANES=-P;; X) EXTRAPAD="-X $OPTARG";; [234689]) NUP="$opt";; [57]) error "Can't find acceptable layout for $opt-up";; 1) case "$OPTARG" in [024568]) NUP="1$OPTARG";; *) error "Can't find acceptable layout for 1$OPTARG-up";; esac ;; o) case "$OPTARG" in l*) NUP_ORIENT=-l;; s*) NUP_ORIENT=-r;; p*|*) NUP_ORIENT=;; esac;; V) echo "$VERSION"; foo2hp -V; exit 0;; h|\?) if [ "$CMDLINE" != "-?" -a "$CMDLINE" != -h ]; then echo "Illegal command:" echo " $0 $CMDLINE" echo fi usage;; esacdoneshift `expr $OPTIND - 1`## If there is an argument left, take it as the file to print.# Else, the input comes from stdin.#if [ $# -ge 1 ]; then if [ "$LPJOB" = "" ]; then : # LPJOB="$1" fi exec < $1fi## Select the ghostscript device to use#case "$BPP" in1) if [ "" = "$COLOR" ]; then GSDEV=-sDEVICE=pbmraw else GSDEV=-sDEVICE=bitcmyk fi case "$GAMMAFILE" in default) if [ $SEGFAULT = 0 ]; then GAMMAFILE=hpclj2600n-1.icm else GAMMAFILE=hpclj2600n-0.icm fi ;; none) GAMMAFILE=;; esac ;;2) if [ "" = "$COLOR" ]; then # GSDEV=-sDEVICE=pgmraw # error "2-bpp monochrome is not yet supported" GSDEV="-sDEVICE=cups -dcupsColorSpace=3 -dcupsBitsPerColor=2" GSDEV="$GSDEV -dcupsColorOrder=2" else GSDEV="-sDEVICE=cups -dcupsColorSpace=6 -dcupsBitsPerColor=2" GSDEV="$GSDEV -dcupsColorOrder=2" fi if [ $GSBIN = "gs.foo" ]; then GSBIN=gs fi case "$GAMMAFILE" in default) if is32 $GSBIN; then GAMMAFILE=km2430_2.icm GAMMAFILE=hpclj2600n-1.icm else GAMMAFILE= fi ;; none) GAMMAFILE=;; esac ;;*) error "Illegal number of bits per plane ($BPP)";;esac#case "$QUALITY" in0) GSOPTS="-dCOLORSCREEN $GSOPTS" ;;1) GSOPTS="-dCOLORSCREEN $GSOPTS" ;;2) GSOPTS="-dMaxBitmap=500000000 $GSOPTS" ;;wts) GSOPTS="-dCOLORSCREEN -dMaxBitmap=500000000 $GSOPTS"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -