Debian Codegraph @

src/pdfembedfonts

raw
1 #!/bin/sh
2 #
3 # PDF Font Embedder
4 # Copyright (C) 2009-2024 by Thomas Dreibholz
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #
19 # Contact: [email protected]
20 #
21
22 # ====== Get arguments ======================================================
23 if [ $# -lt 2 ] ; then
24 echo >&2 "Usage: $0 [Input PDF] [Output PDF] {-optimize}"
25 exit 1
26 fi
27
28 INPUT_PDF="$1"
29 OUTPUT_PDF="$2"
30
31 OPTIMIZE=0
32 if [ "$3" = "-optimize" ] ; then
33 OPTIMIZE=1
34 fi
35
36 if [ ! -e "$INPUT_PDF" ] ; then
37 echo >&2 "ERROR: PDF file $INPUT_PDF does not exist!"
38 exit 1
39 fi
40
41
42 # ====== Perform conversion =================================================
43 # ------ Using PDF -> PS -> PDF ---------------------------
44 # ( ps2pdf -dPDFSETTINGS=/prepress -dLanguageLevel=3 $1 - | \
45 # ps2pdf -dPDFSETTINGS=/prepress -dCompatibilityLevel=1.4 - $2-tmp.pdf && \
46 # qpdf --linearize $2-tmp.pdf $2 ) || cp $1 $2
47 # rm -f $2-tmp.pdf
48
49 # ------ Using PDF/X --------------------------------------
50 if [ $OPTIMIZE -eq 1 ] ; then
51 ( ps2pdf -dPDFX $1 $2-tmp.pdf && qpdf --linearize $2-tmp.pdf $2 ) || cp $1 $2
52 rm -f $2-tmp.pdf
53 else
54 ps2pdf -dPDFX $1 $2
55 fi