I want to make my text Bold in add_text()
in python docx creation
this is the code sample
section = doc.sections[0] # Create a section
sec_header = section.header # Create header
header_tp = sec_header.add_paragraph() # Add a paragraph in the header, you can add any
header_run = header_tp.add_run() # Add a run in the paragraph. In the run you can set the
header_run.add_picture(logo_path, width=Inches(1.24), height=Inches(0.30)) # Add a picture
rml_header = "\t\t\t\t\t Project completion report"
header_run.add_text(rml_header).bold=True
header_run.add_text("\n_____________________________________________________________")
header_run.font.size = Pt(14)
In this code header_run.add_text(rml_header).bold=True
is not working is there any option to bold my text without changing function .add_text()
Try this instead:
header_run.add_text(rml_header)
header_run.bold = True