FPDF-内联粗体 [英] FPDF - Inline bold text

查看:101
本文介绍了FPDF-内联粗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从PHP创建PDF,出于法律原因,我们需要将免责声明设为BOLD,并概述免责声明.

I am trying to create a PDF from PHP and for legal reason we need to make part of our disclaimer BOLD and the disclaimer needs to be outlined.

我当前的代码使用:

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,但是如何创建边框?

I am currently using WriteHTML for other parts of the document, and I could easily use that instead of MultiCell, but then how do I create the border?

所以我有2个选择.

FPDF的本机功能

PROS:提供边框选项

PROS: Give an option for a border

缺点:没有简单的方法可以使内联文本变为粗体

CONS: No easy way to make inline text bold

WriteHTML扩展类

PROS:让我轻松添加内嵌粗体文本

PROS: Lets me easily add bold text inline

缺点:不确定如何创建边框

CONS: Not sure how to create the border

建议?

推荐答案

您可以重写扩展名的一部分,但是使用扩展名writeHTML可能会更容易,然后绘制带有边框的单元格(空文本)您使用writeHTML创建的单元格.通过适当调整单元格,它应该可以工作.

You could rewrite a part of the extension but it may be easier for you to use the extension writeHTML, then draw a cell (empty text) with a border over the cell you created with writeHTML. By adjusting your cells properly it should work.

别忘了使用SetY 然后 SetX来定位您的单元格.

Don't forget to use SetY then SetX to position your cells.

示例:

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');
 } 

这篇关于FPDF-内联粗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆