2022-10-21 16:07:23 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
## Copyright (C) 2022 Antonia <antonia@antonia.is>
|
|
|
|
|
|
|
|
## fills in personal data on forms generated by travelynx
|
|
|
|
|
|
|
|
|
|
|
|
tmpfile=$(mktemp --tmpdir XXXXX.fdf)
|
|
|
|
|
|
|
|
cat - <<EOF >>$tmpfile
|
|
|
|
%FDF-1.2
|
|
|
|
1 0 obj<</FDF<< /Fields[
|
|
|
|
EOF
|
|
|
|
|
|
|
|
function write_field() {
|
|
|
|
echo "<< /T ($1) /V ($2) >>" >> $tmpfile
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
source ~/.fgfillerrc
|
|
|
|
|
|
|
|
if [ -n "$IBAN" ]; then
|
|
|
|
write_field S1F29 "Auszahlung oder Überweisung"
|
|
|
|
if [ -z "$ACCHOLDER" ]; then
|
|
|
|
ACCHOLDER="$FIRSTNAME $LASTNAME"
|
|
|
|
fi
|
|
|
|
write_field S2F20 "$ACCHOLDER"
|
|
|
|
write_field S2F21 "$IBAN"
|
|
|
|
write_field S2F22 "$BIC"
|
|
|
|
else
|
|
|
|
write_field S1F29 "Gutschein"
|
|
|
|
fi
|
|
|
|
|
|
|
|
write_field S2F1 "$GENDER"
|
|
|
|
[ -n "$TITLE" ] && write_field S2F2 "$TITLE"
|
|
|
|
[ -n "$COMPANY" ] && write_field S2F3 "$COMPANY"
|
|
|
|
write_field S2F4 "$LASTNAME"
|
|
|
|
write_field S2F5 "$FIRSTNAME"
|
|
|
|
[ -n "$CO" ] && write_field S2F6 "$CO"
|
|
|
|
[ -n "$PHONENR" ] && write_field S2F7 "$PHONENR"
|
|
|
|
write_field S2F8 "$STREET"
|
|
|
|
write_field S2F9 "$HOUSENR"
|
|
|
|
[ -n "$COUNTRY" ] && write_field S2F10 "$COUNTRY"
|
|
|
|
write_field S2F11 "$ZIP"
|
2024-09-05 18:49:13 +00:00
|
|
|
write_field S2F12 "$CITY"
|
2022-10-21 16:07:23 +00:00
|
|
|
|
|
|
|
if [ -n "$CARDNR" ]; then
|
|
|
|
write_field S2F15 "$CARDNR"
|
|
|
|
if [ -n "$DOB" ]; then
|
|
|
|
write_field S2F13 "BahnCard 100-Nr."
|
|
|
|
k=0
|
|
|
|
for i in $DOB ; do
|
|
|
|
write_field S2F$((k+16)) $i
|
|
|
|
k=$((k+1))
|
|
|
|
done
|
|
|
|
else
|
|
|
|
write_field S2F14 "Zeitkarten-Nr."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cat - <<EOF>>$tmpfile
|
|
|
|
] >> >>
|
|
|
|
endobj
|
|
|
|
trailer
|
|
|
|
<</Root 1 0 R>>
|
|
|
|
%%EOF
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
|
|
mkdir -p output
|
|
|
|
|
|
|
|
for k in "$@"; do
|
|
|
|
outfile="output/$(basename "$k")"
|
|
|
|
tmp=$(mktemp --tmpdir XXXXX.pdf)
|
|
|
|
sed "s/Auszahlung#20oder#20#dcberweisung/Auszahlung#20oder#20#c3Sberweisung/g" "$k" > "$tmp" # solve pdftk bug
|
|
|
|
pdftk "$tmp" fill_form $tmpfile output "$outfile"
|
|
|
|
rm $tmp
|
|
|
|
done
|
|
|
|
|
|
|
|
rm $tmpfile
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|