2016-11-04 10:30:11 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2017-08-30 11:56:37 +02:00
|
|
|
help() {
|
2016-11-04 10:30:11 +01:00
|
|
|
echo "usage: $0 [--colour] <file>"
|
|
|
|
echo
|
2017-08-30 11:56:37 +02:00
|
|
|
echo " -c | --colour print in colour"
|
|
|
|
echo " -r | --rasterize raster pdf before printing"
|
|
|
|
echo " file file (print-ready) to print or -"
|
2016-11-04 10:30:11 +01:00
|
|
|
echo
|
|
|
|
echo "print print-ready files with the UGent printers. Accepts only"
|
|
|
|
echo ".txt, .ps, .pdf, .pcl, .cht and .prn."
|
|
|
|
exit 1
|
2017-08-30 11:56:37 +02:00
|
|
|
}
|
2016-11-04 10:30:11 +01:00
|
|
|
|
2017-08-30 11:56:37 +02:00
|
|
|
if [ -z "$1" ]; then help; fi >&2
|
|
|
|
|
|
|
|
printer="print_mono"
|
|
|
|
format="tiffscaled8"
|
|
|
|
raster=""
|
|
|
|
while [ -n "$2" ]; do
|
|
|
|
case "$1" in
|
|
|
|
-c|--colour) printer="print_colour"
|
|
|
|
format="tiffscaled24"
|
|
|
|
;;
|
|
|
|
-r|--raster) raster="true"
|
|
|
|
;;
|
|
|
|
*) help
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
printfile="$1"
|
|
|
|
if test -n "$raster"; then
|
|
|
|
tiff="$(mktemp)"
|
|
|
|
printfile="$(mktemp)"
|
|
|
|
gs -sDEVICE="$format" -o "$tiff" "$1"
|
|
|
|
tiff2pdf -z -f -F -pA4 -o "$printfile" "$tiff"
|
|
|
|
rm "$tiff"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# pdf2ps -dLanguageLevel=1 input.pdf - | ps2pdf -sPAPERSIZE=a4 - output.pdf
|
|
|
|
|
|
|
|
print_colour() {
|
2017-09-18 10:25:05 +02:00
|
|
|
curl --silent --insecure \
|
2017-08-30 11:56:37 +02:00
|
|
|
-F "fileToPrint=@$1" \
|
|
|
|
-F "FormButtonSubmit=Print" \
|
|
|
|
'https://we02pr06.ugent.be/hp/device/Print/Print'
|
|
|
|
}
|
|
|
|
|
|
|
|
print_mono() {
|
2017-09-18 10:25:05 +02:00
|
|
|
curl --silent --insecure \
|
2017-08-30 11:56:37 +02:00
|
|
|
-F "localFile=@$1" \
|
|
|
|
'https://we02pr04.ugent.be/hp/device/this.printservice?printThis'
|
|
|
|
}
|
|
|
|
|
|
|
|
"$printer" "$printfile"
|
|
|
|
|
|
|
|
if test -n "$raster"; then rm "$printfile"; fi
|