2013-09-06 17:05:03 +02:00
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
2013-09-06 17:29:49 +02:00
|
|
|
|
# Username
|
2013-09-06 17:05:03 +02:00
|
|
|
|
user="$2"
|
2013-09-06 17:29:49 +02:00
|
|
|
|
|
|
|
|
|
# Page title (not used at this time, "Document" instead)
|
2013-09-06 17:05:03 +02:00
|
|
|
|
ptitle="$3"
|
2013-09-06 17:29:49 +02:00
|
|
|
|
|
|
|
|
|
# Printing date
|
2013-09-06 17:05:03 +02:00
|
|
|
|
ddate="`LC_ALL=en_US.UTF-8 date '+%Y/%m/%d %H:%M:%S'`"
|
|
|
|
|
|
2013-09-06 17:29:49 +02:00
|
|
|
|
# Temporary directory
|
|
|
|
|
uid="/tmp/pstoricohddst-gdi-`uuidgen`"
|
2013-09-06 17:05:03 +02:00
|
|
|
|
mkdir -p $uid
|
|
|
|
|
|
2013-09-06 17:29:49 +02:00
|
|
|
|
# Converting from PostScript to PostScript-monochrome, then to PBM image format (per page)
|
2013-09-06 17:05:03 +02:00
|
|
|
|
gs -sDEVICE=psmono -sOutputFile=- -r600 -dQUIET -dBATCH -dNOPAUSE - | gs -sDEVICE=pbmraw -sOutputFile=${uid}/%d-page.pbm -r600 -dQUIET -dBATCH -dNOPAUSE -
|
|
|
|
|
|
2013-09-06 17:29:49 +02:00
|
|
|
|
# Flushing PJL header
|
2013-09-06 17:05:03 +02:00
|
|
|
|
cat <<EOF
|
|
|
|
|
%-12345X@PJL
|
|
|
|
|
@PJL SET TIMESTAMP=$ddate
|
|
|
|
|
@PJL SET FILENAME=Document
|
|
|
|
|
@PJL SET COMPRESS=JBIG
|
|
|
|
|
@PJL SET USERNAME=$user
|
|
|
|
|
@PJL SET COVER=OFF
|
|
|
|
|
@PJL SET HOLD=OFF
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
ls $uid/ | grep 'pbm$' | sort -n | while read page; do
|
|
|
|
|
|
2013-09-06 17:29:49 +02:00
|
|
|
|
# Converting page to JBIG format (parameters are very special for this printer!)
|
2013-09-06 17:05:03 +02:00
|
|
|
|
pbmtojbg -p 72 -o 3 -m 0 -q < $uid/$page > $uid/raster.jbig
|
2013-09-06 17:29:49 +02:00
|
|
|
|
|
|
|
|
|
# Taking image size
|
2013-09-06 17:05:03 +02:00
|
|
|
|
jsize=`wc -c < $uid/raster.jbig`
|
2013-09-06 17:29:49 +02:00
|
|
|
|
|
|
|
|
|
# Taking image dimensions
|
2013-09-06 17:05:03 +02:00
|
|
|
|
read fn ft xs ys garb < <(identify $uid/raster.jbig | tr "x" " ")
|
|
|
|
|
|
2013-09-06 17:29:49 +02:00
|
|
|
|
# Flushing page header
|
2013-09-06 17:05:03 +02:00
|
|
|
|
cat <<EOF
|
|
|
|
|
@PJL SET PAGESTATUS=START
|
|
|
|
|
@PJL SET COPIES=1
|
|
|
|
|
@PJL SET MEDIASOURCE=AUTO
|
|
|
|
|
@PJL SET MEDIATYPE=PLAINRECYCLE
|
|
|
|
|
@PJL SET PAPER=A4
|
|
|
|
|
@PJL SET PAPERWIDTH=$xs
|
|
|
|
|
@PJL SET PAPERLENGTH=$ys
|
|
|
|
|
@PJL SET RESOLUTION=600
|
|
|
|
|
@PJL SET IMAGELEN=$jsize
|
|
|
|
|
EOF
|
|
|
|
|
|
2013-09-06 17:29:49 +02:00
|
|
|
|
# Flushing image
|
2013-09-06 17:05:03 +02:00
|
|
|
|
cat $uid/raster.jbig
|
|
|
|
|
|
2013-09-06 17:29:49 +02:00
|
|
|
|
# Flushing page footer
|
|
|
|
|
# TODO: pixelcount for toner estimate
|
2013-09-06 17:05:03 +02:00
|
|
|
|
cat <<EOF
|
|
|
|
|
@PJL SET DOTCOUNT=1132782
|
|
|
|
|
@PJL SET PAGESTATUS=END
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
2013-09-06 17:29:49 +02:00
|
|
|
|
# Flushing PJL footer
|
2013-09-06 17:05:03 +02:00
|
|
|
|
cat <<EOF
|
|
|
|
|
@PJL EOJ
|
|
|
|
|
%-12345X
|
|
|
|
|
EOF
|
|
|
|
|
|
2013-09-06 17:29:49 +02:00
|
|
|
|
# Cleaning up
|
2013-09-06 17:24:11 +02:00
|
|
|
|
rm -rf $uid
|