Works inside tinker but not in routes #156
Answered
by
alvaro-canepa
alvaro-canepa
asked this question in
Q&A
-
When I try to generate pdf from route give error // This give error
Route::get('html', function () {
return \Spatie\LaravelPdf\Facades\Pdf::html('<h1>Hello World</h1>')
->withBrowsershot(function (\Spatie\Browsershot\Browsershot $browsershot) {
$browsershot
->setNodeBinary('/usr/bin/node')
->setNpmBinary('/usr/bin/npm')
->setIncludePath('/usr/bin')
->noSandbox();
})
->save(storage_path().'/app/test.pdf');
});
From tinker gets this: = Spatie\LaravelPdf\PdfBuilder {#7175
+viewName: "",
+viewData: [],
+html: "<h1>Hello World</h1>",
+headerViewName: "",
+headerData: [],
+headerHtml: null,
+footerViewName: "",
+footerData: [],
+footerHtml: null,
+downloadName: "",
+format: null,
+paperSize: null,
+orientation: null,
+margins: null,
} |
Beta Was this translation helpful? Give feedback.
Answered by
alvaro-canepa
Jul 4, 2024
Replies: 1 comment
-
I found the problem. I use docker with laradock, so, first I need to install puppeteer in .env file on laradock folder WORKSPACE_INSTALL_PUPPETEER=true
PHP_FPM_INSTALL_PUPPETEER=true docker-compose.yaml on laradock folder workspace:
build:
args:
- INSTALL_PUPPETEER=${WORKSPACE_INSTALL_PUPPETEER}
php-fpm:
build:
args:
- INSTALL_PUPPETEER=${PHP_FPM_INSTALL_PUPPETEER} Dockerfile inside of php-fpm and workspace ###########################################################################
# PUPPETEER
###########################################################################
USER root
ARG INSTALL_PUPPETEER=false
RUN if [ ${INSTALL_PUPPETEER} = true ]; then \
curl -sL https://deb.nodesource.com/setup_22.x | bash - \
&& apt-get install -y nodejs gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget libgbm-dev libxshmfence-dev \
&& npm install --location=global --unsafe-perm puppeteer \
&& npx puppeteer browsers install chrome \
;fi Then, inside Now it works!!! |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
alvaro-canepa
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found the problem. I use docker with laradock, so, first I need to install puppeteer in
php-fpm
andworkspace
containers..env file on laradock folder
docker-compose.yaml on laradock folder
Dockerfile inside of php-fpm and workspace