-
Notifications
You must be signed in to change notification settings - Fork 10
/
parsepdfs.sh
executable file
·30 lines (27 loc) · 986 Bytes
/
parsepdfs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh
# Usage: ./parsepdf.sh *.pdf
SCRIPTDIR=$(dirname $0)
# Download the binaries (if not yet existing)
VERSION=3.3.1
for lib in core javase; do
[ -e $SCRIPTDIR/zx-$lib.jar ] || wget https://repo1.maven.org/maven2/com/google/zxing/$lib/$VERSION/$lib-$VERSION.jar -O $SCRIPTDIR/zx-$lib.jar
done
[ -e $SCRIPTDIR/jcommander.jar ] || wget https://repo1.maven.org/maven2/com/beust/jcommander/1.72/jcommander-1.72.jar -O $SCRIPTDIR/jcommander.jar
for file in $@; do
echo "$file: image extraction"
pdfimages "$file" "$file"
echo "$file: image conversion"
for i in "$file"*.pbm "$file"*.ppm; do
convert "$i" "$i.png"
rm "$i"
done
echo "$file: barcode extraction"
for i in "$file"*.png; do
if file "$i" | grep -q 1-bit; then
java -cp $SCRIPTDIR/zx-core.jar:$SCRIPTDIR/zx-javase.jar:$SCRIPTDIR/jcommander.jar \
com.google.zxing.client.j2se.CommandLineRunner \
--pure_barcode --dump_results --brief ./$i
fi
rm "$i"
done
done