Here’s what BambooInvoice uses
function pdf()
{
$this->load->plugin('to_pdf');
$this->load->model('settings_model', '', TRUE);
$this->load->helper('typography');
$data['pageTitle'] = 'invoice';
$id = (int) $this->uri->segment(3);
$invoiceInfo = $this->invoices_model->getSingleInvoice($id);
if ($invoiceInfo->num_rows() == 0) {redirect('invoices/', 'location');}
$data['row'] = $this->invoices_model->getSingleInvoice($id)->row();
$data['companyInfo'] = $this->settings_model->getCompanyInfo()->row();
$html = $this->load->view('invoices/pdf', $data, true);
pdf_create($html, 'invoice_'.$data['row']->invoiceNumber);
}
and the view
<?php
/*
*
* This file is essentially a stripped down version of /views/invoices/view.php
* Any changes you make to that formatting, you may consider adding to this.
*
*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>BambooInvoice:
<?= $pageTitle;?>
</title>
<style type="text/css">
/*
* Invoice view styles notes
*
* This file NEEDS a locally located stylesheet to generate the appropriate formatting for
* transformation into a PDF. If you alter this file (and you are encouraged to do so) just
* keep in mind that all of your formatting must be located here. You might also find that
* there is limited or no support for a specific CSS style you want (ie: floating) and you'll
* need to work around with old-school tables. Sorry for that... ;)
*
*/
body {
margin: 0.5in;
}
h1, h2, h3, h4, h5, h6, li, blockquote, p, th, td {
font-family: Helvetica, Arial, Verdana, sans-serif; /*Trebuchet MS,*/
}
h1, h2, h3, h4 {
color: #5E88B6;
font-weight: normal;
}
h4, h5, h6 {
color: #5E88B6;
}
h2 {
margin: 0 auto auto auto;
font-size: x-large;
}
h3 {
border-top: 1px solid #CCC;
}
li, blockquote, p, th, td {
font-size: 80%;
}
ul {
list-style: url(/img/bullet.gif) none;
}
#footer {
border-top: 1px solid #CCC;
text-align: right;
}
</style>
</head>
<body>
<table width="100%">
<tr>
<td width="60%"><p><strong>Invoice <?= $row->invoiceNumber;?></strong><br />
<strong><?= date('F d, Y', mysql_to_unix($row->dateIssued));?></strong></p>
</td>
<td><h2><img src="<?=base_url();?>img/logo/logo.jpg" alt="<?= $companyInfo->companyName;?>" /></h2>
<p>
<?= $companyInfo->address1;?>
<?php if ($companyInfo->address2 != '') {echo ', ' . $companyInfo->address2;}?><br />
<?= $companyInfo->city;?>,
<?= $companyInfo->province;?>,
<?= $companyInfo->country;?>
<?= $companyInfo->postalCode;?><br />
<?= auto_link(prep_url($companyInfo->website));?>
</p>
</td>
</tr>
</table>
<h3>Bill to
<?= $row->name;?>
</h3>
<p>
<?= $row->address1;?>
<?php if ($row->address2 != '') {echo ', ' . $row->address2;}?>
<br />
<?= $row->city;?>,
<?= $row->province;?>,
<?= $row->country;?>
<?= $row->postalCode;?><br />
<?= auto_link(prep_url($row->website));?>
</p>
<h4>Description of Work</h4>
<?= auto_typography($row->workDescription);?>
<p>Amount: $
<?= $row->amount;?>
<?php
if ($row->tax1_rate != 0) {
echo '<br />' . $row->tax1_desc." (" . $row->tax1_rate . "%): $". number_format(($row->amount*$row->tax1_rate)/100, 2, '.', '');
}
if ($row->tax2_rate != 0) {
echo '<br />' . $row->tax2_desc." (" . $row->tax2_rate . "%): $". number_format(($row->amount*$row->tax2_rate)/100, 2, '.', '') ;
}
if ($row->tax1_rate == 0 && $row->tax2_rate == 0) {
echo '<br /><em>(' . $row->name . " is tax exempt.)</em>";
}
?>
<br />
Total: $
<?= number_format((($row->amount*$row->tax1_rate)/100)+(($row->amount*$row->tax2_rate)/100)+$row->amount, 2, '.', '') ;?>
</p>
<p><strong>Payment Terms:
<?= $row->paymentTerm;?>
</strong></p>
<p>
<?= $row->invoiceNote;?>
</p>
<div id="footer">
<p>Generated by
<?php $this->load->view('includes/logo.inc.php');?>
- <a href="http://www.bambooinvoice.org/">http://www.bambooinvoice.org</a></p>
</div>
</body>
</html>