为什么我的带有CSS的Odoo 9自定义Qweb报告无法正常工作? [英] Why does my Odoo 9 custom Qweb report with CSS is not working?

查看:121
本文介绍了为什么我的带有CSS的Odoo 9自定义Qweb报告无法正常工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Odoo 9上创建一个新报告,该报告使用css样式以便将文本放置在背景图像上.图片在背景中,占据了整个A4页面,没有任何边距.

I'm creating a new report on Odoo 9 which uses css styles in order to position text over a background image. The image is in background and occupies the full A4 page without any margins.

在html中,它工作正常.但是,当我将报告打印为PDF时,左右两边有空白,并且文本位于背景图像下方.似乎没有应用CSS规则.您找到使它在PDF中运行的任何解决方案吗?

In html, it's working fine. However, when I print the report to PDF, I have blank margins at left and right, and the text goes below the background image. It seems that the CSS rules are not applied. Do you find any solution for making it working in 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>

推荐答案

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

The style tag and contents must be set within the <div class="page"> element.

我没有任何文档,仅凭经验.

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

这篇关于为什么我的带有CSS的Odoo 9自定义Qweb报告无法正常工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆