diff --git a/.gitignore b/.gitignore index 05ad729598d1..7f41a3e06b62 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ nbproject .php_cs.cache public/test.pdf +public/storage/test.pdf diff --git a/app/Http/Controllers/SetupController.php b/app/Http/Controllers/SetupController.php index 37e525bfc8df..8f4f1e3ef711 100644 --- a/app/Http/Controllers/SetupController.php +++ b/app/Http/Controllers/SetupController.php @@ -21,6 +21,7 @@ use App\Models\Account; use App\Utils\CurlUtils; use App\Utils\SystemHealth; use App\Utils\Traits\AppSetup; +use Beganovich\ChromiumPdf\ChromiumPdf; use DB; use Exception; use Illuminate\Contracts\Foundation\Application; @@ -227,15 +228,26 @@ class SetupController extends Controller return $this->testPhantom(); } - Browsershot::html('GENERATING PDFs WORKS! Thank you for using Invoice Ninja!') - ->setNodeBinary(config('ninja.system.node_path')) - ->setNpmBinary(config('ninja.system.npm_path')) - ->noSandbox() - ->savePdf( - public_path('test.pdf') - ); + if (config('ninja.experimental_pdf_engine')) { + $chromium_pdf = new ChromiumPdf(); - return response(['url' => asset('test.pdf')], 200); + $pdf = $chromium_pdf + ->setChromiumPath(config('ninja.experimental_pdf_engine_chromium_path')) + ->setHtml('GENERATING PDFs WORKS! Thank you for using Invoice Ninja!') + ->generate(); + + Storage::put('public/test.pdf', $pdf); + } else { + Browsershot::html('GENERATING PDFs WORKS! Thank you for using Invoice Ninja!') + ->setNodeBinary(config('ninja.system.node_path')) + ->setNpmBinary(config('ninja.system.npm_path')) + ->noSandbox() + ->savePdf( + public_path('storage/test.pdf') + ); + } + + return response(['url' => asset('storage/test.pdf')], 200); } catch (Exception $e) { info($e->getMessage());