From e85a35fbfd636e2c1e1fd805791018809749c69e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Fri, 22 Jan 2021 01:20:49 +0100 Subject: [PATCH] improved styling for pdf export --- courses/export_pdf.sh | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/courses/export_pdf.sh b/courses/export_pdf.sh index 7a9a9dd..3985b2c 100755 --- a/courses/export_pdf.sh +++ b/courses/export_pdf.sh @@ -64,12 +64,15 @@ get_dates() { while [ "$dts_date" -lt "$today" ]; do dts_date="$(date -d "${dts_date} + ${rec}" +%Y%m%d)"; done for n in 1 2 3 4 5 6 7 8 9 10; do - LANG=de_DE.UTF-8 date -d "$dts_date" +"%A, %d. %b." + LANG=de_DE.UTF-8 date -d "$dts_date" +"%d. %b." dts_date="$(date -d "${dts_date} + ${rec}" +%Y%m%d)" done } -"$_EXEC/cgilite/html-sh.sed" <<-EOF |sed -E 's;<(td|th)([^>]*)>;<\1 \2 style="border: 1pt solid\; padding: 1mm 2mm\;">;g' >"$htmlfile" +# some table styles need to be inline, because this is how libreoffice works +style_td='style="border: 1pt solid; padding: 1mm 2mm; vertical-align: top;"' + +"$_EXEC/cgilite/html-sh.sed" <<-EOF >"$htmlfile" [html [head [meta http-equiv="content-type" content="text/html; charset=utf-8"] @@ -86,10 +89,10 @@ get_dates() { th, td { text-align: left; } ] ][body lang="de_DE" - [table width="100%" + [table width="100%" style="page-break-after: always;" [col width=10*] [col width=5*] [col width=10*] [col width=15*] [thead - [tr [th . $(l10n N)] [th . $(l10n BDAY)] [th . $(l10n TEL)] [th . $(l10n NOTE)]] + [tr [th $style_td . $(l10n N)] [th $style_td . $(l10n BDAY)] [th $style_td . $(l10n TEL)] [th $style_td . $(l10n NOTE)]] ][tbody $(grep -F "${coursefile##*/} " "$_DATA/mappings/attendance" |while read discard each; do vcf="$(pdi_load "$_DATA/vcard/$each")" @@ -98,23 +101,24 @@ get_dates() { [ "$type" ] && type="$(l10n "TYPE=$type"):" printf '%s %s
' "$type" "$(pdi_value "$vcf" TEL $n)" done )" - printf '[tr [td .N . %s] [td .BDAY . %s] [td .TEL . %s] [td .NOTE . %s]]\n' \ - "$(pdi_value "$vcf" FN |unescape |HTML)" \ - "$(pdi_value "$vcf" BDAY |unescape |HTML)" \ - "$tel" \ - "$(pdi_value "$vcf" NOTE |unescape |HTML)" - done |sort -k4)] + printf '[tr valign=top [td %s .N . %s] [td %s .BDAY . %s] [td %s .TEL . %s] [td %s .NOTE . %s]]\n' \ + "$style_td" "$(pdi_value "$vcf" FN |unescape |HTML)" \ + "$style_td" "$(pdi_value "$vcf" BDAY |unescape |HTML)" \ + "$style_td" "$tel" \ + "$style_td" "$(pdi_value "$vcf" NOTE |unescape |HTML)" + done |sort)] ] - [table width="100%" style="page-break-before: always;" + [table width="100%" [col width=30*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [thead - [tr [th ] $(get_dates |xargs -d\\n printf '[th . %s]')] + [tr [th $style_td ] $(get_dates |xargs -d\\n printf "[th $style_td . %s]")] ][tbody $(grep -F "${coursefile##*/} " "$_DATA/mappings/attendance" |while read discard each; do vcf="$(pdi_load "$_DATA/vcard/$each")" - printf '[tr [td .N . %s] [td] [td] [td] [td] [td] [td] [td] [td] [td] [td]]\n' \ - "$(pdi_value "$vcf" FN |unescape |HTML)" - done |sort -k4)] + printf '[tr [td %s .N . %s] [td %s] [td %s] [td %s] [td %s] [td %s] [td %s] [td %s] [td %s] [td %s] [td %s]]\n' \ + "$style_td" "$(pdi_value "$vcf" FN |unescape |HTML)" \ + "$style_td" "$style_td" "$style_td" "$style_td" "$style_td" "$style_td" "$style_td" "$style_td" "$style_td" "$style_td" + done |sort)] ] ]] EOF -- 2.39.2