跳至内容
菜单
此问题已终结
1 回复
190 查看

I'm facing an issue with font consistency in a custom QWeb PDF report for the Purchase Order. The report uses the Myriad Pro font, which is defined via inline styles in the XML.

The problem is that the PDF output is different between my local development machine and the production server.

  1. Local Machine: Renders correctly (appears to be Myriad Pro).
  2. Server: Renders with a different font (it looks compressed/narrower), indicating a font fallback.

Both servers are running the same Odoo version (Odoo 15) and have the same version of wkhtmltopdf installed.

I suspect the font is missing on the production server.


The report template inherits the standard layout like this:

XML

<template id="custom_purchase_report_sparemate" inherit_id="purchase.report_purchaseorder_document">
    <xpath expr="//t[@t-call='web.external_layout']" position="replace">
        <t t-set="o" t-value="o.with_context(lang=o.partner_id.lang)"/>
        <t t-call="sparemate_custom_invoice.purchase_layout_sparemate">
            </t>
    </xpath>
</template>

Any guidance on the most robust solution

形象
丢弃
最佳答案

Hi,


The issue you are facing is caused by the Myriad Pro font not being available on the production server. While your local machine has the font installed, the server does not, so wkhtmltopdf falls back to a default font, which looks narrower or compressed. This explains the inconsistency in how the PDF renders between environments.


To resolve this, the most robust approach is to embed the font inside your custom module. You can place the .ttf or .otf files under static/src/fonts/ and load them with a @font-face declaration in your CSS. This guarantees consistent rendering across all environments, regardless of the server’s configuration.


An alternative is to install the font directly on the production server by copying it into the system fonts directory and updating the font cache. While this can work, it is less portable and depends on the server setup. If licensing is an issue with Myriad Pro, you may also consider using free alternatives like Source Sans Pro or Open Sans, which can be easily embedded and are visually close.


Overall, the best practice for Odoo custom reports is to embed fonts in the module itself rather than relying on system-installed fonts. This ensures consistency between development, staging, and production environments and avoids font fallback issues.


Hope it helps

形象
丢弃
相关帖文 回复 查看 活动
1
6月 24
2956
0
10月 18
4947
2
12月 19
11140
0
8月 24
1543
0
11月 19
4170