sync/mutt/.mutt/gen_html.sh
2019-04-14 17:37:15 -04:00

19 lines
843 B
Bash
Executable File

#!/bin/sh
set -ex
FILE="$1"
if [[ -z "$FILE" ]]; then
printf "No HTML file given" >&2
exit 1
fi
TMP_DIR="$(mktemp -d)"
# Force the name input.html since some attachments may have malformed extensions/no extension
cp "$FILE" "$TMP_DIR/input.html"
# docker container run -it --rm -v "$TMP_DIR:/usr/src/app" zenika/alpine-chrome --no-sandbox --screenshot --hide-scrollbars "file:///usr/src/app/input.html"
# Works but screenshot is usually too large
# docker container run -it --net none --rm -v "$TMP_DIR:/usr/src/app" zenika/alpine-chrome --no-sandbox --screenshot --window-size=1280,1696 --hide-scrollbars "file:///usr/src/app/input.html"
docker container run -it --net none --rm -v "$TMP_DIR:/usr/src/app" zenika/alpine-chrome --no-sandbox --print-to-pdf --hide-scrollbars "file:///usr/src/app/input.html"
xdg-open "$TMP_DIR/output.pdf"