php - 超过渐变时,Tcpdf multiCell 边框丢失
问题描述
如何在渐变上使用带有边框的 MultiCell?
请注意,如果您使用单元格,则会显示边框。
// set colors for gradients (r,g,b) or (grey 0-255)
$red = array(255, 0, 0);
$blue = array(0, 0, 200);
$yellow = array(255, 255, 0);
$green = array(0, 255, 0);
$white = array(255);
$black = array(0);
// set the coordinates x1,y1,x2,y2 of the gradient (see linear_gradient_coords.jpg)
$coords = array(0, 0, 1, 0);
// paint a linear gradient
$pdf->LinearGradient(20, 45, 80, 80, $red, $blue, $coords);
// write label
$pdf->MultiCell(100, 100, 'LinearGradient()', 1);
解决方案
根据 Nicola 本身(https://sourceforge.net/p/tcpdf/bugs/236/)“这是通缉行为”。
$pdf->setPageMark()
在渐变和多单元格之间添加。
// paint a linear gradient
$pdf->LinearGradient(20, 45, 80, 80, $red, $blue, $coords);
$pdf->setPageMark();
// write label
$pdf->MultiCell(100, 100, 'LinearGradient()', 1);
此外,通过setPageMark
docblock:
在当前页面流上设置开始写入标记,用于放置边框和填充。边框和填充总是在内容之后创建并插入到此方法标记的位置。此函数必须在为背景图像调用 Image() 函数后调用。背景图像必须始终在调用 Multicell() 或 WriteHTMLCell() 或 WriteHTML() 函数之前插入。
推荐阅读
- javascript - 与 if else 对应物相比,Javascript 三元组在 React 状态下产生意外结果
- html - 网页在移动设备上打开放大
- arrays - 使用 Google 表格的 2 组值中的共同值
- eclipse - 为什么 Eclipse 在应该使用 JUnit4 时却尝试使用 JUnit5?
- c# - Hangfire ContinueWithJob 卡在等待状态,尽管父作业已成功
- c - 以下 C 代码显示:格式“%c”需要“int”类型的参数,但参数 3 的类型为 char*
- php - PHP Closures - 获取闭包范围起源的类名
- javascript - 在 Bootstrap Datetimepicker 上禁用特定日期的特定时间
- matlab - Octave 和 area() 方法的问题
- flutter - 即使应用程序关闭或终止,flutter 中的异步操作是否仍在运行