-
Notifications
You must be signed in to change notification settings - Fork 0
/
stamp.sh
executable file
·69 lines (59 loc) · 1.28 KB
/
stamp.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
#Define some colors
RED='\033[0;31m'
NC='\033[0m'
#Default values
nameList=$1
pdfToStamp=$2
outputFolder="./StampedPdf"
usage()
{
echo "usage: stamp
[[-o|--output] <outputFolder>]
[[-l|--list] <names_list>]
[[-f|--file] <pdf_to_stamp>]
[-h|--help]"
}
# Separator to read the file.
IFS=' '
# Main
while [ ! -z "$1" ]; do
case $1 in
-o | --output)
shift
outputFolder="$1/StampedPdf"
;;
-l | --list)
shift
nameList=$1
if [ ! -f $nameList ]; then
echo -e "${RED}\n$nameList does not exist, exit${NC}"
exit
fi
;;
-f | --file)
shift
pdfToStamp=$1
if [ ! -f $pdfToStamp ]; then
echo -e "${RED}\n$pdfToStamp does not exist, exit${NC}"
exit
fi
;;
-h | --help)
usage
exit
esac
shift
done
# Create StampedPdf Directory if it does not exist.
if [ ! -d $outputFolder ]; then
echo "Creating $outputFolder ..."
eval $(mkdir -p $outputFolder)
fi
while read -r prenom nom
do
stamp="$prenom $nom"
fileName=$(basename "$pdfToStamp")
outputFilePath="$outputFolder/$prenom-$nom-$fileName"
eval $(echo $GOBIN/pdfcpu stamp -pages odd,even "'"$stamp, f:Courier, s:1, c: 0.75 0.75 0.75, r:45, o:0.5"'" $pdfToStamp $outputFilePath)
done < $nameList