Exemple #1
0
 public function action_pdf($order_id = false)
 {
     if (!($order = \Order\Model_Order::find_one_by_id($order_id))) {
         \Messages::error('There was an error while trying to create PDF for order ID: ' . $order_id);
         \Response::redirect(\Input::referrer(\Uri::create('admin/order/list')));
     }
     $pdf = \Pdf\Pdf::forge('tcpdf')->init('P', 'mm', 'A4', true, 'UTF-8', false);
     // set document information
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetAuthor('Cool Kids Rooms');
     $pdf->SetTitle('Invoice');
     $pdf->SetSubject('Invoice');
     //$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
     // remove default header/footer
     $pdf->setPrintHeader(false);
     $pdf->setPrintFooter(false);
     // set default monospaced font
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // set margins
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     // set auto page breaks
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     // set image scale factor
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // set font
     //$pdf->SetFont('times', 'BI', 20);
     // add a page
     $pdf->AddPage();
     // ---------------------------------------------------------
     $content['content']['data'] = $order;
     $html = \Theme::instance()->view($this->view_dir . 'invoice/order', $content, false);
     // output the HTML content
     $pdf->writeHTML($html, true, false, true, false, '');
     // ---------------------------------------------------------
     //Close and output PDF document
     $pdf->Output('Invoice Order ' . $order_id . '.pdf', 'I');
 }
Exemple #2
0
 /**
  * Construct for the class.
  * 
  * @access protected
  * @param int $clientID
  * @param array $options
  * @return object
  *
  * @author Simon Skinner <*****@*****.**>
  */
 protected function __construct($clientID, $options, $extraData)
 {
     $this->_clientID = $clientID;
     $this->_extraData = $extraData;
     $this->_clientDetails = \Crm\ClientClass::forge($clientID);
     $this->_pdfInstance = \Pdf\Pdf::forge('mpdf')->init();
     return $this;
 }