PDF T and C concat working

This commit is contained in:
Karl Cordes 2010-03-04 09:23:28 +11:00
parent abeca8a3a9
commit 9fd2507c46
2 changed files with 32 additions and 9 deletions

18
vendors/xtcpdf.php vendored
View file

@ -1,6 +1,8 @@
<?php <?php
App::import('Vendor','tcpdf/tcpdf'); App::import('Vendor','tcpdf/tcpdf');
class XTCPDF extends TCPDF { class XTCPDF extends TCPDF {
var $xheadertext = 'PDF created using CakePHP and TCPDF'; var $xheadertext = 'PDF created using CakePHP and TCPDF';
@ -336,15 +338,21 @@ ENDPRODUCT;
echo "Currently have $heightLeft Comm details height is ".$commDetailsHeight." totals height is: ".$totalsHeight."<br>"; echo "Currently have $heightLeft Comm details height is ".$commDetailsHeight." totals height is: ".$totalsHeight."<br>";
if($heightLeft - ($commDetailsHeight + $totalsHeight) <= 0) {
echo "<br>Need a new page for last item and commercial comments";
if($heightLeft - $totalsHeight <= 0) {
echo "<br>Need a new page for last item and totals";
array_pop($pageProducts[$pagesRequired]); array_pop($pageProducts[$pagesRequired]);
$pagesRequired++; $pagesRequired++;
$heightLeft = $availableHeight; $heightLeft = $availableHeight;
$heightLeft -= $commDetailsHeight; $heightLeft -= $totalsHeight;
$pageProducts[$pagesRequired][] = $product[$docType]['id']; $pageProducts[$pagesRequired][] = $product[$docType]['id'];
} }
if($heightLeft - $commDetailsHeight <= 0) {
$pagesRequired++;
}
debug($pageProducts); debug($pageProducts);
return $pageProducts; return $pageProducts;
@ -380,7 +388,7 @@ ENDPRODUCT;
$subTotal = 0; $subTotal = 0;
print_r($pageProducts);
foreach ($pageProducts as $page) { foreach ($pageProducts as $page) {
$this->AddPage(); $this->AddPage();
@ -416,7 +424,7 @@ ENDPRODUCT;
echo "<h2>$pageNo</h2>"; echo "<h2>$pageNo</h2>";
print_r($page); // print_r($page);
//Start Printing Product cells, until we run out of room. Then continue on the next page //Start Printing Product cells, until we run out of room. Then continue on the next page

View file

@ -3,6 +3,7 @@
$tcpdf = new XTCPDF('P', 'mm', 'A4', true, false, 'UTF-8'); $tcpdf = new XTCPDF('P', 'mm', 'A4', true, false, 'UTF-8');
@ -121,5 +122,19 @@ echo "<br> Wrote: ".$output_dir.$filename;
//$tcpdf->Output('cmcquote.pdf', 'D'); //$tcpdf->Output('cmcquote.pdf', 'D');
App::import('Vendor', 'xfpdi');
//$newpdf = new concat_pdf();
$newpdf = new XFPDI();
$newpdf->SetMargins(2, 2);
$newpdf->setPrintHeader(false);
$newpdf->setPrintFooter(false);
$newpdf->setFiles(array($output_dir.$filename, $output_dir.'CMC_terms_and_conditions2006_A4.pdf'));
$newpdf->concat();
$newpdf->Output($output_dir.$filename, "F");
?> ?>