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

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

问题描述

我正在使用Yii Extension开发的网页上工作,并且正在使用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:

  • 像素("500像素")
  • 百分比("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上的所有示例均具有以下属性:

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天全站免登陆