~carloabelli/bin

bin/pages2pdf -rwxr-xr-x 339 bytes
2c82710aCarlo Abelli Add license 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh

while getopts "o:" opt; do
    case $opt in
        o)
            out="$OPTARG"
    esac
done
shift $((OPTIND-1))

if [ "$#" -ne 1 ]; then
    echo "usage: $0 [-o file] file"
    exit 1
fi

in="$1"
[ -z "$out" ] && out="$in.pdf"

dir="$(mktemp -d)"
unzip "$in" -d "$dir" && mv "$dir/QuickLook/Preview.pdf" "$out"
rm -rf "$dir"