word wrap in tcpdf
Posted
by ChuckO
on Stack Overflow
See other posts from Stack Overflow
or by ChuckO
Published on 2010-05-30T14:14:05Z
Indexed on
2010/05/31
23:43 UTC
Read the original article
Hit count: 501
I'm using tcpdf to creat a pdf version of the html table below.
How do I word wrap the text in the cells?
<!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>
This is the 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;
© Stack Overflow or respective owner