pcrt/yii2-latex

Alternative Gii generator for Yii2 framework

1.0.21 2019-08-27 21:35 UTC

This package is not auto-updated.

Last update: 2024-04-14 19:51:14 UTC


README

Latex2PDF formatter for Yii2 .

This extension "format" Latex responses to PDF files (by default Yii2 includes HTML, JSON and XML formatters). Great for reports in PDF format using Latex views/layouts.

##Installation

The preferred way to install this extension is through composer.

Either run

$ php composer.phar require pcrt/yii2-latex "*"

or add

"pcrt/yii2-pdf": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, modify your application configuration to include:

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 )
 				],
			]
		],
		...
	],
];

For default the buildpath variable is set on your @webroot folder .

In the controller:

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', []);
	}
}

License

Yii2-Latex is released under the BSD-3 License. See the bundled LICENSE.md for details.

Useful URLs

Enjoy!