skytrex / ci-dompdf
This package for all codeigniter user who is using composer to install dependecies dompdf
v0.0.4
2019-10-25 08:45 UTC
Requires
- php: >=5.4.0
- ext-dom: *
- ext-mbstring: *
- phenx/php-font-lib: 0.5.*
- phenx/php-svg-lib: 0.3.*
Requires (Dev)
- phpunit/phpunit: ^4.8|^5.5|^6.5
- squizlabs/php_codesniffer: 2.*
This package is auto-updated.
Last update: 2025-02-26 02:46:21 UTC
README
How to install
composer require skytrex/ci-dompdf 0.0.4
versioning is depends on the release
How to use this with Codeigniter 3.
1. Create a pdf.php file in folder application/libraries/pdf.php.
<?php defined('BASEPATH') OR exit('No direct script access allowed'); require_once("./vendor/skytrex/ci-dompdf/autoload.inc.php"); use Dompdf\Dompdf; class pdf { public function generate($html, $filename='', $stream=TRUE, $paper = 'A4', $orientation = "portrait") { $dompdf = new DOMPDF(); $dompdf->loadHtml($html); $dompdf->setPaper($paper, $orientation); $dompdf->render(); if ($stream) { $dompdf->stream($filename.".pdf", array("Attachment" => 0)); } else { return $dompdf->output(); } } }
2. Add pdf.php to your application/autoload and add file to your helper.
$autoload['libraries'] = array('pdf'); $autoload['helper'] = array('file');
3. Change composer autoload in config.php to below.
$config['composer_autoload'] = FCPATH .'vendor/autoload.php';