I try to create tcpdf using writeHTML
like this $pdf->writeHTML($html, true, 0, false, 0);
which $html
value like code below
<table border="1">
<tr>
<td width="100%" colspan="4">
<table border="0">
<tr>
<td width="18%" style="border-right:0.01px">Test 1</td>
<td width="12%">Test 2</td>
<td width="20%">Test 3</td>
</tr>
<tr>
<td width="18%" style="border-right:0.01px">Test 4</td>
<td width="12%">Test 5</td>
<td width="20%">Test 6</td>
</tr>
</table>
</td>
</tr>
</table>
style="border-right:0.01px"
or style="border-right:0.1px"
or style="border-right:1px"
provide same result of border width, how to make this right border smaller? because my result rigth border on Test 1 and Test 4 are biggest then outside border.
Go to Table Tools >Design > Table Styles > Borders, and then click the border option that you want to change.
To change the width of the table's border, use the attribute border="p" where p = number of pixels wide the border should be. Note that using this attribute also adds borders to the cells. The table below has a border of 10 pixels. This is done with the table tag <table border="10">.
The HTML <table> border Attribute is used to specify the border of a table. It sets the border around the table cells.
If you're a little more explicit in your border definition it'll work as you expect. TCPDF's HTML/CSS parser is rather limited so it helps to be as specific as possible with your styling rules and the like.
Your code should work with either border-right-width: 0.1px
or with the rest of CSS properties for the shorthand of border-right
, see the example HTML below and accompanying screenshot of a rendered PDF (zoomed to highlight difference)
<table border="1">
<tr>
<td width="100%" colspan="4">
<table border="0">
<tr>
<!-- This should work -->
<td width="18%" style="border-right-width:0.1px;">Test 1</td>
<td width="12%">Test 2</td>
<td width="20%">Test 3</td>
</tr>
<tr>
<!-- As should this -->
<td width="18%" style="border-right:0.1px solid black;">Test 4</td>
<td width="12%">Test 5</td>
<td width="20%">Test 6</td>
</tr>
<tr>
<!-- However, this does not. -->
<td width="18%" style="border-right:0.1px">Test Broken</td>
<td width="12%">Test :)</td>
<td width="20%">Test :)</td>
</tr>
</table>
</td>
</tr>
</table>
As you can see, it handles the first two definitions as expected with thinner borders.
I use style="border-right-color:white" to hidden right border
<td style="border-right-color:white; border-bottom-color:black; border-top-color:black"></td>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With