Reputation: 1327
I want to set some text-blocks by TCPDF. But I have some problems with font size. First text block is on x-y/5-5, and his font size is 5 to. But it is samaller then 5. Font-size in TCPDF is not in the same units like other dimensions ?
PHP
$text1 = 'AAAg';
$text1_x = 5;
$text1_y = 5;
$text1_font_size = 5;
$text2 = 'BBBg';
$text2_x = 10;
$text2_y = 10;
$text2_font_size = 10;
$text3 = 'CCCg';
$text3_x = 15;
$text3_y = 15;
$text3_font_size = 15;
// I tried $pdf->Cell and $pdf->Text... both are doing the same...
Upvotes: 3
Views: 36125
Reputation: 1327
OK I found answer and solution. When we create new PDF document in tcPDF, dimensions units whole document can be in formats like mm, cm, pt, px. But fonts are in points - pt.
So solution...
PHP - tcPDF Exampe :
$pdf->setPageUnit('pt');
$document_width = $pdf->pixelsToUnits('100');
$document_height = $pdf->pixelsToUnits('100');
$x = $pdf->pixelsToUnits('20');
$y = $pdf->pixelsToUnits('20');
$font_size = $pdf->pixelsToUnits('20');
$txt = 'AAAg';
$pdf->SetFont ('helvetica', '', $font_size , '', 'default', true );
$pdf->Text ( $x, $y, $txt, false, false, true, 0, 0, '', false, '', 0, false, 'T', 'M', false );
Upvotes: 10
Reputation: 385
Changing font size in TCPDF ... Which can set using below code :
$pdf = new TCPDF();
$pdf->SetFont('Font family', '', font size here);
Which are default setting in TCPDF
Upvotes: 5