如何使右边界表tcpdf更小?
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.
我尝试使用 writeHTML code>创建tcpdf,如
$ pdf-&gt; writeHTML($ html,true,0,false,0); code>其中
$ html code>值如下面的代码 p>
&lt; table border =“1”&gt;
&lt; tr&gt;
&lt; td width =“100%”colspan =“4”&gt;
&lt; table border =“0”&gt;
&lt; tr&gt;
&lt; td width =“18%”style =“border-right:0.01px”&gt; Test 1&lt; / td&gt;
&lt; td width =“12%”&gt; Test 2&lt; / td&gt;
&lt; td width =“20%”&gt;测试3&lt; / td&gt;
&lt; / tr&gt;
&lt; tr&gt;
&lt; td width =“18%”style =“border-right:0.01px”&gt ;测试4&lt; / td&gt;
&lt; td width =“12%”&gt;测试5&lt; / td&gt;
&lt; td width =“20%”&gt;测试6&lt; / td&gt;
&lt; / tr&gt;
&lt; / table&gt;
&lt; / td&gt;
&lt; / tr&gt;
&lt; / table&gt;
code> pre>
style =“border-right:0.01px” code>或
style =“border-right:0.1px” code>或
style =“border-right:1px” code>提供 边框宽度的相同结果,如何使这个右边框更小? 因为我在测试1和测试4上的结果边界最大然后在边界外。 p>
div>
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.