通过"setlinestyle",tcpdf中的单元格具有不同的边界. [英] Different borders for the cell in tcpdf by "setlinestyle"
问题描述
在库TCPDF中.如何通过命令"setlinestyle"设置不同的边框,以使单元格看起来像f.e.这个:
In library TCPDF. How can I set different borders by command "setlinestyle", to make the cell looks like f.e. this:
css
/* top */
border-top-width="1"
border-top-style="solid"
border-top-color="rgba(0, 255, 0, 1)"
/* right */
border-right-width="2"
border-right-style="dotted"
border-right-color="rgba(255, 0, 255, 1)"
/* bottom */
border-bottom-width="3"
border-bottom-style="solid"
border-bottom-color="rgba(0, 0, 255, 1)"
/* left */
border-left-width="4"
border-left-style="solid"
border-left-color="rgba(255, 0, 255, 1)"
一种具有所有边框样式的PHP命令
$pdf->SetLineStyle(array('width' => 0.5, 'cap' => 'butt', 'join' => 'miter', 'dash' => 4, 'color' => array(255, 0, 0)));
$text="DUMMY";
$pdf->Cell(0, 0, $text, 1, 1, 'L', 1, 0);
推荐答案
在创建单元格时,您可以通过将每个边框作为border参数的分组数组传递,将每个边框分别设置为不同的线型.例如(请注意,这与您的CSS并不完全匹配.)
When creating the cell you can set each border to a different line style individually by passing them as a grouped array for the border parameter. For example (note that this does not exactly match your CSS above.)
$complex_cell_border = array(
'T' => array('width' => 1, 'color' => array(0,255,0), 'dash' => 4, 'cap' => 'butt'),
'R' => array('width' => 2, 'color' => array(255,0,255), 'dash' => '1,3', 'cap' => 'round'),
'B' => array('width' => 3, 'color' => array(0,0,255), 'dash' => 0, 'cap' => 'square'),
'L' => array('width' => 4, 'color' => array(255,0,255), 'dash' => '3,1,0.5,2', 'cap' => 'butt'),
);
//Where T,B,R, and L are Top, Bottom, Right and Left respectively.
$pdf->Cell(0,0,"Dummy text, more dummy text!", $complex_cell_border);
它们也可以分组,因此您不必多次提供相同的样式.例如,在这里,我们具有相同样式的平行边框.
They can also be grouped so you're not having to provide the same style multiple times. For example, here we have parallel borders share the same style.
$complex_cell_border = array(
'TB' => array('width' => 1, 'color' => array(0,255,0), 'dash' => 4, 'cap' => 'butt'),
'RL' => array('width' => 2, 'color' => array(255,0,255), 'dash' => '1,3', 'cap' => 'round'),
);
$pdf->Cell(0,0,"Dummy text, more dummy text!", $complex_cell_border);
这篇关于通过"setlinestyle",tcpdf中的单元格具有不同的边界.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!