commit 78cf4b12d27611be06fb26563b7e73a40c4c2331 Author: Antonia Date: Fri Oct 21 18:07:23 2022 +0200 First commit diff --git a/fgfiller.sh b/fgfiller.sh new file mode 100644 index 0000000..c69da9c --- /dev/null +++ b/fgfiller.sh @@ -0,0 +1,89 @@ +#!/bin/bash + +## Copyright (C) 2022 Antonia + +## fills in personal data on forms generated by travelynx + + +tmpfile=$(mktemp --tmpdir XXXXX.fdf) + +cat - <>$tmpfile +%FDF-1.2 +1 0 obj<>" >> $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" + +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 - <>$tmpfile +] >> >> +endobj +trailer +<> +%%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 + + + + + diff --git a/fgfillerrc.sample b/fgfillerrc.sample new file mode 100644 index 0000000..59d48c7 --- /dev/null +++ b/fgfillerrc.sample @@ -0,0 +1,30 @@ +# Sample fgfillerrc file + +# Payment info + +# IBAN number. Leave blank if a coupon is desired instead of wire transfer +IBAN="" +# BIC +BIC="" +# Account holder, if separate from the claimant +ACCHOLDER="" + +# Personal data + +GENDER="" # Must be "Herr" or "Frau" +# Academic title (Optional) +TITLE="" +# Company name (Optional) +COMPANY="" +# First name of the claimant +FIRSTNAME="" +# Last name of the claimant +LASTNAME="" +# Address data of the claimant +STREET="" +HOUSENR="" +CO="" # c/o or similar (optonal) +COUNTRY="" # country code, leave empty if Germany +ZIP="" # Zip code +CARDNR="" # Bahncard 100 or monthly ticket number +DOB="" # Date of birth in case of Bahncard 100, Format DD MM YYYY separated by spaces