Different borders for a cell in tcpdf "setlinestyle"
The TCPDF library. How can I set different borders with "setlinestyle" command so that the cell looks like fe is:
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 command with one style for all borders
$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);
+3
source to share
1 answer
When creating a cell, you can set each border to a separate line style separately by passing them as a grouped array for the border parameter. For example (note that this does not 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 be grouped as well, so you don't need to provide the same style multiple times. For example, here the parallel borders have 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);
+10
source to share