--- /dev/null
+#!/bin/bash
+
+# Convert EMF file (like from LTspice) to PDF file.
+# Leave the new file in the same directory if no second argument
+
+EMFNAME="$1"
+
+BASENAME=$(basename "$1" .emf)
+
+if [[ "$2" = "" ]]; then
+ OUTNAME="$BASENAME.pdf"
+else
+ OUTNAME="$2"
+fi
+
+PDFNAME="$BASENAME.pdf"
+CROPNAME="$BASENAME-crop.pdf"
+# template from:
+# https://stackoverflow.com/a/34676160
+
+
+# the directory of the script
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+# the temp directory used, within $DIR
+WORK_DIR=$(mktemp -d "$0.XXXXXXXX")
+
+# check if tmp dir was created
+if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
+ echo "Could not create temp dir" >&2
+ exit 1
+fi
+
+# deletes the temp directory
+function cleanup {
+ rm -rf "$WORK_DIR"
+ #echo "Deleted temp working directory $WORK_DIR"
+}
+
+function exiterr {
+ echo "Something went wrong... exiting." >&2
+ exit 1
+}
+
+
+# register the cleanup function to be called on the EXIT signal
+trap cleanup EXIT
+
+
+libreoffice --convert-to pdf --outdir "$WORK_DIR" $1 || exiterror
+
+pdfcrop "$WORK_DIR/$PDFNAME" "$WORK_DIR/$CROPNAME" || exiterror
+
+mv "$WORK_DIR/$CROPNAME" "$OUTNAME"
+
+echo "Output is: $OUTNAME"
--- /dev/null
+#!/bin/bash
+
+# Convert EMF file (like from LTspice) to PNG file.
+# Leave the new file in the same directory if no second argument
+
+EMFNAME="$1"
+
+BASENAME=$(basename "$1" .emf)
+
+if [[ "$2" = "" ]]; then
+ PNGNAME="$BASENAME.png"
+else
+ PNGNAME="$2"
+fi
+
+PDFNAME="$BASENAME.pdf"
+CROPNAME="$BASENAME-crop.pdf"
+# template from:
+# https://stackoverflow.com/a/34676160
+
+
+# the directory of the script
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+# the temp directory used, within $DIR
+WORK_DIR=$(mktemp -d "$0.XXXXXXXX")
+
+# check if tmp dir was created
+if [[ ! "$WORK_DIR" || ! -d "$WORK_DIR" ]]; then
+ echo "Could not create temp dir" >&2
+ exit 1
+fi
+
+# deletes the temp directory
+function cleanup {
+ rm -rf "$WORK_DIR"
+ #echo "Deleted temp working directory $WORK_DIR"
+}
+
+function exiterr {
+ echo "Something went wrong... exiting." >&2
+ exit 1
+}
+
+
+# register the cleanup function to be called on the EXIT signal
+trap cleanup EXIT
+
+
+libreoffice --convert-to pdf --outdir "$WORK_DIR" $1 || exiterror
+
+pdfcrop "$WORK_DIR/$PDFNAME" "$WORK_DIR/$CROPNAME" || exiterror
+
+convert -density 300 "$WORK_DIR/$CROPNAME" "$PNGNAME" || exiterror
+
+echo "Output is: $PNGNAME"