HTML2PDF 无法识别表格的大小 [英] HTML2PDF doesn't recognize tables' sizes

查看:31
本文介绍了HTML2PDF 无法识别表格的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Yii 扩展开发的网页上工作,我正在使用 HTML2PDF 扩展生成 PDF (http://html2pdf.fr/).尽管 PDF 生成得很好,但它似乎无法识别我的表格大小;我为一行或整个表格指定的宽度或高度无关紧要:PDF 总是以相同的方式生成(表格宽度恰好适合单元格内容)......这是我试图指定的方式宽度:

I'm working in a web page developed using Yii Extension and I'm using the HTML2PDF extension to generate PDFs (http://html2pdf.fr/). Though the PDF is generated fine, it doesn't seem to recognize my tables' sizes; doesn't matter the width or height I specify for a row or a whole table: the PDF is always generated the same way (with a table width that just fits the cell content)... Here is how I'm trying to specify the width:

<table width="500px" height="20px" style="margin:10px;">
                    <tr>
                        <td width="25%"></td>
                        <td width="50%"></td>
                        <td width="25%"></td>
                    </tr>
                    <tr bgcolor="#EAF8FF">
                        <td colspan="3">
                            <strong>Title</strong>
                        </td>
                    </tr>

我试过用以下方法指定宽度:

I've tried specifying the width with:

  • 像素(500px")
  • 百分比(100%")
  • 没有px"(500")
  • 使用 '&quot;'标签(是的,我知道&"和quot"之间有一个额外的空格)

...等等,但似乎没什么关系...表格的大小和宽度总是与其包含的文本成正比.但是,tr"标签中的bgcolor"和td"标签中的colspan"都可以正常工作,所以我不知道会发生什么......我也试过在里面指定大小'tr',但什么都没有...不知道我会遗漏什么?

... etc. but nothing seems to matter... The table size and width is always proportional to the text it contains. However, both the "bgcolor" in the 'tr' tag and the "colspan" in the 'td' tag work fine, so I don't know what can be happening... I've also tried specifying the size inside the 'tr', but nothing... Any idea on what can I be missing?

推荐答案

您是否尝试过使用样式"属性?html2pdf wiki 上的所有示例都具有此属性:http://wiki.spipu.net/doku.php?id=html2pdf:en:v4:bookmark&s[]=td&s[]=width

Have you tried with "style" attribute? All examples on html2pdf wiki is with this attribute : http://wiki.spipu.net/doku.php?id=html2pdf:en:v4:bookmark&s[]=td&s[]=width

这篇关于HTML2PDF 无法识别表格的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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