retour automatique à la ligne dans tcpdf
Je suis en utilisant tcpdf afin de créer une version pdf du html le tableau ci-dessous.
Comment faire pour mot le texte à la ligne dans les cellules?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<style type="text/css">
table.frm {
width: 960px;
Height:400px;
margin-left: auto;
margin-right: auto;
border-width: 0px 0px 0px 0px;
border-spacing: 0px;
border-style: solid solid solid solid;
border-color: gray gray gray gray;
border-collapse: collapse;
background-color: white;
font-family: Verdana,Arial,Helvetica,sans-serif;
font-size: 11px;
}
table.frm th {
Width: 120px;
border-width: 1px 1px 1px 1px;
padding: 1px 1px 1px 1px;
border-style: solid solid solid solid;
border-collapse: collapse;
border-color: gray gray gray gray;
background-color: white;
}
table.frm td {
width: 120px;
height: 80px;
vertical-align: top;
border-width: 1px 1px 1px 1px;
padding: 2px 2px 2px 2px;
border-style: solid solid solid solid;
border-collapse: collapse;
border-color: gray gray gray gray;
background-color: white;
}
</style>
<title>Weekly Menu</title>
</head>
<body>
<table class="frm">
<tr>
<th align="center" colspan="8"><b>WEEKLY MENU</b></th>
</tr>
<tr>
<th align="center" colspan="8"><b>Your Name Here</b></th>
</tr>
<tr>
<th></th>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
<th>Thursday</th>
<th>Friday</th>
<th>Saturday</th>
<th>Sunday</th>
</tr>
<tr>
<td><b>Breakfast</b></td>
<td>Scrambled Eggs Black Coffee</td>
<td>Vegetable Omelet Black Coffee</td>
<td>2 slices Toast Black Coffee</td>
<td>Cereal w/milk Black Coffee</td>
<td>Orange Juice Black Coffee</td>
<td>Cereal w/milk Black Coffee</td>
<td>Pancakes w/syrup Black Coffee</td>
</tr>
<tr>
<td><b>Lunch</b></td>
<td>Tuna Salad Sandwich Diet Coke</td>
<td>Greek Salad Black Coffee</td>
<td></td>
<td>Amer Cheese Sandwich Orange Juice</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><b>Dinner</b></td>
<td>Burger Fried Onions Diet Coke</td>
<td>Steak Fries Diet Sprite</td>
<td></td>
<td>Chicken Cutlet Baked Potato Peas</td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td><b>Snack</b></td>
<td>Apple</td>
<td>Orange</td>
<td>Sm bag of chips</td>
<td>Celery Sticks</td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</body>
</html>
C'est le tcpdf code:
$pdf = new TCPDF('Landscape', 'mm', '', true, 'UTF-8', false);
$pdf->SetTitle('Weekly Menu');
$pdf->SetMargins(15, 7.5, 12.5);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
$pdf->AddPage();
$pdf->setFormDefaultProp(array('lineWidth'=>0, 'borderStyle'=>'dot', 'fillColor'=>array(235, 235, 255), 'strokeColor'=>array(255,255,250)));
$pdf->SetFont('times', 'BU', 12);
$pdf->cell(250, 8, 'Weekly Menu', 0, 1, 'C');
$pdf->cell(250, 8, $yourname, 0, 1, 'C');
$pdf->SetFont('times', '', 10);
$cw=35;
$ch=25;
$pdf->SetXY(15,50);
$pdf->cell(25,5,'',1,0,'L');
$pdf->cell($cw,5,$day1,1,0,'C');
$pdf->cell($cw,5,$day2,1,0,'C');
$pdf->cell($cw,5,$day3,1,0,'C');
$pdf->cell($cw,5,$day4,1,0,'C');
$pdf->cell($cw,5,$day5,1,0,'C');
$pdf->cell($cw,5,$day6,1,0,'C');
$pdf->cell($cw,5,$day7,1,1,'C');
$pdf->cell(25,$ch,'Breakfast',1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[0]->breakfast,1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[1]->breakfast,1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[2]->breakfast,1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[3]->breakfast,1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[4]->breakfast,1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[5]->breakfast,1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[6]->breakfast,1,1,'L',0,0,false,'','T');
$pdf->cell(25,$ch,'Lunch',1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[0]->lunch,1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[1]->lunch,1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[2]->lunch,1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[3]->lunch,1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[4]->lunch,1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[5]->lunch,1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[6]->lunch,1,1,'L',0,0,false,'','T');
$pdf->cell(25,$ch,'Dinner',1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[0]->dinner,1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[1]->dinner,1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[2]->dinner,1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[3]->dinner,1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[4]->dinner,1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[5]->dinner,1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[6]->dinner,1,1,'L',0,0,false,'','T');
$pdf->cell(25,$ch,'Snack',1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[0]->snack,1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[1]->snack,1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[2]->snack,1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[3]->snack,1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[4]->snack,1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[5]->snack,1,0,'L',0,0,false,'','T');
$pdf->cell($cw,$ch,$record[6]->snack,1,1,'L',0,0,false,'','T');
EOD;
OriginalL'auteur ChuckO | 2010-05-30
Vous devez vous connecter pour publier un commentaire.
J'ai fait un peu plus de recherche. Ce que j'ai besoin d' Multicellulaire au lieu de Cellule pour obtenir le texte de retour.
Je sais que c'est une vieille question, mais je peux voir que vous êtes toujours actif sur 🙂 eh Bien, quelle est la solution? J' a l'utilisation Mutlicell mais il ne fonctionne pas comme prévu, le texte est justifié, mais la cellule de toujours avoir la même hauteur, de sorte qu'il chevauche la cellule suivante (ci-dessous). Les docs disent: "$h (float) de Cellules de hauteur minimum. La cellule s'étend automatiquement si nécessaire." Mais il ne le fait pas. J'ai le plus récent TCPDF version.
OriginalL'auteur ChuckO