I’m creating a PDF using reportlab (in conjunction with Django). I have created the following code for creating a table with heads and details:
elements = []
datas = []
course_info = [
['Course Code' , c.course_code] ,
['Course Title' , c.course_name],
['Prerequisites by Course(s) and Topics', c.pre_reqs],
['Assessment Instruments with Weights (some desc)', c.grade_distribution]
]
for k in course_info:
headpara = Paragraph(k[0], styleB)
datas.append([headpara , Paragraph(clean_string(k[1]), styleN)])
t = LongTable(datas, colWidths=[5 * cm, 12 * cm])
t.setStyle(TableStyle(org.getTableStyle()))
elements.append(t)
doc.build(elements)
I’m using BaseDocTemplate as my template. What I want is to be able to give parts of the headpara as non-bold e.g. the (some desc) part in the fourth row need to be normal style instead of bold. How can I achieve this?
Reportlab supports simple HTML formatting so we can use
styleNand make the required text bold. Like so: