border - tcpdf 中单元格的不同边框由 "setlinestyle"

标签 border cell tcpdf

在图书馆 TCPDF 中。如何通过命令“setlinestyle”设置不同的边框,使单元格看起来像 f.e.这个:

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 不完全匹配。)

$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);

它们也可以分组,这样您就不必多次提供相同的样式。例如,这里我们有平行边框共享相同的样式。
$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);

关于border - tcpdf 中单元格的不同边框由 "setlinestyle",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25730636/

相关文章:

objective-c - iOS - UIView 边框底部宽度?

html - <tr> 不显示 cms 页面的边框

css - 如何在一个div中创建多个列

ios - 如何在 iOS 的表格 View 中调整文本?

php - 在每一页的开头重复一个表格

php - tcpdf 编码汉字

css - 边框悬停在 div 上(CSS)

ios - 从 UITableViewCell 中删除单元格?

Matlab-元胞矩阵中给定列的运算

php - 使用tcpdf时如何写html格式的条码