Changing PDF product table output. hopefully it will suck less

This commit is contained in:
Karl Cordes 2009-11-19 12:09:56 +11:00
parent 7f08e9e53b
commit 40f30519ab
2 changed files with 26 additions and 13 deletions

37
vendors/xtcpdf.php vendored
View file

@ -164,7 +164,7 @@ class XTCPDF extends TCPDF {
$this->SetFontSize(10);
$lineHeight = 8; //Size of a single line of text. If the company name is more, multiply this by the number of lines it needs
$lineHeight = 5; //Size of a single line of text. If the company name is more, multiply this by the number of lines it needs
@ -179,13 +179,17 @@ class XTCPDF extends TCPDF {
//$heightNeeded = $this->getNumLines("ITEM\NO.", $itemColwidth);
//echo "HEADER ROW HEIGHT IS $heightNeeded";
/* Need to work out how many Pages the Product Table will need to be split over */
echo "Product Page height is: ".$this->getPageHeight();
//Draw Header Rows
$pageNo = $this->PageNoFormatted();
$this->MultiCell(0, 0, "PRICING & SPECIFICATIONS (PAGE $pageNo OF {nb})", 0, "C", 0, 1);
$this->MultiCell($itemColwidth, 0, "ITEM\nNO.", 1, "C", 1, 0);
$heightNeeded = $this->getLastH();
@ -209,24 +213,33 @@ class XTCPDF extends TCPDF {
$this->MultiCell($unitpriceColwidth, $heightNeeded, $currency, 1, "C", 1, 0);
$this->MultiCell($totalPricColwidth, $heightNeeded, $currency, 1, "C", 1, 1);
foreach ($products as $product) {
//Need to use the getNumLines method to figure out how big to make the cells before the description cell
$fullDesc = $product[$docType]['title'].'<br>'.$product[$docType]['description'];
$fullDesc = "<b>".$product[$docType]['title'].'</b><br>'.$product[$docType]['description'];
$linesNeeded = $this->getNumLines($fullDesc, $descColwidth);
echo "<br>";
echo $product[$docType]['title']." needs $linesNeeded so approx ".$linesNeeded*$lineHeight." mm <br>";
$this->MultiCell($itemColwidth, $linesNeeded*$lineHeight, number_format($product[$docType]['item_number'], 1, '.', ''), 1, "C", 0, 0);
$this->MultiCell($qtyColwidth, $linesNeeded*$lineHeight, $product[$docType]['quantity'], 1, "C", 0, 0);
$quoteProduct['QuoteProduct']['item_number'];
$this->MultiCell($descColwidth, $linesNeeded*$lineHeight, $fullDesc, 1, "L", 0, 0, null, null, true, 0, true);
$mmNeeded = $linesNeeded*$lineHeight;
$this->MultiCell($itemColwidth, $mmNeeded, number_format($product[$docType]['item_number'], 1, '.', ''), 1, "C", 0, 0);
$this->MultiCell($qtyColwidth, $mmNeeded, $product[$docType]['quantity'], 1, "C", 0, 0);
$this->MultiCell($descColwidth, $mmNeeded, $fullDesc, 1, "L", 0, 0, null, null, true, 0, true);
$this->MultiCell($unitpriceColwidth, $mmNeeded, "$1000", 1, "C", 0, 0);
$this->MultiCell($totalPricColwidth, $mmNeeded, "$2000", 1, "C", 0, 1);
$this->MultiCell($unitpriceColwidth, $linesNeeded*$lineHeight, "$1000", 1, "C", 0, 0);
$this->MultiCell($totalPricColwidth, $linesNeeded*$lineHeight, "$2000", 1, "C", 0, 1);
}

View file

@ -6,7 +6,7 @@
//print_r($enquiry);
$tcpdf = new XTCPDF();
$tcpdf = new XTCPDF('P', 'mm', 'A4', true, false, 'UTF-8');
$textfont = 'times'; // looks better, finer, and more condensed than 'dejavusans'