Add ability to use Browsershot with NODE_PATH & NPM_PATH .env variables

This commit is contained in:
Clément Gayot 2020-10-13 14:42:54 +02:00
parent 1bbe674902
commit c21c79b8be
4 changed files with 483 additions and 296 deletions

View File

@ -192,6 +192,8 @@ class SetupController extends Controller
} }
Browsershot::html('PDF GENERATION WORKS! Thank you for using Invoice Ninja!') Browsershot::html('PDF GENERATION WORKS! Thank you for using Invoice Ninja!')
->setNodeBinary(config('ninja.system.node_path'))
->setNpmBinary(config('ninja.system.npm_path'))
->noSandbox() ->noSandbox()
->savePdf( ->savePdf(
public_path('test.pdf') public_path('test.pdf')

773
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -16,6 +16,7 @@
"@babel/plugin-proposal-class-properties": "^7.10.4", "@babel/plugin-proposal-class-properties": "^7.10.4",
"cypress": "^4.12.1", "cypress": "^4.12.1",
"laravel-mix-purgecss": "^5.0.0", "laravel-mix-purgecss": "^5.0.0",
"puppeteer": "^5.3.1",
"vue-template-compiler": "^2.6.11" "vue-template-compiler": "^2.6.11"
}, },
"dependencies": { "dependencies": {
@ -27,7 +28,6 @@
"jsignature": "^2.1.3", "jsignature": "^2.1.3",
"laravel-mix": "^5.0.7", "laravel-mix": "^5.0.7",
"lodash": "^4.17.20", "lodash": "^4.17.20",
"puppeteer": "^1.20.0",
"resolve-url-loader": "^3.1.0", "resolve-url-loader": "^3.1.0",
"sass": "^1.26.10", "sass": "^1.26.10",
"sass-loader": "^8.0.0", "sass-loader": "^8.0.0",

View File

@ -28,6 +28,8 @@ class PdfGenerationTest extends TestCase
private function makePdf($header, $footer, $html, $pdf) private function makePdf($header, $footer, $html, $pdf)
{ {
Browsershot::html($html) Browsershot::html($html)
->setNodeBinary(config('ninja.system.node_path'))
->setNpmBinary(config('ninja.system.npm_path'))
//->showBrowserHeaderAndFooter() //->showBrowserHeaderAndFooter()
//->headerHtml($header) //->headerHtml($header)
//->footerHtml($footer) //->footerHtml($footer)