Question

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:

  • pixels ("500px")
  • percentage ("100%")
  • without 'px' ("500")
  • using the '& quot;' tag (yes, I'm aware there is an extra space between '&' and 'quot')

... 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?

Was it helpful?

Solution

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

OTHER TIPS

You can also use "col" tags after the opening "table" tag. e.g.

<col width="250">
<col width="500">
<col width="250">

I have the same problem and I changed the page margins, especially on the right side

page backtop="14mm" backbottom="14mm" backleft="8mm" backright="100mm"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top