2016-04-21 95 views
0

我使用yii扩展名将html转换为pdf,这是我使用的html代码。html to pdf conversion background image

<table cellpadding="0" cellspacing="0" style="width:100%;"> 
     <tr> 
      <td> 
       <table cellpadding="0" cellspacing="0" style="width:100%;"> 
        <tr> 
         <td style="text-align:center; width:100%; padding:35px 0 15px 0;"><img src="<?php echo Yii::app()->baseUrl;?>/images/digest_logo.png" /></td> 
        </tr> 
        <tr> 
         <td style="text-align:center; color:#2d2d2d;">April 18, 2016</td> 
        </tr> 
       </table> 
      </td> 
     </tr> 
     <tr> 
      <td style="padding-top:20px;"> 
       <table cellpadding="0" cellspacing="0" style="width:100%; background:#f3f3f1;"> 
        <tr> 
         <td style="width:100%; padding:40px 75px 35px;"> 
          <h1 style="margin:0 0 35px 0; font-weight:normal; font-size:24px;">Hi, Patron</h1> 
          <p style="margin:0 0 4px 0; font-size:17px;">Greetings from Crownit,</p> 
          <p style="margin:0 0 4px 0; font-size:17px;">Crown it believes ut is very important to. make</p> 
          <p style="margin:0 0 4px 0; font-size:17px;">Lorem ipsum Lorem ipsumhhhhhhhhh hhhhhn </p> 
         </td> 
        </tr> 
       </table> 
      </td> 
     </tr> 
     <tr> 
      <td style="background-image:url(<?php echo Yii::app()->baseUrl;?>/images/bg-script.png)"> 
       sdf 
      </td> 
     </tr> 
    </table> 

我突然卡住的地方,我想用background-image为我设计的一个地方是这样的

Image reference

当我看到在PDF我得到这个错误的结果

无法加载图像C:/xampp/htdocs//var/www/html/insight/insight/images/bg-script.png

我不知道为什么这个背景CSS不工作在PDF格式,它在浏览器中工作正常。

任何帮助表示赞赏!

回答

0

得到了答案。

这PDF扩展有一个非常小的CSS支持。

目前,只有以下CSS属性的支持:

  • FONT-FAMILY
  • 字体大小
  • 字体重量
  • 字体风格
  • 颜色
  • 背景 - 颜色
  • 文字装饰
  • 宽度
  • 高度
  • 的text-align

其他标签将无法正常工作。

+0

你的扩展使用了什么?如果它的html2pdf,那么你应该可以使用标签及其backimg属性在每个页面上指定背景。 http://wiki.spipu.net/doku.php?id=html2pdf:en:v4:page – georaldc

+0

我使用标签,我知道我可以使用整页背景图像,但如果你仔细阅读这个问题,我会问为单个标题之间的背景 –