allows Paragraph in table cells for pdf, and specific cell values for pdf

This commit is contained in:
Emmanuel Viennet 2022-03-09 13:59:40 +01:00
parent a4035411d9
commit d2fe27b67c

View File

@ -233,7 +233,10 @@ class GenTable(object):
colspan_count -= 1 colspan_count -= 1
# if colspan_count > 0: # if colspan_count > 0:
# continue # skip cells after a span # continue # skip cells after a span
content = row.get(cid, "") or "" # nota: None converted to '' if pdf_mode:
content = row.get(f"_{cid}_pdf", "") or row.get(cid, "") or ""
else:
content = row.get(cid, "") or "" # nota: None converted to ''
colspan = row.get("_%s_colspan" % cid, 0) colspan = row.get("_%s_colspan" % cid, 0)
if colspan > 1: if colspan > 1:
pdf_style_list.append( pdf_style_list.append(
@ -547,9 +550,16 @@ class GenTable(object):
omit_hidden_lines=True, omit_hidden_lines=True,
) )
try: try:
Pt = [ Pt = []
[Paragraph(SU(str(x)), CellStyle) for x in line] for line in data_list for line in data_list:
] Pt.append(
[
Paragraph(SU(str(x)), CellStyle)
if (not isinstance(x, Paragraph))
else x
for x in line
]
)
except ValueError as exc: except ValueError as exc:
raise ScoPDFFormatError(str(exc)) from exc raise ScoPDFFormatError(str(exc)) from exc
pdf_style_list += self.pdf_table_style pdf_style_list += self.pdf_table_style