0.625, 'colW'=>3.0, 'colSpacing'=>0.0); $font = array(); $font['category'] = array ('family'=>'ArialBlack', 'style'=>'', 'size'=>13, 'color'=>'#ba3e46'); $font['catDesc'] = array ('family'=>'Arial', 'style'=>'', 'size'=>10); $font['item'] = array ('family'=>'PalatinoLinotype', 'style'=>'', 'size'=>12, 'color'=>'#b7484d'); $font['itemDesc'] = array ('family'=>'PalatinoLinotype', 'style'=>'', 'size'=>11); require (FPDF_PATH.'fpdf.php'); $pdf = new FPDF('P', 'in', 'Letter'); $pdf->AddFont('Arial','', 'arial.php'); $pdf->AddFont('ArialBlack','', 'ariblk.php'); $pdf->AddFont('PalatinoLinotype','','pala.php'); $pdf->SetMargins (0, 0, 0); $pdf->SetAutoPageBreak (FALSE); $pdfz = new FPDF('P', 'in', 'Letter'); // sandbox to determine multicell heights $pdfz->AddFont('Arial','', 'arial.php'); $pdfz->AddFont('ArialBlack','', 'ariblk.php'); $pdfz->AddFont('PalatinoLinotype','','pala.php'); $pdf->AddPage(); ////print header //$imgW = 1.375; //$pdf->Image('images/printHeader.jpg', 0.75, $marginT+0.125, 7.0); // //$pdf->SetY(2.2); for ($i=0;$i<=1;$i++) { $pdf->SetY($marginT); foreach ($meals as $meal) { if ($meal['name']=='Dinner') { foreach ($meal['categories'] as $category) { if ($category['name'] == 'Postres') { $pdf->SetX ((4.25*$i)+0.625); setFont ($pdf, 'category'); $pdf->MultiCell (3.0, $font['category']['size']/72, (strtoupper($category['name']).' '.$mainPrice), 0, 'C'); $pdf->SetY($pdf->GetY()+$font['category']['size']/72); foreach ($category['items'] as $keyItem=>$item) { if ($item['special'] <> '1') { if (is_numeric($item['prices'][0]['price'])) { $item['prices'][0]['price'] = str_replace('.00','',sprintf("$%01.2f", floatval($item['prices'][0]['price']))); } setFont ($pdf, 'item'); $pdf->SetX ((4.25*$i)+$layout[$category['name']]['marginLR']); $pdf->Cell($layout[$category['name']]['colW'], ($font['item']['size']+2)/72, $item['name'], 0, 1, 'C'); setFont ($pdf, 'itemDesc'); $pdf->SetX ((4.25*$i)+$layout[$category['name']]['marginLR']); $pdf->MultiCell ($layout[$category['name']]['colW'], ($font['itemDesc']['size']+2)/72, (str_replace("\n",' ',stripslashes($item['desc']))."\n".$item['prices'][0]['price']), 0, 'C'); //$pdf->MultiCell ($layout[$category['name']]['colW'], ($font['itemDesc']['size']+2)/72, (stripslashes($item['desc'])."\n".$item['prices'][0]['price']), 0, 'C'); $pdf->SetY($pdf->GetY()+$font['itemDesc']['size']/72); } } } } } } } $pdf->Output(); function setFont (&$pdf, $class) { global $font; $pdf->SetFont($font[$class]['family'], $font[$class]['style'], $font[$class]['size']); if ($font[$class]['color'] != '') { $pdf->SetTextColor(hexdec(substr($font[$class]['color'],1,2)), hexdec(substr($font[$class]['color'],3,2)), hexdec(substr($font[$class]['color'],5,2))); } else { $pdf->SetTextColor(0); } } function printItem (&$pdf, $item, $x, $colW) { global $font, $i; $y = $pdf->GetY(); setFont ($pdf, 'item'); $pdf->SetX ((4.25*$i)+$x); $pdf->Cell($colW, ($font['item']['size']+2)/72, $item['name']); // leave space in the item description MultiCell for the item name (different font/color) $w1 = $pdf->GetStringWidth(stripslashes($item['name'])); $numSpaces = 0; setFont ($pdf, 'itemDesc'); while ($pdf->GetStringWidth(str_repeat(' ',$numSpaces)) < $w1) { $numSpaces++; } if (is_numeric($item['prices'][0]['price'])) { $item['prices'][0]['price'] = str_replace('.00','',sprintf("$%01.2f", floatval($item['prices'][0]['price']))); } setFont ($pdf, 'itemDesc'); $pdf->SetXY ((4.25*$i)+$x, $y); $pdf->MultiCell ($colW, ($font['itemDesc']['size']+2)/72, (str_repeat(' ',++$numSpaces).str_replace("\n",' ',stripslashes($item['desc'])).' '.$item['prices'][0]['price']), 0, 'L'); $pdf->SetY($pdf->GetY()+$font['itemDesc']['size']/144); return $pdf->GetY(); } /* // Create an AFM file from a TTF require ('includes/fpdf/font/makefont/makefont.php'); MakeFont('includes/fpdf/font/fonts/gothicb.ttf','includes/fpdf/font/fonts/gothicb.afm'); MakeFont('includes/fpdf/font/fonts/gothicbi.ttf','includes/fpdf/font/fonts/gothicbi.afm'); MakeFont('includes/fpdf/font/fonts/gothici.ttf','includes/fpdf/font/fonts/gothici.afm'); */ ?>