首页 文章

Odoo 9自定义qweb报告,css无法正常工作

提问于
浏览
0

我正在创建一个关于Odoo 9的新报告,它使用css样式来在背景图像上定位文本 . 图像位于背景中,占据整个A4页面,没有任何边距 .

在HTML中,它工作正常 . 但是,当我将报表打印为PDF时,我左右边距为空白,文本低于背景图像 . 似乎没有应用CSS规则 . 您是否找到了使其以PDF格式运行的解决方案?

这是我的报告:

<template id="sub_proposal">
<style type="text/css">
    .container {
        padding: 0mm;
    }
    #sponsor-ref {
        position: absolute;
        top: 84mm;
        left: 45mm;
    }
    #form_image {
        position: absolute;
        top: 0mm;
        left: 0mm;
        width: 210mm;
        height: 297mm;
    }
    #form_image img {
        max-width: 100%;
        max-height: 100%;
        margin: auto;
    }
</style>
<t t-call="report.html_container">
    <t t-foreach="docs" t-as="o">
        <div class="page">
            <div id="form_image">
                <span t-field="o.sub_proposal_form" t-field-options='{"widget": "image"}'/>
            </div>
            <span id="sponsor-ref" t-field="o.ref"/>
        </div>
    </t>
</t>

2 回答

  • 0

    必须在 <div class="page"> 元素中设置 style 标记和内容 .

    我没有任何文件,只有经验 .

    在Odoo论坛上链接到同一个问题

  • 0

    这将在pdf上打印带有文本的图像

    <template id="account_report_id" inherit_id="account.report_invoice_document">
        <p t-if="o.fiscal_position_id.note" position="after">

    <img t-if="o.partner_id.image" t-att-src="'data:image/png;base64,%s' % o.partner_id.image" style="float:right;max-height:40px;"/>

    <span style="float: right;">Customer Sign</span> </p> </template>

相关问题