skytrex / ci-dompdf
此包适用于所有使用composer安装依赖项dompdf的Codeigniter用户
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: 2024-09-26 01:50:45 UTC
README
如何安装
composer require skytrex/ci-dompdf 0.0.4
版本取决于发布
如何使用Codeigniter 3
1. 在文件夹 application/libraries/pdf.php 中创建一个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. 将pdf.php添加到您的 application/autoload 中,并将其添加到您的辅助文件中。
$autoload['libraries'] = array('pdf'); $autoload['helper'] = array('file');
3. 将 config.php 中的 composer autoload 修改为以下内容。
$config['composer_autoload'] = FCPATH .'vendor/autoload.php';