Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hanishsingla/mpdf-wrapper
https://github.com/hanishsingla/mpdf-wrapper
mpdf symfony symfony-bundle symfony2 symfony3 wrapper
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/hanishsingla/mpdf-wrapper
- Owner: hanishsingla
- License: mit
- Created: 2017-03-28T05:49:59.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-03-27T12:11:54.000Z (almost 6 years ago)
- Last Synced: 2024-11-15T21:07:32.854Z (about 2 months ago)
- Topics: mpdf, symfony, symfony-bundle, symfony2, symfony3, wrapper
- Language: PHP
- Size: 18.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mpdf-wrapper
This bundle provides a service for mpdf library with symfony 4.
### 1.1 Download MpdfWrapperBundle using composer
Run in terminal:
```bash
$ php composer.phar require symfgenus/mpdf-wrapper
```Symfony flex activates the bundles automatically. If it is not, then enable the bundle:
```php
// /config/bundles.php[
// ...
Symfgenus\MpdfWrapper\MpdfWrapperBundle::class => ['all' => true],
];
```MpdfService provides many ways to use MPDF.
### 2.1 It can generate a direct pdf response which can be served through any route.
```php
// /config/bundles.phppublic function index(MpdfService $MpdfService)
{
return $MpdfService->generatePdfResponse($pdfHtml);
}
```### 2.2 It can also generate pdf content which can be saved in a variable and used.
```php
// /config/bundles.phppublic function index(MpdfService $MpdfService)
{
return $pdf = $MpdfService->generatePdf($pdfHtml);
}
```### 2.3 Sometimes there is need to create multiple PDFs, MpdfService can be used as following:
```php
// /config/bundles.phppublic function index(MpdfService $MpdfService)
{
$firstPdf = $MpdfService->getMpdf($argsFirst);
$mpdf->WriteHTML($htmlFirst);
$firstPdfFile = $mpdf->Output();$secondPdf = $MpdfService->getMpdf($argsSecond);
$mpdf->WriteHTML($htmlSecond);
$secondPdfFile = $mpdf->Output();return [
$firstPdfFile,
$secondPdfFile
];
}
```For symfony 3, this service can be loaded as following:
```php
$this->get('symfgenus.mpdf.wrapper').
```