如何通过dompdf提供PDF背景? [英] How to give Background to pdf by dompdf?

查看:99
本文介绍了如何通过dompdf提供PDF背景?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Dompdf将Html Page转换为PDF。作为客户的要求pdf文件的背景应该有水印图像。我在编码方面尝试了很多方法,也有不同的css风格,但没有帮助。有人有任何想法吗?请帮帮我。

I m using Dompdf to convert Html Page to PDF. As client's requirement pdf should have watermark image at background of document. I have tried many ways in coding and also differnt css style but its not helpful. Is anybody has any idea about it? please Help me out.

推荐答案

哪个版本的DOMPDF?使用0.6.0版本,您可以使用固定位置元素作为水印。这是一个文档外壳:

Which version of DOMPDF? With the 0.6.0 release you could use a fixed-position element to act as a watermark. Here's a document shell:

<html>
  <head>
    <style>
      #watermark { position: fixed; bottom: 0px; right: 0px; width: 200px; height: 200px; opacity: .1; }
    </style>
  </head>
  <body>
    <div id="watermark"><img src="http://code.google.com/p/dompdf/logo" height="100%" width="100%"></div>
  </body>
</html>

请参阅此处的示例: http://eclecticgeek.com/dompdf/debug.php?identifier=f14b0c995add4b6c1ee1d14c0c6a987e

开0.5.1你可以在主体上使用背景图像风格声明。您对样式的控制较少,因此您需要确保图像的格式与文档中的显示格式完全相同,具体涉及大小和不透明度。还有其他一些问题,但这确实奏效。这是一个文档外壳:

On 0.5.1 you could use the background-image style declaration on the body. You have less control over the styling, so you'll want to make sure the image is formatted exactly how it should appear in the document, specifically related to size and opacity. There are other issues, as well, but this does work. Here's a document shell:

<html>
  <head>
    <style>
      body { background-image: url(http://www.wolfsrainfans.com/wp-content/uploads/2011/04/Wolfs_Rain__Taboe_by_Nizira_Hathor.png); background-position: bottom right; background-repeat: no-repeat; }
    </style>
  </head>
  <body>
  </body>
</html>

请参阅此处的示例: http://eclecticgeek.com/dompdf/debug.php?identifier=a05af7b814031ac5460860560a581183

这篇关于如何通过dompdf提供PDF背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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