Last active
August 29, 2015 14:06
-
-
Save zhiephie/f0e0097e7a757c92dfa6 to your computer and use it in GitHub Desktop.
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
============CONTROLLER============== | |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
/** | |
* @author : Yudi Purwanto | |
* @link : http://yudi-purwanto.com | |
* @since : 14 may 2014 | |
*/ | |
class Pdf extends CI_Controller | |
{ | |
function __construct() | |
{ | |
parent::__construct(); | |
session_start(); | |
$this->load->helper(array('dompdf', 'file')); | |
} | |
function generate() | |
{ | |
$slug = $this->uri->segment(3); | |
$idtutorial=''; | |
//$limit = 10; | |
$data1 = $this->frontend_model->generate_detail_tutorial($slug); | |
foreach ($data1->result() as $d) | |
{ | |
$judul = $d->title; | |
} | |
$data['title'] = $judul. " yudi purwanto"; | |
$data['detail'] = $this->frontend_model->generate_detail_tutorial($slug); | |
//$data['popular'] = $this->frontend_model->generate_popular($limit); | |
//$data['random'] = $this->frontend_model->generate_random($idtutorial); | |
//$data['freebie'] = $this->frontend_model->popular_ebook(); | |
//$data['authors'] = $this->db->get('about')->result(); | |
// page info here, db calls, etc. | |
//$this->load->view('frontend/_header',$data); | |
$html = $this->load->view('pdf_message', $data, true); | |
//$this->load->view('frontend/_popular',$data); | |
//$this->load->view('frontend/_footer'); | |
//var_dump($html); | |
pdf_create($html, url_title($data['title']), 'dash', TRUE); | |
} | |
} | |
/* End of file pdf.php */ | |
/* Location: ./application/controller/pdf.php */ | |
===================END=================== | |
=================HELPER================== | |
<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); | |
function pdf_create($html, $filename='', $stream=TRUE) | |
{ | |
require_once("dompdf/dompdf_config.inc.php"); | |
$dompdf = new DOMPDF(); | |
$dompdf->load_html($html); | |
$dompdf->render(); | |
if ($stream) { | |
$dompdf->stream($filename.".pdf"); | |
} else { | |
return $dompdf->output(); | |
} | |
} | |
?> | |
===========END============== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment