Enable support for ChromiumPdf on setup

Add test.pdf to .gitignore
This commit is contained in:
Benjamin Beganović 2020-12-16 12:51:41 +01:00
parent e6419085b2
commit 9f4481d35f
2 changed files with 21 additions and 8 deletions

1
.gitignore vendored
View File

@ -28,3 +28,4 @@ nbproject
.php_cs.cache
public/test.pdf
public/storage/test.pdf

View File

@ -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());