Last active
February 19, 2017 14:38
-
-
Save ardianta/f4bfa696ca9a040677e87f2cde4d5887 to your computer and use it in GitHub Desktop.
Codeigniter Dompdf library
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php defined('BASEPATH') OR exit('No direct script access allowed'); | |
| /** | |
| * CodeIgniter DomPDF Library | |
| * | |
| * Generate PDF's from HTML in CodeIgniter | |
| * | |
| * @packge CodeIgniter | |
| * @subpackage Libraries | |
| * @category Libraries | |
| * @author Ardianta Pargo | |
| * @license MIT License | |
| * @link https://github.com/ardianta/codeigniter-dompdf | |
| */ | |
| use Dompdf\Dompdf; | |
| class Pdf extends Dompdf{ | |
| /** | |
| * PDF filename | |
| * @var String | |
| */ | |
| public $filename; | |
| public function __construct(){ | |
| parent::__construct(); | |
| $this->filename = "laporan.pdf"; | |
| } | |
| /** | |
| * Get an instance of CodeIgniter | |
| * | |
| * @access protected | |
| * @return void | |
| */ | |
| protected function ci() | |
| { | |
| return get_instance(); | |
| } | |
| /** | |
| * Load a CodeIgniter view into domPDF | |
| * | |
| * @access public | |
| * @param string $view The view to load | |
| * @param array $data The view data | |
| * @return void | |
| */ | |
| public function load_view($view, $data = array()){ | |
| $html = $this->ci()->load->view($view, $data, TRUE); | |
| $this->load_html($html); | |
| // Render the PDF | |
| $this->render(); | |
| // Output the generated PDF to Browser | |
| $this->stream($this->filename, array("Attachment" => false)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment