Reputation: 1166
i use this tutorial to generate pdf files from html files like
the controller
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Test extends CI_Controller {
function __construct() {
parent::__construct();
}
function index() {
$this->load->library('mpdf');
$this->mpdf = new mPDF('utf-8', 'A4');
$html = $this->load->view("test");
$txt = "hiiiiiiiiiii";
$this->mpdf->WriteHTML($txt , 2);
$this->mpdf->WriteHTML($html , 2);
$this->mpdf->Output('ggg.pdf', 'I');
}
public function ahmed() {
$this->load->view('test');
}
public function fakhr() {
$this->load->view('welcome_message');
}
public function yahoo() {
$this->load->view('welcome_message');
}
}
the problem is , when i pass $html
to WriteHTML()
function it generated a blank pdf and when i pass $txt
variable to the same function printed the text "hiiiii"...
so how to solve this problem any why i cant generate pdf from codeigniter views files..
Upvotes: 0
Views: 1724
Reputation: 19882
You only need to do this
$html = $this->load->view("test",array() , true);
Use third parameter as true so that it returns the view as string
Upvotes: 2