PDF Generation coming along nicely

This commit is contained in:
Karl Cordes 2009-10-09 16:07:50 +11:00
parent 83ef2e0b2a
commit 60e569cddc
6 changed files with 119 additions and 8 deletions

BIN
vendors/tcpdf/images/cmclogo.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
vendors/tcpdf/images/cmclogosmall.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

44
vendors/xtcpdf.php vendored
View file

@ -23,14 +23,43 @@ class XTCPDF extends TCPDF
function Header()
{
list($r, $b, $g) = $this->xheadercolor;
//$this->setY(10); // shouldn't be needed due to page margin, but helas, otherwise it's at the page top
//$this->Image(K_PATH_IMAGES.'cmcheader.jpg');
$this->SetFillColor(255, 255, 255);
$this->SetTextColor(0 , 0, 152);
$this->SetTextColor(0 , 0, 152); //Set the Text Color to Blue
$this->Image(K_PATH_IMAGES.'cmclogosmall.jpg', 2, 0, 30, 0, null, 'http://www.cmctechnologies.com.au', null, false, null, 'L');
$this->Cell(30);
$this->SetFont('times', 'B');
$this->Cell(0,0, $this->xheadertext, 0,1,'C', 1);
//$this->Text(15,26,$this->xheadertext );
$this->SetFontSize(10);
$this->Cell(30);
$this->Cell(0,0, "PTY LIMITED ACN: 47 085 991 224, ABN 47 085 991 224", 0, 1, 'C', 1);
/* Start the contact details */
$this->SetTextColor(0); //Set the Text Color to Black
$this->MultiCell(18, 0, "Phone:\nFax:\nEmail:\nWeb Site:\n", 0, 'L', 0, 0, 45, 23);
$this->MultiCell(50, 0, "+61 2 9669 4000<br>+61 2 9669 4111<br><a href=\"mailto:sales@cmctechnologies.com.au\">sales@cmctechnologies.com.au</a>
<br><a href=\"http://www.cmctechnologies.com.au\">www.cmctechnologies.com.au</a><br>", 0, 'L', 0, 0, 65, null, true, 0, true);
$this->MultiCell(50, 0, "Unit 19, 77 Bourke Rd\nAlexandria\nNSW 2015\nAUSTRALIA\n", 0, 'L', 0, 0, 150, null);
$this->SetTextColor(0 , 0, 152); //Set the Text Color to Blue
$this->SetFont('times', 'B');
$this->MultiCell(30, 20, "Engineering &\nIndustrial\nInstrumentation", 0, 'L', 0, 1, 2,28);
}
/**
@ -46,6 +75,15 @@ class XTCPDF extends TCPDF
$this->SetTextColor(0, 0, 0);
$this->SetFont($this->xfooterfont,'',$this->xfooterfontsize);
$this->Cell(0,8, $footertext,'T',1,'C');
}
/**
* For Quotes and (hopefully) Invoices. Identifies who the document is for, date, reference number, etc.
*/
function DetailsBox($companyName, $emailTo, $attention, $fromName, $fromEmail, $enquiryNumber) {
}
}
?>

View file

@ -6,6 +6,7 @@ $textfont = 'freeserif'; // looks better, finer, and more condensed than 'dejavu
$tcpdf->SetTopMargin(0);
$tcpdf->SetAuthor("CMC Technologies");
$tcpdf->SetTitle("CMC Technologies Quote");
$tcpdf->SetAutoPageBreak( false );
$tcpdf->setHeaderFont(array($textfont,'',40));
$tcpdf->xheadercolor = array(150,0,0);
@ -16,13 +17,85 @@ $tcpdf->Header();
// Now you position and print your page content
// example:
$tcpdf->SetTextColor(0, 0, 0);
/*$tcpdf->SetTextColor(0, 0, 0);
$tcpdf->SetFont($textfont,'B',20);
$tcpdf->Cell(0,14, "Hello World", 0,1,'L');
// ...
// etc.
// see the TCPDF examples
*/
echo $tcpdf->Output('/var/www/quotenik1.2/app/webroot/pdf/filename1.pdf', 'F');
$tcpdf->AddPage();
$content = <<<ENDCONTENT
<p>
Dear Bill,</p>
<p style="text-align: center;">
<br />
<strong>RE: Awesome Products</strong></p>
<p>
Thank you for your enquiry regarding our Products. Please see the following quotation for:</p>
<table align="center" border="0" cellpadding="1" cellspacing="1" style="width: 100%;">
<tbody>
<tr>
<td>
Item</td>
<td>
Product</td>
</tr>
<tr>
<td>
&nbsp;</td>
<td>
&nbsp;</td>
</tr>
<tr>
<td>
&nbsp;</td>
<td>
&nbsp;</td>
</tr>
</tbody>
</table>
<p>
&nbsp;</p>
<p>
Regards,</p>
<p>
<br />
Sales Engineer</p>
<p>
&nbsp;</p>
<p>
Attachments:</p>
<p>
<em>attachment1.pdf </em><br />
<em>attachment2.pdf</em></p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
&nbsp;</p>
<p>
<em>SOMEONE</em></p>
ENDCONTENT;
$tcpdf->SetTextColor(0);
$tcpdf->writeHTMLCell(0, 0, $currentX, 50, $content, 'LTRB', 1, 0, true, 'L', true);
$tcpdf->lastPage();
$tcpdf->AddPage();
//$tcpdf->writeHTML($content, true, 0, true, 0);
$tcpdf->lastPage();
$tcpdf->Output('/var/www/cake/app/webroot/pdf/filename1.pdf', 'F');
?>

0
webroot/pdf/filename.pdf Normal file → Executable file
View file

BIN
webroot/pdf/filename1.pdf Normal file → Executable file

Binary file not shown.