2020-02-19 21:44:12 +01:00
|
|
|
<?php
|
2020-12-21 16:32:04 +01:00
|
|
|
|
2020-03-18 10:40:15 +01:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2020-03-18 10:40:15 +01:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2021-01-03 22:54:54 +01:00
|
|
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
2020-03-18 10:40:15 +01:00
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
2020-02-19 21:44:12 +01:00
|
|
|
|
|
|
|
namespace App\Utils\Traits\Pdf;
|
|
|
|
|
2020-12-21 16:32:04 +01:00
|
|
|
use Beganovich\Snappdf\Snappdf;
|
2020-02-19 21:44:12 +01:00
|
|
|
|
|
|
|
trait PdfMaker
|
|
|
|
{
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Returns a PDF stream.
|
2020-02-19 21:44:12 +01:00
|
|
|
*
|
|
|
|
* @param string $header Header to be included in PDF
|
|
|
|
* @param string $footer Footer to be included in PDF
|
|
|
|
* @param string $html The HTML object to be converted into PDF
|
|
|
|
*
|
|
|
|
* @return string The PDF string
|
|
|
|
*/
|
2020-03-21 06:37:30 +01:00
|
|
|
public function makePdf($header, $footer, $html)
|
|
|
|
{
|
2020-12-21 16:32:04 +01:00
|
|
|
$pdf = new Snappdf();
|
2020-07-01 00:29:05 +02:00
|
|
|
|
2020-12-25 14:15:57 +01:00
|
|
|
if (config('ninja.snappdf_chromium_path')) {
|
|
|
|
$pdf->setChromiumPath(config('ninja.snappdf_chromium_path'));
|
|
|
|
}
|
|
|
|
|
2020-12-21 16:32:04 +01:00
|
|
|
return $pdf
|
|
|
|
->setHtml($html)
|
|
|
|
->generate();
|
2020-07-01 00:29:05 +02:00
|
|
|
}
|
|
|
|
}
|