Feat(Gotenberg): Opt-in alternative pdf generation for modern CSS (#184)

* WIP(gotenberg): add pdf generation abstraction and UI

* feat(pdf): settings validate(clien+server) & save

* fix(gotenberg): Use correct default papersize
chore(gotengberg): Remove unused GOTENBERG_MARGINS env from .env

* style(gotenberg): fix linter/styling issues

* fix(pdf): use pdf config policy

* fix: revert accidental capitalization in mail config vue

* Update composer, remove whitespace typo

* Fix small typos

* fix cookie/env issue

* Add gotenberg to .dev, move admin menu item up
This commit is contained in:
Tim van Osch
2025-05-04 02:10:15 +02:00
committed by GitHub
parent 8a9392e400
commit bf40f792c2
27 changed files with 1512 additions and 597 deletions

View File

@@ -0,0 +1,54 @@
<?php
namespace App\Http\Controllers\V1\Admin\Settings;
use App\Http\Controllers\Controller;
use App\Http\Requests\PDFConfigurationRequest;
use App\Space\EnvironmentManager;
class PDFConfigurationController extends Controller
{
/**
* @var EnvironmentManager
*/
protected $environmentManager;
public function __construct(EnvironmentManager $environmentManager)
{
$this->environmentManager = $environmentManager;
}
public function getDrivers()
{
$this->authorize('manage pdf config');
$drivers = [
'dompdf',
'gotenberg',
];
return response()->json($drivers);
}
public function getEnvironment()
{
$this->authorize('manage pdf config');
$config = [
'pdf_driver' => config('pdf.driver'),
'gotenberg_host' => config('pdf.gotenberg.host'),
'gotenberg_margins' => config('pdf.gotenberg.margins'),
'gotenberg_papersize' => config('pdf.gotenberg.papersize'),
];
return response()->json($config);
}
public function saveEnvironment(PDFConfigurationRequest $request)
{
$this->authorize('manage pdf config');
$results = $this->environmentManager->savePDFVariables($request);
return response()->json($results);
}
}