mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-15 17:24:10 +00:00
Split PDFService.php (3 classes + 2 interfaces in one file) into separate files. Move GotenbergPDFDriver from app/Services/PDFDrivers/ into app/Services/Pdf/. Normalize casing from ALL-CAPS PDF to Pdf throughout: facade, provider, service, driver factory, and Gotenberg driver. Fix PaymentService using Barryvdh DomPDF facade directly instead of the app's PDF facade (bypassed the driver factory). Report controllers also updated to use the app facade.
33 lines
892 B
PHP
33 lines
892 B
PHP
<?php
|
|
|
|
namespace App\Services\Pdf;
|
|
|
|
use Gotenberg\Gotenberg;
|
|
use Gotenberg\Stream;
|
|
|
|
class GotenbergPdfDriver
|
|
{
|
|
public function loadView(string $viewname): GotenbergPdfResponse
|
|
{
|
|
$papersize = explode(' ', config('pdf.connections.gotenberg.papersize'));
|
|
if (count($papersize) != 2) {
|
|
throw new \InvalidArgumentException('Invalid Gotenberg Papersize specified');
|
|
}
|
|
|
|
$host = config('pdf.connections.gotenberg.host');
|
|
$request = Gotenberg::chromium($host)
|
|
->pdf()
|
|
->margins(0, 0, 0, 0)
|
|
->paperSize($papersize[0], $papersize[1])
|
|
->html(
|
|
Stream::string(
|
|
'document.html',
|
|
view($viewname)->render(),
|
|
)
|
|
);
|
|
$result = Gotenberg::send($request);
|
|
|
|
return new GotenbergPdfResponse($result);
|
|
}
|
|
}
|