aboutsummaryrefslogtreecommitdiffstats
path: root/cli/pdf-embed-fonts.sh
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2017-11-03 18:45:20 +0800
committerAaron LI <aly@aaronly.me>2017-11-03 18:45:20 +0800
commit5a8b44ee3328464a673c2be2e21873fb02f1425b (patch)
tree192c3cc96018a26a85ec470aad1f814ea989a947 /cli/pdf-embed-fonts.sh
parent08aa61a60172326f4ea70834cd28817c0c397421 (diff)
downloadatoolbox-5a8b44ee3328464a673c2be2e21873fb02f1425b.tar.bz2
Add several more collected scripts
Diffstat (limited to 'cli/pdf-embed-fonts.sh')
-rwxr-xr-xcli/pdf-embed-fonts.sh37
1 files changed, 37 insertions, 0 deletions
diff --git a/cli/pdf-embed-fonts.sh b/cli/pdf-embed-fonts.sh
new file mode 100755
index 0000000..0f89f70
--- /dev/null
+++ b/cli/pdf-embed-fonts.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# Embed a PDF file with all fonts it uses, so it can be rendered and printed
+# correctly by every PDF reader on all types of OS.
+#
+#
+# Credits:
+# [1] The PDF viewer 'Evince' on Linux can not display some math symbols correctly
+# http://stackoverflow.com/a/10282269/4856091
+#
+#
+# Aaron LI
+# 2015-10-24
+#
+
+usage() {
+ echo "usage: `basename $0` <input.pdf> [ output_embedfonts.pdf ]"
+ exit 1
+}
+
+if [ $# -eq 0 ]; then
+ usage
+fi
+case "$1" in
+ -[hH]*)
+ usage
+ ;;
+esac
+
+INFILE="$1"
+OUTFILE="$2"
+
+[ -z "${OUTFILE}" ] && OUTFILE="${INFILE%.pdf}_embedfonts.pdf"
+
+# "-dPDFSETTINGS=/prepress" tells Ghostscript to embed all non-embedded fonts.
+gs -o "${OUTFILE}" -dPDFSETTINGS=/prepress -sDEVICE=pdfwrite "${INFILE}"
+