python - python FPDF如何加粗内联文本
问题描述
如何在写入文档时将内联字符串加粗。
我尝试了特殊字符\033,但它们似乎只适用于控制台打印而不是pdf输出,因为它们在pdf中显式打印为\033......还有其他方法可以将字符串格式化为粗体吗?
编辑:
我的意思是,我需要将非 ASCII 字符打印到文件中,我该如何完成它
解决方案
使用的字体必须包含加粗样式
请参阅鼓舞 Arial 和 Times 的示例,网址为
https://pyfpdf.readthedocs.io/en/latest/reference/set_font/index.html#example
# Times regular 12
pdf.set_font('Times')
# Arial bold 14
pdf.set_font('Arial', 'B', 14)
# Removes bold
pdf.set_font('')
# Times bold, italic and underlined 14
pdf.set_font('Times', 'BIU')
另请参阅https://pyfpdf.readthedocs.io/en/latest/reference/add_font/index.html和https://pyfpdf.readthedocs.io/en/latest/reference/set_font/index.html
推荐阅读
- json - 为 sagemaker 上的 tensorflow 服务模型提供输入时出错。{'error': "缺少 'inputs' 或 'instances' 键"}
- scala - Scala中的函数定义添加的无法识别的字段
- arrays - 如何使用 listbox.selecteditem 继续使用数组
- php - 使用不同的角色登录(根据用户类型重定向到不同的页面)
- bash - 在 sshd.conf 末尾添加一行
- sql - 在 SQL 表中查找双字节空格
- javascript - 点击包装加载问题
- r - 为什么即使我之前已经附加了数据框,我也不能在“for循环”中更改数据框的值?
- java - 尝试使用 Java 高级 REST 客户端查询 Long 类型时出现问题
- javascript - addEventListener 不适用于动态加载内容