-1

$pdf->SetFont sets the font to entire page but i want this font to be affected only to span tag.

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();
namratha
  • 191
  • 4
  • 11
  • Check out this link http://stackoverflow.com/questions/8990216/html-rendering-with-tcpdfphp [1]: http://stackoverflow.com/questions/8990216/html-rendering-with-tcpdfphp – Kapil gopinath May 14 '14 at 05:17

1 Answers1

0

You have to explicitly set the font for each cases. For example

$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

In your case as you are passing an html you can write inline style to the span and get it applied . // Please try this and see if it has any effect

$html='<span style="font-weight:bold" '.$pdf->SetFont($fruit['family']).'>my text in bold</span>This isnormal';
Kapil gopinath
  • 1,053
  • 1
  • 8
  • 18
  • even after using $pdf->setFont inside span tag whole document is reflecting with same font..i want the font only to be reflected in span tag – namratha May 14 '14 at 05:21
  • You will get answer to your question by referring these 2 links. http://www.tcpdf.org/examples/example_006.phps http://www.tcpdf.org/examples/example_006.pdf //this is the pdf generated result of the php file(example_006.phps) Dont forget that you can add inline style. – Kapil gopinath May 14 '14 at 05:32