diff options
author | InigoGutierrez <inigogf.95@gmail.com> | 2019-12-02 14:23:33 +0100 |
---|---|---|
committer | InigoGutierrez <inigogf.95@gmail.com> | 2019-12-02 14:23:33 +0100 |
commit | 58a9e65b5554b2c9552540dfea96b562375cf321 (patch) | |
tree | 118dbc0f74d7d09c328e5fbdecd118c7f3f23ee4 /pdfs | |
parent | 1ab2d661fb0ffa625d828792deabfb92a5c3611a (diff) | |
download | scripts-58a9e65b5554b2c9552540dfea96b562375cf321.tar.gz scripts-58a9e65b5554b2c9552540dfea96b562375cf321.zip |
Mon 02 Dec 2019 02:23:33 PM CET
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" & |