我正在尝试从PHP创建PDF,出于法律原因,我们需要将免责声明设为“BOLD”,并对免责声明进行概述。
我当前的代码使用:
if(isset($_POST['optout']) && $_POST['optout'] == "yes"){
$pdf->Ln(5);
$pdf->SetFont('Arial','I',12);
$pdf->SetTextColor(128);
$pdf->MultiCell(0,4,'This is my disclaimer. THESE WORDS NEED TO BE BOLD. These words do not need to be bold.',1,'C');
}
我目前在文档的其他部分使用WriteHTML,可以轻松地使用它代替MultiCell,但是如何创建边框?
所以我有2个选择。
native FPDF函数
优点:给边框加个选项
缺点:没有简单的方法可以使内联文本变为粗体
WriteHTML扩展类
优点:让我轻松地以内联方式添加粗体文本
缺点:不确定如何创建边框
有什么建议吗?
最佳答案
您可以重写扩展的一部分,但是使用扩展writeHTML可能会更容易,然后在您使用writeHTML创建的单元格上方绘制带有边框的单元格(空文本)。通过适本地调整单元格,它应该可以工作。
不要忘记使用SetY 然后使用 SetX来定位您的单元格。
例子:
if(isset($_POST['optout']) && $_POST['optout'] == "yes"){
$pdf->Ln(5);
$pdf->SetFont('Arial','I',12);
$pdf->SetTextColor(128);
//Your text cell
$pdf->SetY($pos_Y);
$pdf->SetX($pos_X);
$pdf->writeHTML('This is my disclaimer. <b>THESE WORDS NEED TO BE BOLD.</b> These words do not need to be bold.');
//Your bordered cell
$pdf->SetY($pos_Y);
$pdf->SetX($pos_X);
$pdf->Cell($width, $height, '', 1, 0, 'C');
}