]> git.plutz.net Git - confetti/commitdiff
improved styling for pdf export
authorPaul Hänsch <paul@plutz.net>
Fri, 22 Jan 2021 00:20:49 +0000 (01:20 +0100)
committerPaul Hänsch <paul@plutz.net>
Fri, 22 Jan 2021 00:20:49 +0000 (01:20 +0100)
courses/export_pdf.sh

index 7a9a9dd17ee49e876d40cfc7cd62ddad06d7b8ef..3985b2c878babd32673a00883cc944f999716cdf 100755 (executable)
@@ -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
 
   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
 }
 
     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"
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 [html [head
   [meta http-equiv="content-type" content="text/html; charset=utf-8"]
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 [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"
     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
     [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")"
     ][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<br>' "$type" "$(pdi_value "$vcf" TEL $n)"
                 done  )"
                   [ "$type" ] && type="$(l10n "TYPE=$type"):"
                   printf '%s %s<br>' "$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
     [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")"
     ][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
   ]
 ]]
 EOF