Skip to content
PHP Logo

How can line breaks be implemented in FPDF multicell function in PHP?

To implement line breaks in FPDF multicell function in PHP, you can use the "\n" character to indicate a line break within the text passed to the multicell function. This will create a new line within the cell content.

php
<?php
require('fpdf.php');

$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','',12);

$text = "This is a sample text with\nline breaks in FPDF multicell function.";

$pdf->MultiCell(0, 10, $text);

$pdf->Output();
?>