【问题标题】:html tags issue in pdfpdf中的html标签问题
【发布时间】:2015-09-08 10:42:50
【问题描述】:

我有短信

  $text1 =  <p>This is a paragraph</p>
  $text2 =  <p>7<sup>2</sup></p>
  $text3 =  <b>This is bold</b>

我必须将这些文本显示为 pdf。我试过这样:

$pdf->Cell(0,10,$num.". ".$text1, 0, 1);
$pdf->Cell(0,10,$num.". ".$text2, 0, 1);
$pdf->Cell(0,10,$num.". ".$text3, 0, 1);

结果是

 <p>This is a paragraph</p>
 <p>7<sup>2</sup></p>
 <b>This is bold</b>

但我的预期结果是:

这是一段

72

这是粗体

我该怎么做?请帮帮我..

我正在使用 fpdf 生成 pdf。

【问题讨论】:

标签: php fpdf


【解决方案1】:

FPDF 格式为您提供解决方案

if (in_array( strtoupper($val['tag']) , array('SUP','SUB'))) { 
// use the SetStyle-function to define Sub/Sub properties 
$bakY = $this->y; 
$bakX = $this->x; 
if (strtoupper($val['tag'])=="SUP") 
$this->SetY($bakY-1); 
else 
$this->SetY($bakY+1); 
$this->SetX($bakX); 
} 

if (in_array( strtoupper($val['tag']) , array('SUP','SUB'))) { 
$bakX = $this->x; 
$this->SetY($bakY); 
$this->SetX($bakX); 
}

此代码属于 FPDF 格式。希望对您有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-23
    • 1970-01-01
    • 1970-01-01
    • 2018-10-01
    • 2021-10-09
    • 2011-01-15
    • 1970-01-01
    相关资源
    最近更新 更多