aboutsummaryrefslogtreecommitdiffstats
path: root/bin/make_pdf_derivatives.sh
blob: 76c9ebf806ce4597f7f5f107f7965fa9525fa886 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env bash

set -e -u -o pipefail

export FULLTEXTDIR=$1
export BLOBPATH=$2
export PDFPATH="$FULLTEXTDIR/pdf/$BLOBPATH.pdf"

if [[ ! -f $PDFPATH ]]; then
    echo "PDF does not exist: $PDFPATH"
    exit -1
fi

echo "processing: $PDFPATH"

if [[ ! -f "$FULLTEXTDIR/pdftotext/$BLOBPATH.txt" ]]; then
    pdftotext $PDFPATH $FULLTEXTDIR/pdftotext/$BLOBPATH.txt || true
fi

if [[ ! -f "$FULLTEXTDIR/thumbnail/$BLOBPATH.png" ]]; then
    pdftocairo -png -singlefile -scale-to-x 400 -scale-to-y -1 $PDFPATH $FULLTEXTDIR/thumbnail/$BLOBPATH || true
fi