Reputation: 191
In the below code i am using two fonts fruit and fruit bold.. so when i use this whole page is coming in bold. But i want make use of both. ex : hello should come in fruit and world should come in bold.. i tried all things nothing worked out.
<?
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();
?>
Upvotes: 4
Views: 4591
Reputation: 191
I finally found the solution.. you can use two or more fonts this way
<?
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();
?>
Upvotes: 6