pcrt / yii2-latex
Yii2框架的替代Gii生成器
1.0.21
2019-08-27 21:35 UTC
Requires
- php: >=5.6.0
- symfony/process: >=4.3
- yiisoft/yii2: >2.0.0
README
Yii2 .的Latex2PDF格式化器。
此扩展可以将Latex响应格式化为PDF文件(默认情况下Yii2包括HTML、JSON和XML格式化器)。非常适合使用Latex视图/布局的PDF格式报告。
##安装
安装此扩展的首选方法是通过 composer。
运行以下命令之一
$ php composer.phar require pcrt/yii2-latex "*"
或者在您的 composer.json
文件的require部分中添加以下内容。
"pcrt/yii2-pdf": "*"
使用方法
安装扩展后,修改您的应用程序配置以包含以下内容
return [ 'components' => [ ... 'response' => [ 'formatters' => [ 'pdf' => [ 'class' => 'pcrt\latex\Latex2PdfResponseFormatter', 'latexbin' => '/usr/local/bin/pdflatex', 'buildpath' => '/folder/you/prefer' // for default use current folder 'keepfile' => false // if true not clean debug file ( debug purpose only ) ], ] ], ... ], ];
默认情况下,buildpath变量设置在您的 @webroot 文件夹中。
在控制器中
class MyController extends Controller { public function actionPdf(){ Yii::$app->response->format = 'latex'; $this->layout = '//print'; // A siple template without any html code return $this->render('myview', []); } }
许可证
Yii2-Latex是在BSD-3许可证下发布的。有关详细信息,请参阅附带的 LICENSE.md
文件。
有用的URL
祝您使用愉快!