nam*_*tha 4 html css php tcpdf
在下面的代码中,我使用了两种字体水果和水果粗体..所以当我使用这整个页面时,整个页面都是粗体的。但我想同时使用两者。例如:你好应该是水果,世界应该是粗体……我尝试了所有的事情都没有结果。
<?
require_once('../tcpdf.php'); //include tcpdf library
$pdf = new TCPDF();
$pdf->AddPage('P', 'A4');
$fruit=$pdf->AddFont('fruit');
$pdf->SetFont($fruit['family']);
$fruit_bold=$pdf->AddFont('fruit_bold');
$pdf->SetFont($fruit_bold['family']);
$html='<html>
<head>
</head>
<body>
<table width="100%" border="0" style="font-size:24px;" >
<tr>
<td>Hello World</td>
</tr>
</table>';
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->Output();
?>
Run Code Online (Sandbox Code Playgroud)
我终于找到了解决方案..你可以这样使用两种或多种字体
<?
require_once('../tcpdf.php'); //include tcpdf library
$pdf = new TCPDF();
$pdf->AddPage('P', 'A4');
$fruit=$pdf->AddFont('fruit'); //custom font
$fruitb=$pdf->AddFont('fruitb'); //custom font
$html='
<style>
span{
color: navy;
font-family: fruitb;
font-size: 16pt;
}
p {
color: red;
font-family: fruit;
font-size: 16pt;
}
</style>
<span>My text in bold</span>
<p>Normal text</p>';
$pdf->writeHTML($html, true, false, true, false, '');
$pdf->Output();
?>
Run Code Online (Sandbox Code Playgroud)