1 |
#! /bin/sh |
2 |
|
3 |
#================================================================ |
4 |
# extfxpdftohtml |
5 |
# Convert PDF into HTML |
6 |
#================================================================ |
7 |
|
8 |
|
9 |
# set variables |
10 |
PATH="$PATH:/usr/local/bin:$HOME/bin:." ; export PATH |
11 |
progname="estfxpdftohtml" |
12 |
|
13 |
|
14 |
# check arguments |
15 |
if [ $# -lt 1 ] |
16 |
then |
17 |
printf '%s: usage: %s infile [outfile]\n' "$progname" "$progname" 1>&2 |
18 |
exit 1 |
19 |
fi |
20 |
infile="$1" |
21 |
outfile="$2" |
22 |
if [ -n "$ESTORIGFILE" ] && [ -f "$ESTORIGFILE" ] |
23 |
then |
24 |
infile="$ESTORIGFILE" |
25 |
fi |
26 |
|
27 |
|
28 |
# check the input |
29 |
if [ "!" -f "$infile" ] |
30 |
then |
31 |
printf '%s: %s: no such file\n' "$progname" "$infile" 1>&2 |
32 |
exit 1 |
33 |
fi |
34 |
|
35 |
|
36 |
# initialize the output file |
37 |
if [ -n "$outfile" ] |
38 |
then |
39 |
rm -f "$outfile" |
40 |
fi |
41 |
|
42 |
|
43 |
# function to output |
44 |
output(){ |
45 |
if [ -n "$outfile" ] |
46 |
then |
47 |
cat >> "$outfile" |
48 |
else |
49 |
cat |
50 |
fi |
51 |
} |
52 |
|
53 |
|
54 |
# output the result |
55 |
pdftotext -enc UTF-8 -htmlmeta "$infile" - 2> "/dev/null" | output |
56 |
|
57 |
|
58 |
# exit normally |
59 |
exit 0 |
60 |
|
61 |
|
62 |
|
63 |
# END OF FILE |