Created
April 18, 2023 17:35
-
-
Save baszoetekouw/f63a4a51143b9617eecc55758323391b to your computer and use it in GitHub Desktop.
pdf2pdf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# $Id: ps2pdfwr,v 1.9 2002/02/21 21:49:28 giles Exp $ | |
# Convert PostScript to PDF without specifying CompatibilityLevel. | |
OPTIONS="" | |
QUALITY="ebook" | |
while true | |
do | |
case "$1" in | |
-q*) | |
# see https://www.ghostscript.com/doc/current/VectorDevices.htm#PDFWRITE | |
q=$1 | |
if [ "x$q" = 'x-qscreen' -o "x$q" = 'x-q1' ]; then | |
QUALITY="screen" | |
# these are not on by default for low quality; wont increase file size, but will increasy quality | |
OPTIONS="-dColorImageDownsampleType=/Bicubic $OPTOINS" | |
OPTIONS="-dGrayImageDownsampleType=/Bicubic $OPTOINS" | |
elif [ "x$q" = 'x-qebook' -o "x$q" = 'x-q2' ]; then | |
# these are not on by default for low quality; wont increase file size, but will increasy quality | |
QUALITY="ebook" | |
OPTIONS="-dColorImageDownsampleType=/Bicubic $OPTOINS" | |
elif [ "x$q" = 'x-qprinter' -o "x$q" = 'x-q3' ]; then | |
# these are not on by default for low quality; wont increase file size, but will increasy quality | |
QUALITY="printer" | |
elif [ "x$q" = 'x-qprepress' -o "x$q" = 'x-q4' ]; then | |
QUALITY="prepress" | |
else | |
echo "Invalid value for -q (quality). Allowed values are:" 1>&2 | |
echo " 1 or screen : 72dpi, lowest quality" 1>&2 | |
echo " 2 or ebook : 150dpi, medium quality" 1>&2 | |
echo " 3 or printer : 300dpi, high quality" 1>&2 | |
echo " 4 or prepress : 300dpi, very high quality" 1>&2 | |
exit 1 | |
fi | |
;; | |
-?*) OPTIONS="$OPTIONS $1" ;; | |
*) break ;; | |
esac | |
shift | |
done | |
OPTIONS="-dPDFSETTINGS=/$QUALITY $OPTIONS" | |
if [ $# -lt 1 -o $# -gt 2 ]; then | |
echo "Usage: `basename $0` [-q{book|ebook|printer|prepress}] [options...] <input.{ps,eps,pdf}> {output.pdf|-}" 1>&2 | |
exit 1 | |
fi | |
infile="$1"; | |
if [ $# -eq 1 ] | |
then | |
outfile=- | |
else | |
outfile="$2" | |
fi | |
# We have to include the options twice because -I only takes effect if it | |
# appears before other options. | |
#exec gs $OPTIONS -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite "-sOutputFile=$outfile" $OPTIONS -c .setpdfwrite -f "$infile" | |
#exec gs $OPTIONS -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite "-sOutputFile=$outfile" $OPTIONS -c .setpdfwrite -f "$infile" | |
exec gs $OPTIONS -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dSAFER "-sOutputFile=$outfile" "$infile" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment