$pdf = new TCPDF(); $pdf->SetFont('Arial', 'B', 12); $pdf->SetFontSize(8); $pdf->Write(0, 'This text will be written at size 8.');
$fontSizes = array(6, 8, 10, 12, 16, 20); foreach($fontSizes as $size) { $pdf->SetFontSize($size); $pdf->Write(0, "This text is set at size $size\n"); }
$fontSize = 10; for($i = 1; $i <= 5; $i++) { $pdf->SetFontSize($fontSize); $pdf->Write(0, "This text is size $fontSize.\n"); $fontSize += 2; }This example illustrates a method to incrementally increase the font size for text. The script starts with a base font size of 10 and loops through 5 iterations, each time increasing the size by 2 points. In all of these examples, TCPDF SetFontSize is used to manipulate the size of the text written to the PDF document. TCPDF is a popular PHP package library that enables the creation and manipulation of PDF documents through a variety of methods, including SetFontSize().