#!/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" write_field S2F12 "$CITY" 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