SetTopMargin(); //$tcpdf->SetLeftMargin(29); //$tcpdf->SetMargins(1, 1); $tcpdf->SetAuthor("CMC Technologies"); $tcpdf->SetTitle("CMC Technologies Quote: ".$quote['Enquiry']['title']); $tcpdf->SetAutoPageBreak( false ); $tcpdf->setHeaderFont(array($textfont,'',40)); $tcpdf->xheadercolor = array(150,0,0); $tcpdf->xheadertext = 'CMC TECHNOLOGIES'; $tcpdf->xfootertext = 'Copyright © %d CMC Technologies. All rights reserved.'; $tcpdf->setPrintHeader(false); $tcpdf->setPrintFooter(false); $page1done = false; //Have we already made the first page? If so, don't show the CMC header/footer foreach ($quote['QuotePage'] as $page) { $tcpdf->AddPage(); if($page1done == false) { $tcpdf->Page1Header(); if( (!$enqury['Enquiry']['customer_reference']) || ($enquiry['Enquiry']['customer_refernece'] == '') ) { $enquiry_date = date('d/m/Y',$time->toUnix($enquiry['Enquiry']['created'])); $enquiry['Enquiry']['customer_reference'] = "Enquiry on $enquiry_date"; } if ($quote['Quote']['revision'] > 0) { $cmcRef = $enquiry['Enquiry']['title'].' rev '.$quote['Quote']['revision']; } else { $cmcRef = $enquiry['Enquiry']['title']; } $tcpdf->DetailsBox($enquiry['Customer']['name'], $enquiry['Contact']['email'], $enquiry['Contact']['first_name'].' '.$enquiry['Contact']['last_name'], $enquiry['User']['first_name'].' '.$enquiry['User']['last_name'], $enquiry['User']['email'], $cmcRef, $enquiry['Enquiry']['customer_reference']); } else { $tcpdf->continuedHeader($enquiry['Enquiry']['title']); } $currentX = $tcpdf->GetX(); $currentY = $tcpdf->GetY(); $tcpdf->SetTextColor(0); $tcpdf->SetFont('times', '', 12); $tcpdf->writeHTMLCell(0, 0, $currentX, $currentY+5, $page['content'], 'LTRB', 1, 0, true, 'L', true); /* Only show the footer if it's the first page */ if($page1done == false) { $tcpdf->Page1Footer(); $page1done = true; } } //DetailsBox($companyName, $emailTo, $attention, $fromName, $fromEmail, $enquiryNumber) $tcpdf->AliasNbPages(); $tcpdf->lastPage(); $output_dir = '/var/www/cake/app/webroot/pdf/'; if($quote['Quote']['revision'] > 0) { $filename = $enquiry['Enquiry']['title'].'rev'.$quote['Quote']['revision'].'.pdf'; } else { $filename = $enquiry['Enquiry']['title'].'.pdf'; } $tcpdf->Output($output_dir.$filename, 'F'); //$tcpdf->Output('cmcquote.pdf', 'D'); ?>