i'm generating a pdf document for an invoice using TCPDF library in yii php. after the address data there a part with the list of bought items. that list is of variable lenght which makes it hard to predict where the next part will render. and at the end there is a part with payment, taxes, shipping etc.
i would like to know how to make that last part be unbreakable. so it's either entirely on the first page or entirely on the second page.
is that even doable?
in case it helps here's the code for the part in question:
$pdf->SetFont("helvetica", "", 9);
$pdf->Cell(4,0,'Versandart','TLR',0,'L',0,'',0, 0,'','T');
$pdf->Cell(8,0,"$model->versandart",'TBLR',0,'R',0,'',0, 0,'','B');
$pdf->SetFont("helvetica", "", 6);
$pdf->Cell(5,0.4,'Hiermit bestätige ich den Auftrag','TLR',1,'R',0,'',0, 0,'','T');
$pdf->SetFont("helvetica", "", 9);
$pdf->Cell(4,0,'Frachtpreis','TLR',0,'L',0,'',0, 0,'','T');
$pdf->Cell(8,0,"$model->versandpreis €",'BLR',0,'R',0,'',0, 0,'','B');
$pdf->Cell(5,0,'','LR',1,'R',0,'',0, 0,'','T');
$pdf->Cell(4,0,'Nachnahmegeb.','TLR',0,'L',0,'',0, 0,'','T');
$pdf->Cell(8,0,"$model->nachnahme €",'BLR',0,'R',0,'',0, 0,'','B');
$pdf->Cell(5,0,'','LR',1,'R',0,'',0, 0,'','T');
$pdf->Cell(4,0,'SPV-Versicherung','TLR',0,'L',0,'',0, 0,'','T');
$pdf->Cell(8,0,"$model->versicherung €",'BLR',0,'R',0,'',0, 0,'','B');
$pdf->SetFont("helvetica", "B", 6);
$pdf->Cell(5,0.4,'Ort, Datum, Unterschrift','BLR',1,'R',0,'',0, 0,'','B');
$pdf->SetFont("helvetica", "", 9);
$pdf->Cell(4,0,'Nettobetrag','TLR',0,'L',0,'',0, 0,'','T');
$pdf->Cell(8,0,$totalSum-($model->vat/100)*$totalSum." €",'BLR',0,'R',0,'',0, 0,'','B');
$pdf->SetFont("helvetica", "", 6);
$pdf->Cell(5,0.4,'Ich erkenne die AGB in der Homepage','TLR',1,'R',0,'',0, 0,'','T');
$pdf->SetFont("helvetica", "", 9);
$pdf->Cell(4,0,"incl. $model->vat% MwSt.",'TLR',0,'L',0,'',0, 0,'','T');
$pdf->Cell(8,0,($model->vat/100)*$totalSum." €",'BLR',0,'R',0,'',0, 0,'','B');
$pdf->SetFont("helvetica", "", 6);
$pdf->Cell(5,0.4,'unter Kontakt nachzulesen hiermit an.','LR',1,'R',0,'',0, 0,'','T');
$pdf->SetFont("helvetica", "", 9);
$pdf->Cell(4,0,'Summe','TLR',0,'L',0,'',0, 0,'','T');
$pdf->Cell(8,0,$totalSum." €",'BLR',0,'R',0,'',0, 0,'','B');
$pdf->SetFont("helvetica", "B", 6);
$pdf->Cell(5,0.4,'','LR',1,'R',0,'',0, 0,'','B');
$pdf->SetFont("helvetica", "", 9);
$pdf->Cell(4,0,'zu bezahlen','TBLR',0,'L',0,'',0, 0,'','T');
$pdf->Cell(8,0,$totalSum-$model->paymentSum." €",'BLR',0,'R',0,'',0, 0,'','B');
$pdf->SetFont("helvetica", "B", 6);
$pdf->Cell(5,0.4,'Ort, Datum, Unterschrift','BLR',1,'R',0,'',0, 0,'','B');
$pdf->Ln();
$pdf->MultiCell(4, 1, 'Hiermit bestätige ich den Auftrag', 'TLR', 'R', 0, 1, '', '', true, 0, false, true, 0, 'T');
$pdf->MultiCell(4, 1, 'Ort, Datum, Unterschrift', 'BLR', 'R', 0, 1, '', '', true, 0, false, true, 0, 'B');
The way I know of would be to generate HTML code first and let tcpdf convert it to pdf which is generally easier to code I think. You can then use the following style attribute to achieve what you're looking for:
There is a simple solution for this, you can include what html provides you for the
<tr>
that breaks, simply usenobr="true"
For example: