php - 如何使用 php 和 TCPDF 在 pdf 中绘制虚线?
问题描述
我需要使用 TCPDF 在 pdf 中绘制水平虚线。我试过了:
$style = array('width' => 0.1, 'cap' => 'butt', 'join' => 'miter', 'dash' => 1, 'color' => array(0, 0, 0));
$pdf->Line(5, 50, 100, 50, $style);
我使用了破折号参数。当我将它设置为 1 时,它会绘制短划线,但我需要点。我没有在互联网上找到关于样式参数的解释或任何手册。
解决方案
请使用以下代码在 pdf 中绘制水平虚线TCPDF
并对其应用样式。
<?php
require_once('tcpdf.php');
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// disable header and footer
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
// set font
$pdf->SetFont('helvetica', '', 10);
// add a page
$pdf->AddPage();
//set 'width' => 0.1, 'dash' => '1,1,1,1' as per your requirement
$style = array('width' => 0.5, 'dash' => '2,2,2,2', 'phase' => 0, 'color' => array(255, 0, 0));
// Line
$pdf->Text(5, 4, 'Line examples');
$pdf->Line(5, 20, 200, 20, $style);
//Close and output PDF document
$pdf->Output('line_example.pdf', 'I');
我希望这有帮助!
推荐阅读
- android - 如何修复 android.widget.TextView() 需要 api 21 错误
- objective-c - 用石英 2D 从透明 png 交换 UIImage 上的颜色通道
- julia - 如何在 Julia 的 TimeSeries 中增加价值
- sql - 如何使用输入参数文件路径从 plpgsql 函数中复制
- python - 如何获取包含管道的 Python 子进程命令的输出?
- r - 如何查看并行调整 mlr 的中间结果?
- c++ - 如何在模板函数中根据对象的类型构造不同的对象?
- c# - 将字符串作为参数传递:它是复制还是引用?我很困惑
- r - 为什么 predict.lm 和矩阵乘法给出不同的预测?
- postgresql - 我无法删除 Postgresql 数据库,因为无论如何它总是有活动会话