- cDownload dompf from here and exstract the file.
- Then put to the directory ./system/application/plugins/.
- After that then create new file on ./system/application/plugins/dompdf_pi.php like this
- Create controler mypdf.php
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
/**
* Try increasing memory available, mostly for PDF generation
*/
ini_set("memory_limit", "32M");
function pdf_create($html, $filename, $stream=TRUE, $orientation="portrait") {
require_once(BASEPATH . "application/plugins/dompdf/dompdf_config.inc.php");
$dompdf = new DOMPDF();
$dompdf->set_paper("a4", $orientation);
$dompdf->load_html($html);
$dompdf->render();
if ($stream) { //open only
$dompdf->stream($filename . ".pdf");
} else { // save to file only, your going to load the file helper for this one
write_file("pdf/$filename.pdf", $dompdf->output());
}
}
?>
<?php /** * @property CI_DB_active_record $db */ class mypdf extends MY_Controller { function mypdf() { parent::MY_Controller(); $this->load->plugins('dompdf_pi'); } function index() { $html="Hello Word"; $filename="Mypdf"; pdf_create($html, $filename, $stream=TRUE, $orientation='portrait'); } } ?>
1 comments:
is it working?
Post a Comment