Created
June 19, 2016 04:46
-
-
Save FachrulCH/9ed0448c72fe2bc0f3aa27336f796c5b to your computer and use it in GitHub Desktop.
cetak laporan dengan DOMPDF
This file contains 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 if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
/** | |
* Name: DOMPDF | |
* | |
* Author: Jd Fiscus | |
* jdfiscus@gmail.com | |
* @iamfiscus | |
* | |
* | |
* Origin API Class: http://code.google.com/p/dompdf/ | |
* | |
* Location: http://github.com/iamfiscus/Codeigniter-DOMPDF/ | |
* | |
* Created: 06.22.2010 | |
* | |
* Description: This is a Codeigniter library which allows you to convert HTML to PDF with the DOMPDF library | |
* | |
*/ | |
// \application\libraries\Dompdf_gen.php | |
class Dompdf_gen { | |
public function __construct() { | |
require_once APPPATH.'third_party/dompdf_old/dompdf_config.inc.php'; // @version 0.5.1.htischer.20090507 | |
$pdf = new DOMPDF(); | |
$CI =& get_instance(); | |
$CI->dompdf = $pdf; | |
} | |
} |
This file contains 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 | |
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
/** | |
* \application\controllers\Report.php | |
* | |
* @author kurawall | |
*/ | |
if (!defined('BASEPATH')) | |
exit('No direct script access allowed'); | |
class Report extends CI_Controller { | |
//put your code here | |
public function __construct() { | |
parent::__construct(); | |
$this->load->helper(array('form')); | |
} | |
public function tescetak() { | |
// $nama = "test"; | |
$html2 = '<html><body><h1>Hallow semua lagi</h1></body></html>'; | |
$html = file_get_contents("http://localhost/PRJ/lg/report/incoming?startdate=2016-06-01&enddate=2016-06-08"); | |
$this->load->library('dompdf_gen'); | |
// Convert to PDF | |
$this->dompdf->load_html($html); | |
$this->dompdf->set_paper('A4', 'landscape'); | |
$this->dompdf->render(); | |
//utk menampilkan preview pdf | |
//$this->dompdf->stream("report_incoming". str_replace("-", "", $data['get_data']['startdate'])."_".str_replace("-", "", $data['get_data']['enddate']).".pdf", array('Attachment' => 0)); | |
$this->dompdf->stream("report_incoming.pdf", array('Attachment' => 0)); | |
} | |
public function cetak() { | |
$this->load->view('report/sample'); | |
// $this->load->view('contents/pg-customer-service'); | |
//$this->load->view('design/footer'); | |
$html = $this->output->get_output(); | |
// Load/panggil library dompdfnya | |
$this->load->library('dompdf_gen'); | |
// Convert to PDF | |
$this->dompdf->load_html($html); | |
// $this->dompdf->set_base_path(realpath(APPPATH . '/assets/bootstrap/css/bootstrap.min.css')); | |
$this->dompdf->set_paper('A4', 'landscape'); | |
$this->dompdf->render(); | |
//utk menampilkan preview pdf | |
$this->dompdf->stream("ujicoba.pdf", array('Attachment' => 0)); | |
//atau jika tidak ingin menampilkan (tanpa) preview di halaman browser | |
//$this->dompdf->stream("welcome.pdf"); | |
} | |
} |
This file contains 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
<!--Views/report/sample.php--> | |
<html> | |
<body> | |
<h1>Nah kalo ini dari view</h1> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment