📄 foo2qpdl-wrapper.in
字号:
#!/bin/sh#* Copyright (C) 2003-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: foo2qpdl-wrapper.in,v 1.20 2007/10/18 13:52:07 rick Exp $'## Printer Notes:## Samsung CLP-300: ICM# Samsung CLP-600: CRD, need ICM for black text# Samsung CLX-3160: ICM# Xerox Phaser 6110: ICM#PROGNAME="$0"BASENAME=`basename $PROGNAME`PREFIX=/usrSHARE=$PREFIX/share/foo2qpdlPATH=$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 foo2qpdl printer driver. This script reads a Postscript ps-file or standard input and converts it to a Samsung QPDL stream (CLP-600).Normal Options:-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] 0=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=upper, 2=lower, 4=manual, 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]-z model Model: 0=CLP-300 1=CLP-600Color 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 "$@"}## 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=1COLOR=COLORMODE=defaultMODEL=0QUALITY=1QUALITY=wtsMEDIA=0COPIES=1PAPER=0RES=1200x600SOURCE=1NUP=CLIP_UL=CLIP_LR=CLIP_LOG=BC=AIB=NOPLANES=COLOR2MONO=GAMMAFILE=defaultINTENT=0GSOPTS=EXTRAPAD=SAVETONER=NUP_ORIENT=GSDEV=-sDEVICE=pbmraw# What mode to use if the user wants us to pick the "best" modecase `$GSBIN --version` in7*) DEFAULTCOLORMODE=10 DEFAULTCOLORMODE=1 ;;8.1*) DEFAULTCOLORMODE=1 QUALITY=1 ;;*) DEFAULTCOLORMODE=1 ;;esacwhile getopts "1:23456789o:b:cC:d:g:l:u:L:m:n:p:q:r:s:tz:ABS:D:G:I:PX:Vh?" optdo case $opt in b) GSBIN="$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";; z) MODEL="$OPTARG";; 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"; foo2qpdl -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#case "$QUALITY" in0) GSOPTS="-dCOLORSCREEN $GSOPTS" ;;1) GSOPTS="-dCOLORSCREEN $GSOPTS" ;;2) GSOPTS="-dMaxBitmap=500000000 $GSOPTS" ;;wts) GSOPTS="-dCOLORSCREEN -dMaxBitmap=500000000 $GSOPTS" ;;esac## Validate model code#case "$MODEL" in0|1) ;;*) error "Unknown model code $MODEL";;esac## Validate media code#case "$MEDIA" in0|plain) MEDIA=0;;1|thick) MEDIA=1;;2|thin) MEDIA=2;;3|bond) MEDIA=3;;4|color) MEDIA=4;;5|card) MEDIA=5;;6|labels) MEDIA=6;;7|envelope) MEDIA=7;;8|preprinted) MEDIA=8;;9|cotton) MEDIA=9;;10|recycled) MEDIA=10;;[0-9]*) ;;*) error "Unknown media code $MEDIA";;esac## Validate source (InputSlot) code#case "$SOURCE" in1|auto) SOURCE=1;;2|manual) SOURCE=2;;3|multi) SOURCE=3;;4|tray1) SOURCE=4;;[0-9]*) ;;*) error "Unknown source code $SOURCE";;esac## Validate Duplex code#case "$DUPLEX" in1|off|none) DUPLEX=1;;2|long*) DUPLEX=2;;3|short*) DUPLEX=3;;[0-9]*) ;;*) error "Unknown duplex code $DUPLEX";;esac## Validate Resolution#case "$RES" in600x600) ;;1200x600) ;;1200x1200) ;;*) error "Illegal resolution $RES";;esac#
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -