Skip to content

Commit f42c126

Browse files
author
NorNet Praesum Presum
committed
Improved PDF fonts embedder script.
1 parent acbd720 commit f42c126

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/pdfembedfonts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
22
#
33
# PDF Font Embedder
44
# Copyright (C) 2009-2025 by Thomas Dreibholz
@@ -19,6 +19,9 @@
1919
2020
#
2121

22+
# Bash options:
23+
set -eu
24+
2225
# ====== Get arguments ======================================================
2326
if [ $# -lt 2 ] ; then
2427
echo >&2 "Usage: $0 [Input PDF] [Output PDF] {-optimize}"
@@ -33,23 +36,18 @@ if [ "$3" = "-optimize" ] ; then
3336
OPTIMIZE=1
3437
fi
3538

36-
if [ ! -e "$INPUT_PDF" ] ; then
37-
echo >&2 "ERROR: PDF file $INPUT_PDF does not exist!"
39+
if [ ! -e "${INPUT_PDF}" ] ; then
40+
echo >&2 "ERROR: PDF file ${INPUT_PDF} does not exist!"
3841
exit 1
3942
fi
4043

4144

4245
# ====== 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
46+
47+
# ------ Using PDF/X --------------------------------------------------------
48+
if [ ${OPTIMIZE} -eq 1 ] ; then
49+
( ps2pdf -dPDFX "${INPUT_PDF}" "${OUTPUT_PDF}"-tmp.pdf && qpdf --linearize "${OUTPUT_PDF}"-tmp.pdf "${OUTPUT_PDF}" ) || cp "${INPUT_PDF}" "${OUTPUT_PDF}"
50+
rm -f "${OUTPUT_PDF}"-tmp.pdf
5351
else
54-
ps2pdf -dPDFX $1 $2
52+
ps2pdf -dPDFX "${INPUT_PDF}" "${OUTPUT_PDF}"
5553
fi

0 commit comments

Comments
 (0)