2014-05-14 20 views
-1

$ pdf-> SetFont将字体设置为整个页面,但是我只希望该字体仅用于跨度标记。

require_once('../tcpdf.php');  
$pdf = new TCPDF(); 
$pdf->AddPage('P', 'A4'); 
$fruit=$pdf->AddFont('fruit'); 
$html='<span '.$pdf->SetFont($fruit['family']).'>my text in bold</span>This isnormal'; 
$pdf->writeHTML($html, true, false, true, false, ''); 
$pdf->Output(); 
+0

退房此链接 http://stackoverflow.com/questions/8990216/html-rendering-with-tcpdfphp [1]: http://stackoverflow.com/questions/8990216/html-rendering-with-tcpdfphp –

回答

0

您必须明确设置每种情况下的字体。例如

$pdf->SetFont('times', 'B', 16); 
// now time s font will applied for the following cell 
$pdf->MultiCell(0, 0, 'Table Of Content', 0, 'C', 0, 1, '', '', true, 0); 
$pdf->Ln(); 
$pdf->SetFont('helvetica', '', 10); 
// This will override the time s font applied before and apply helvetica as the new font 

在你的情况下,当你传递一个html,你可以写入内联风格的跨度,并得到它应用。 //请试试这个,看看它是否有任何影响

$html='<span style="font-weight:bold" '.$pdf->SetFont($fruit['family']).'>my text in bold</span>This isnormal'; 
+0

即使使用$ pdf-> setFont内部跨度标签整个文档是反映相同的字体..我希望字体只反映在跨度标签 – namratha

+0

您将通过参考这2个链接来获得您的问题的答案。 http://www.tcpdf.org/examples/example_006.phps http://www.tcpdf.org/examples/example_006.pdf //这是pdf文件生成的结果(example_006.phps) 不要忘记你可以添加内联样式。 –

相关问题