#!/bin/mksh
-# $MirOS: contrib/hosted/tg/ps2pdfmir,v 1.7 2010/07/31 23:11:15 tg Exp $
+# -*- mode: sh -*-
+# $MirOS: contrib/hosted/tg/ps2pdfmir,v 1.8 2015/04/22 18:13:30 tg Exp $
#-
-# Copyright (c) 2009, 2010
-# Thorsten Glaser <tg@mirbsd.org>
+# Copyright © 2009, 2010, 2015
+# Thorsten “mirabilos” Glaser <tg@mirbsd.org>
+# Copyright © 2014, 2015
+# Thorsten Glaser <thorsten.glaser@teckids.org>
#
# Provided that these terms and disclaimer and all copyright notices
# are retained or reproduced in an accompanying document, permission
-# is granted to deal in this work without restriction, including un-
+# is granted to deal in this work without restriction, including un‐
# limited rights to use, publicly perform, distribute, sell, modify,
# merge, give away, or sublicence.
#
-# This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to
+# This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
# the utmost extent permitted by applicable law, neither express nor
# implied; without malicious intent or gross negligence. In no event
# may a licensor, author or contributor be held liable for indirect,
# direct, other damage, loss, or other issues arising in any way out
# of dealing in the work, even if advised of the possibility of such
# damage or existence of a defect, except proven that it results out
-# of said person's immediate fault when using the work as intended.
+# of said person’s immediate fault when using the work as intended.
#-
-# Convert PostScript or PDF to PDF 1.3 (Acrobat 4-and-later compatible),
+# Convert PostScript or PDF to PDF 1.4 (Acrobat 5-and-later compatible),
# or, if the -a option is given, to something resembling PDF/A (PDF 1.4,
-# Acrobat 5-and-later compatible, ISO standardised).
+# ISO standardised; experimental). Use -V to specify a different version
+# (e.g. PDF 1.3, Acrobat 4-and-later compatible).
set -A args
function addargs {
- typeset _i
+ local _i
for _i in "$@"; do
args[${#args[*]}]=$_i
function usage {
print -u2 "Syntax:"
- print -ru2 " $0 [-a] [-p papersize] [-t title] infile [outfile]"
- print -ru2 " $0 [-a] [-p p.] [-t t.] -o outfile infile [...]"
- print -ru2 " $0 [-a] [-p p.] [-t t.] -c -o outfile pscommand [... -f infile ...]"
+ print -ru2 " $0 [-a] [-p papersize] [-t title] [-V 1.4] infile [outfile]"
+ print -ru2 " $0 [-a] [-p p.] [-t t.] [-V v.] -o outfile infile [...]"
+ print -ru2 " $0 [-a] [-ptV xxx] -c -o outfile pscommand [... -f infile ...]"
+ print -ru2 " PDF/A generation (-a) ignores PDF version (-V) and is beta"
exit 1
}
pdfa=0
+pdfv=1.4
icmd=0
outfile=
papersize=
overtitle=
-while getopts "aco:p:t:" c; do
+while getopts "aco:p:t:V:" c; do
case $c {
(a) pdfa=1 ;;
(c) icmd=1 ;;
(o) outfile=$OPTARG ;;
(p) papersize=$OPTARG ;;
(t) overtitle=$OPTARG ;;
+ (V) pdfv=$OPTARG ;;
(*) usage ;;
}
done
#XXX
if [[ $overtitle = *@(\(|\))* ]]; then
- print -u2 Cannot deal with parentheses in title.
+ print -u2 Cannot deal with parenthesēs in title.
exit 1
fi
(( pdfa )) && addargs -I"$r"
addargs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile="$outfile" \
- -dSAFER -dCompatibilityLevel=1.3 -dSubsetFonts=true -dEmbedAllFonts=true
+ -dSAFER -dSubsetFonts=true -dEmbedAllFonts=true
[[ -n $papersize ]] && addargs -sPAPERSIZE="$papersize"
if (( pdfa )); then
p=$r/sRGB_IEC61966-2-1_black_scaled.icc
d=$r/ps2pdfa.ps
if [[ ! -s $p || ! -s $d ]]; then
- print -u2 "Cannot find definition and profile files:"
- print -ru2 -- "- $d"
- print -ru2 -- "- $p"
+ print -u2 "Cannot find definition and/or profile files:"
+ print -ru2 -- "• $d"
+ print -ru2 -- "• $p"
exit 1
fi
addargs -dNOOUTERSAVE -dPDFA -sProcessColorModel=DeviceCMYK \
-c /ICCProfile "($p)" def -f "$d"
+else
+ addargs -dCompatibilityLevel="$pdfv"
fi
addargs -c .setpdfwrite