diff options
Diffstat (limited to 'pdfs')
-rwxr-xr-x | pdfs/asPDF.sh | 14 | ||||
-rwxr-xr-x | pdfs/pdfSxiv.sh | 30 | ||||
-rwxr-xr-x | pdfs/toPDF.sh | 25 |
3 files changed, 69 insertions, 0 deletions
diff --git a/pdfs/asPDF.sh b/pdfs/asPDF.sh new file mode 100755 index 0000000..a03f0aa --- /dev/null +++ b/pdfs/asPDF.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +outdir="/tmp/pdf" +name="${1%.*}" +ext="${1##*.}" +[ -d "$outdir" ] || mkdir -p "$outdir" + +case "$ext" in + "md") + pandoc -s -o "$outdir/$name.pdf" "$1" 1>/dev/null 2>&1 ;; + *) + lowriter --convert-to pdf --outdir "$outdir" "$1" 1>/dev/null 2>&1 ;; +esac +"$READER" "$outdir/$name.pdf" diff --git a/pdfs/pdfSxiv.sh b/pdfs/pdfSxiv.sh new file mode 100755 index 0000000..0a63586 --- /dev/null +++ b/pdfs/pdfSxiv.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# +# pdfSxiv.sh +# +# Usage: pdfSxiv.sh FILE +# +# Opens all images of a pdf with sxiv + +[ -z "$1" ] && exit 1 + +baseDir="/tmp/pdfSxiv" +directory="${1##*/}" +directory="${directory%%.*}" +fullPath="${baseDir}/001-${directory}" +if [ -d "$fullPath" ]; then + last="$(ls "${fullPath}/.." | sort | tail -n 1)" + last="${last%%-*}" + while echo "$last" | grep -E -q '^0'; do + last="${last#0}" + done + index="$((last+1))" + while ! echo "$index" | grep -E -q '.{3}'; do + index="0$index" + done + fullPath="${baseDir}/${index}-${directory}" +fi + +mkdir -p "$fullPath" +pdfimages -png "$1" "${fullPath}/pdfSxiv" +sxiv "${fullPath}"/* diff --git a/pdfs/toPDF.sh b/pdfs/toPDF.sh new file mode 100755 index 0000000..e4e6ece --- /dev/null +++ b/pdfs/toPDF.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# +# toPDF.sh +# +# Usage: toPDF.sh [-o] INPUTFILE +# +# Compiles a file to a temporal PDF using pandoc, updating the temporal file if +# it already exists. +# Opens the file with $READER if -o option is given. + +if [ "$1" = "-o" ]; then + open="1" + shift +fi + +[ -z "$1" ] && exit 1 + +targetDir="/tmp/toPDF" +sourceFile="$1" +targetFile="${targetDir}/${sourceFile##*/}" +targetFile="${targetFile%.*}.pdf" + +[ -d "$targetDir" ] || mkdir -p "$targetDir" +pandoc "$sourceFile" -o "$targetFile" +[ -n "$open" ] && "$READER" "$targetFile" & |