Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an alternative to TCPDF::writeHTML to get inline bold text

Tags:

php

tcpdf

I'm using TCPDF to generate a PDF with text only.

First I've used multiCell to add the text, now I wanted to have two words become bold (somewhere in the middle in my text). So I changed my code to use writeHTML and surrounded i with b-tags, and voila the words are now blod. But at the same time my document size went from 41kB to 205kB which seems a little extreme.

Is there anyway to use inline blod formatting in the text without increasing the PDF size by 300%?

like image 773
Jacob Avatar asked Sep 25 '12 09:09

Jacob


1 Answers

As I said in comments, try with changing your font prior to using Cell() or Multicell() , example follows:

$pdf=new PDF();
...
$pdf->Cell(180,10,'bla bla',0,1,'C');
$pdf->SetFont('Times','B',16);            //Change to bold
$pdf->Cell(180,10,'bla bla bla',0,1,'C'); //this printed in bold
$pdf->SetFont('Times','',12);             //Revert to plain font
$pdf->Cell(180,10,'bla bla bla',0,1,'C');
like image 172
Nelson Avatar answered Oct 19 '22 01:10

Nelson