You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Odoo报表默认字体致wkhtmltopdf加粗异常问题求助

问题原因分析
  • 字体嵌入不完整:Odoo默认的Lato字体在wkhtmltopdf渲染时,未正确嵌入完整的字重变体(常规、加粗等)。当遇到<strong>标签触发加粗需求时,因找不到对应的Lato-Bold字体文件,wkhtmltopdf会强制将整页文本转为加粗样式,而非仅应用到局部。
  • 字体规则缺失:Odoo原生报表样式里,未明确为Lato字体声明不同字重的@font-face规则,导致wkhtmltopdf无法区分常规与加粗字重,触发全局加粗的渲染bug。
解决方案

方案1:补全Lato字体的字重定义

在自定义报表的CSS中添加完整的字体声明,确保wkhtmltopdf能识别不同字重的Lato字体:

@font-face {
    font-family: 'Lato';
    src: url('/web/static/lib/lato/Lato-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}
@font-face {
    font-family: 'Lato';
    src: url('/web/static/lib/lato/Lato-Bold.ttf') format('truetype');
    font-weight: bold;
    font-style: normal;
}

body {
    font-family: 'Lato', sans-serif;
}
strong {
    font-weight: bold;
}

方案2:替换为系统标准字体

若不想处理字体嵌入问题,直接在报表CSS中指定服务器已安装的标准字体(如Arial),这类字体的字重识别兼容性更好:

body {
    font-family: Arial, sans-serif;
}

方案3:升级wkhtmltopdf版本

部分旧版wkhtmltopdf存在自定义字体字重的渲染bug,升级到0.12.6及以上的稳定版本,可修复此类兼容性问题。

内容的提问来源于stack exchange,提问作者chrineuh

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.04 05:32:34