问题描述
我正在创建qweb报表,我想在所有页面中将图像添加到背景中,但是仅在第一页中出现水印.我尝试过的:
I am creating qweb report and I want to add a image to the background in all pages but I am getting watermark in only the first page. What I have tried:
<div style="position:absolute;text-align:center;z-index:-1;border:0;opacity:0.1;padding-top:50px;">
<img t-att-src="'data:image/png;base64,%s' %o.employee_id.company_id.watermark_img"/>
</div>
推荐答案
我已经找到了解决方案这里
I have found the solution here
在外部布局的标头中为水印添加此代码.它的外部ID是report.external_layout_header
:
Add this code for watermark in header of external layout. Its external id is report.external_layout_header
:
<style>
.watermark {
position: absolute;
opacity: 0.25;
z-index: 1000;
transform: rotate(300deg);
-webkit-transform: rotate(300deg);
width: 150%;
}
</style>
<div class="watermark">
<p>WATERMARK</p>
<img t-att-src="'/module_name/static/src/img/image_name.png'" />
</div>
我添加了以文件形式存储的图像.如果您要使用静态图片,我认为这是最合适的方式
I have added a image stored as a file. If you are going to use a static image I think this is the most appropiate way
注意:恐怕这在Odoo v11中不起作用
Note: I am afraid this does not work in Odoo v11
仅当您要将同一图像添加到所有报告中时,此解决方案才有效.
This solution only is valid if you want to add the same image to all the reports.
OCA开发了一个模块,用于在报告中添加水印.在所有报表中都会出现一个字段,可以在其中添加图像(A4尺寸).模块名称为 report_qweb_pdf_watermark
There is a module developed by the OCA to add watermarks to the reports. A field appears in all reports where an images (with A4 size) can be added. The module name is report_qweb_pdf_watermark
这篇关于如何在Odoo的所有PDF页面的Qweb Reports中添加水印图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!