0

I changed Cell() to Multicell() in a table to include break lines inside a cell.

I don't know why it is breking the line after each new data. I mean, the header and corresponding data should be all in one line:

Name | Last Name | Exemple of breaking line

but what's happening is:

Name

Last Name

Exemple of breaking line

php:

<?php

$pdf->Multicell(200, 20, 'Motorista',1);
$pdf->Multicell(60, 20, 'Direção',1);
$pdf->Multicell(60, 15, "Espera Pós \nJornada",1,'C');
$pdf->Multicell(60, 15, "Espera em \nJornada",1,'C');
$pdf->Multicell(60, 20, 'Noturnas',1);
$pdf->Multicell(70, 20, 'Extras 50%',1);
$pdf->Multicell(70, 20, 'Extras 100%',1);
$pdf->Multicell(60, 15, "Hrs Tempo \nParado",1,'C');
$pdf->SetFont('Arial', '', 9);
$pdf->Ln(10);

?>

I removed $pdf->Ln(10); but this is just for adding margin from header to data.

Community
  • 1
  • 1
A52
  • 19
  • 7

1 Answers1

0

I solved it based on this answer

<?php

$x = $pdf->GetX(); 
$y = $pdf->GetY();

$pdf->Multicell(200, 30, 'Motorista',1,'C');
$pdf->SetXY($x + 200, $y);

$pdf->Multicell(60, 30, 'Direção',1,'C');
$pdf->SetXY($x + 260, $y);

$pdf->Multicell(60, 15, "Espera Pós \nJornada",1,'C');
$pdf->SetXY($x + 320, $y);

$pdf->Multicell(60, 15, "Espera em \nJornada",1,'C');
$pdf->SetXY($x + 380, $y);

$pdf->Multicell(60, 30, 'Noturnas',1,'C');
$pdf->SetXY($x + 440, $y);

$pdf->Multicell(60, 30, 'Extras 50%',1,'C');
$pdf->SetXY($x + 500, $y);

$pdf->Multicell(60, 30, 'Extras 100%',1,'C');
$pdf->SetXY($x + 560, $y);

$pdf->Multicell(60, 15, "Hrs Tempo \nParado",1,'C');
$pdf->SetXY($x + 620, $y);

$pdf->SetFont('Arial', '', 9);
$pdf->Ln(30);

?>

So you sum the previous col width to the next one.

A52
  • 19
  • 7