$pdf = new TCPDF(); $pdf->AddPage(); $pdf->SetFont('helvetica', 'B', 12); $pdf->SetTextColor(0, 0, 0); $pdf->SetXY(20, 50); $pdf->Cell(50, 10, 'Hello World!'); $pdf->Output();
$pdf = new TCPDF(); $pdf->AddPage(); $pdf->SetFont('helvetica', 'B', 12); $pdf->SetTextColor(0, 0, 0); $x = 20; $y = 50; $pdf->SetXY($x, $y); $pdf->Cell(50, 10, 'Hello World!'); $new_x = $x + 50; $new_y = $y + 10; $pdf->SetXY($new_x, $new_y); $pdf->Cell(50, 10, 'This is a new line under the first'); $pdf->Output();This code is similar to example 1, but also shows how the SetXY function can be used to move the cursor to a new position for a new line of text. The new position is calculated based on the previous position plus the width and height of the previous cell. The TCPDF library is used in both examples.