Laravel PDF Magic: From Dynamic Views to Beautiful PDFs with Spatie Browsershot

  Рет қаралды 13,766

Glenn Raya

Glenn Raya

Күн бұрын

Пікірлер: 74
@inamrasluzd6524
@inamrasluzd6524 5 ай бұрын
OMG this is what I have been looking for! Thanks for posting.
@glennraya
@glennraya 5 ай бұрын
You're welcome, In a couple of minutes I'll be posting a new video about advanced searching with Laravel Scout (Meilisearch).
@junjungaming855
@junjungaming855 5 ай бұрын
ang galing niyo po
@glennraya
@glennraya 5 ай бұрын
ahaha, salamat 😀
@DimpyIOS
@DimpyIOS 5 ай бұрын
Could you please provide me with the settings.json file that looks fabulous?
@glennraya
@glennraya 5 ай бұрын
Here's all my settings (github.com/glennraya/vscode-settings-json), you can install "Custom CSS and JS Loader" vscode extension, I made some mods to it since this video, you can refer to my latest video (kzbin.info/www/bejne/r2LFm2iud9Frd8k) on this channel to see how it looks.
@wormy_coder
@wormy_coder 3 ай бұрын
It's pretty cool I guess I would try that Library. Another Cool Video. Please keep it up
@glennraya
@glennraya 3 ай бұрын
@@wormy_coder thank you! 🙏
@yoelyanesdoynga7795
@yoelyanesdoynga7795 4 ай бұрын
Is it necessary to store PDF files on the server? Can we use something like stream() in dompdf so that the PDF files don't need to be stored?
@glennraya
@glennraya 4 ай бұрын
Hi, yes definitely. You can also directly download PDFs or open it in a new browser tab. You don't have to necessarily save it on the server.
@StevenTohme
@StevenTohme 5 ай бұрын
Your vscode theme looks super dope! What'd you use to make it look like this?
@glennraya
@glennraya 5 ай бұрын
I used the "Custom CSS and JS Loader" extension in order to customize some parts of the interface. You can define your styles in CSS to modify VSCode's UI.
@thierrykonan1050
@thierrykonan1050 4 ай бұрын
hi, thanks for the package , Often, we want to stream the PDF ... you didn't mention that part
@glennraya
@glennraya 4 ай бұрын
Correct, I should've streamed it. But anyway, this video is about generating PDFs. Next time I'll carefully consider things when making a video. Thanks.
@thierrykonan1050
@thierrykonan1050 4 ай бұрын
@@glennraya thanks, 👌
@sorinvacarescu8212
@sorinvacarescu8212 23 күн бұрын
I would really appreciate some help: I have tried this, installed puppeteer, installed the browsers for puppeteer (since I was initially getting errors from that part), pointed browsershot to the browser's path, set permissions for chrome, and I still get crashes with an error like Error Output: ================ Error: Failed to launch the browser process! Somehow nothing I tried fixed it. Also, for context, I'm running the thing containerized, on an php:8.2-fpm based image. Everything else so far has worked fine, pretty much out of the box. Many thanks in advance :)
@glennraya
@glennraya 23 күн бұрын
I haven't tried this in a containerized environment, also have to admit, a bit complicated to setup in production, but it's doable. You can refer to Browsershot's Github discussion: github.com/spatie/browsershot/discussions/663.
@rjcabarong
@rjcabarong Ай бұрын
Hello. Is there a way to hide the header on specific pages?
@glennraya
@glennraya Ай бұрын
@@rjcabarong You can hide with css, however it might reflect on all pages. Try using nth-child in css to target specific pages.
@rjcabarong
@rjcabarong Ай бұрын
@@glennraya Thanks. I already tried it using css with nth child. You're right, it reflects on all pages. Maybe I'll use mpdf instead.
@glennraya
@glennraya Ай бұрын
@@rjcabarong You can consult the browsershot's docs maybe they have something like that. I haven't had a use case for that yet.
@dark-time-programer3306
@dark-time-programer3306 3 ай бұрын
very good explanation
@glennraya
@glennraya 3 ай бұрын
Thank you!
@itsmeka
@itsmeka 2 ай бұрын
The page number is important in PDF documents. Is there any way to add page numbers, and repeat header and footer?
@glennraya
@glennraya 2 ай бұрын
I believe page numbers can be added. Kindly consult Browsershot's docs for that. For headers and footers, you can try fixed positioning in CSS to make available on every page.
@itsmeka
@itsmeka 2 ай бұрын
@@glennraya I have checked their docs and found its possible. thank you very much :)
@ronaldngarombo1026
@ronaldngarombo1026 5 ай бұрын
Hello, could you please show how we could set up this on a linux production server? A week ago I used this package and everything was perfect on local during development. But it was a nightmare when it came to using it in production unit I had to abandon it and use Dompdf instead.
@glennraya
@glennraya 5 ай бұрын
I will consider it, make sure your production server meets the requirements for Browsershot by checking their documentation since not all servers are configured the same. You may also refer to puppeteer's docs: pptr.dev/troubleshooting#chrome-doesnt-launch-on-linux. And also Spatie's requirement guide: spatie.be/docs/browsershot/v4/requirements#content-custom-node-and-npm-binaries
@yoskokleng3658
@yoskokleng3658 5 ай бұрын
how about laravel print automatic to printer witout pop up print screen in browser through javascript (window.print). i mean print it automatic from server side (silent print). please make this tutorial .
@glennraya
@glennraya 5 ай бұрын
@@yoskokleng3658 I don't think that's possible on a web interface. Maybe some form of dirty hack would do.
@miltonchowdhury4016
@miltonchowdhury4016 2 ай бұрын
wow..this looks awesome and very helpful..... If I want to add the page number of the bottom right, then how to add it, plz tell us, thanks once again...
@glennraya
@glennraya 2 ай бұрын
You can add page numbers by enabling the header and footer of Browsershot: spatie.be/docs/browsershot/v4/usage/creating-pdfs
@christiancolewan
@christiancolewan 4 ай бұрын
How do Spatie Browsershot and DomPDF compare in terms of efficiency and speed for generating PDFs?
@glennraya
@glennraya 4 ай бұрын
I think DomPDF is faster than Browsershot because Browsershot uses puppeteer which is a node library, but IMO Browsershot can generate PDFs more accurately than DomPDF (and the API is easier too).
@bolence79
@bolence79 2 ай бұрын
The header and footer are showing as not working as expected. I tried everything from documentation.
@glennraya
@glennraya 2 ай бұрын
some people have tried to make a header/footer by making it a "fixed" container to make it available on all pages.
@bolence79
@bolence79 2 ай бұрын
@@glennraya Thanks for the answer. I tried that too, but no luck.
@benedettosciuto6924
@benedettosciuto6924 5 ай бұрын
can Laravel PDF Magic repeat header and footer on every page?
@glennraya
@glennraya 5 ай бұрын
Spatie's Browsershot package doesn't directly support including the header on every succeeding page, however, you may achieve the repeating header effect by experimenting with custom CSS, like setting the header with a fixed positioning so it "could" appear on every page.
@jimmyarb7767
@jimmyarb7767 6 ай бұрын
Sir Glenn i found difficulty in production there is an error in node any advice to fix it.
@glennraya
@glennraya 6 ай бұрын
What node version are you using? Puppeteer requires node version 18 and up.
@ronaldngarombo1026
@ronaldngarombo1026 5 ай бұрын
@@glennraya I personally was using node 22 but face the error @jimmyarb7767 is probably referring to. Issue was with node and puppeteer
@SahilKumar-bt2pf
@SahilKumar-bt2pf 2 ай бұрын
I installed Browsershot, Puppetter exactly like you did but not working it's processing for few seconds then fails with errors.
@glennraya
@glennraya 2 ай бұрын
It would be helpful if you can share the error.
@videolocos413
@videolocos413 2 ай бұрын
greetings good video I am having problems to show logo in the header ->headerHtml($headHtml), of the page when I call from the database the logo doesn't show me anything and neither from the public/img/logo.png folder.
@glennraya
@glennraya 2 ай бұрын
You may need to also call the ->showBrowserHeaderAndFooter() method.
@wuba6977
@wuba6977 6 ай бұрын
Does it support all browsers?
@glennraya
@glennraya 6 ай бұрын
Yes, it supports all modern browsers.
@yoskokleng3658
@yoskokleng3658 5 ай бұрын
what's framework for css ? if i can think of the style of report design like u. my customer would love me 🤣😭
@glennraya
@glennraya 5 ай бұрын
@@yoskokleng3658 I use tailwindcss for the css framework.
@elrincondeisma
@elrincondeisma 5 ай бұрын
Tailwindui library? I see a beatiful dashboard.
@glennraya
@glennraya 5 ай бұрын
No, it's not tailwindUI. I made it myself, though it was inspired by the Arc browser UI, and the date range picker is from nextUI. Thanks
@scherzer6428
@scherzer6428 5 ай бұрын
@@glennraya Can you make a video about the dashboard
@glennraya
@glennraya 5 ай бұрын
​@@scherzer6428 I don't think making a video about the dashboard is going to bring much value to people haha. Thanks for the compliment. However, I will upload a new video tomorrow, creating advanced, Google like search engine for one's projects.
@mon_codes
@mon_codes 5 ай бұрын
thanks idol, u have my sub
@nilanjanchakraborty2694
@nilanjanchakraborty2694 5 ай бұрын
theme name please?
@glennraya
@glennraya 5 ай бұрын
Hi, which theme you're asking? VS Code's or the dashboard's?
@nilanjanchakraborty2694
@nilanjanchakraborty2694 5 ай бұрын
@@glennraya vs code
@glennraya
@glennraya 4 ай бұрын
@@nilanjanchakraborty2694 The theme itself is "Palenight", but my VS Code's UI is modified beyond what themes can give you, you can use "Custom CSS and JS Loader" extension to modify VS Code's UI extensively. After installing the plugin you can try my current settings: github.com/glennraya/vscode-settings-json
@kaiserdianalan7059
@kaiserdianalan7059 6 ай бұрын
Huui nakikita kita sa programmer code posting
@glennraya
@glennraya 6 ай бұрын
FB group po pa yun? haha
@rondevPH
@rondevPH 5 ай бұрын
hard to implement on windows
@emmanuelsiziba5142
@emmanuelsiziba5142 5 ай бұрын
I agree with you
@glennraya
@glennraya 5 ай бұрын
@@rondevPH Really? I couldn't try it, I don't have a windows machine. 😅
@rondevPH
@rondevPH 5 ай бұрын
@@glennraya good for you. That is why dompdf is the only way😅
@JavierHernandez-jg3wo
@JavierHernandez-jg3wo 5 ай бұрын
I'm trying to get it to work with laragon on windows but I can't figure out how to get it to work.
@glennraya
@glennraya 5 ай бұрын
@@rondevPH hmm, can't tell for sure, Browsershot docs doesn't mention any incompatibility with Windows.
@ajmal7247
@ajmal7247 6 ай бұрын
Can you share the source code?
@glennraya
@glennraya 6 ай бұрын
Yes sure, I'll push it to github and linked on the description.
@glennraya
@glennraya 6 ай бұрын
github.com/glennraya/browsershot
@ajmal7247
@ajmal7247 6 ай бұрын
@@glennraya i got the below error when i generate pdf in windows.I already have node installed in the system.How can i solve this The command "node "D:\wamp64\www\browsershot\vendor\spatie\browsershot\src/../bin/browser.cjs" "{""url"":""file:\/\/C:\\Users\\Ajmal\\AppData\\Local\\Temp\\896216291-0639441001719154368\\index.html"",""action"":""pdf"",""options"":{""path"":""D:\\wamp64\\www\\browsershot\\storage\\\/app\/reports\/example.pdf"",""args"":[],""viewport"":{""width"":800,""height"":600},""displayHeaderFooter"":false,""margin"":{""top"":""4mm"",""right"":""0mm"",""bottom"":""4mm"",""left"":""0mm""},""format"":""A4"",""printBackground"":true}}"" failed. Exit Code: 1(General error) Working directory: D:\wamp64\www\browsershot\public Output: ================ Error Output: ================ 'node' is not recognized as an internal or external command, operable program or batch file.
@pembatamang5716
@pembatamang5716 5 ай бұрын
Symfony \ Component\ Process \ Exception\ ProcessFailedException. the error occured. idk is this the window issue or what.
@ssodoloufo
@ssodoloufo 5 ай бұрын
I think this package only works for MacOs users, not Windows or Linux.
JS is more powerful than you remember
10:58
Coding in Public
Рет қаралды 15 М.
New Spatie PDF Package: Use Tailwind Styles in PDF
3:18
Laravel Daily
Рет қаралды 15 М.
coco在求救? #小丑 #天使 #shorts
00:29
好人小丑
Рет қаралды 120 МЛН
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 23 МЛН
malicious javascript injected into 100,000 websites
12:28
Low Level
Рет қаралды 217 М.
Laravel Octane: supercharge your Laravel applications
8:34
Aaron Francis
Рет қаралды 50 М.
Introducing Clay - High Performance UI Layout in C
35:19
Nic Barker
Рет қаралды 82 М.
Laravel Dusk: painless browser automation
20:49
Aaron Francis
Рет қаралды 23 М.
UV for Python… (Almost) All Batteries Included
17:35
ArjanCodes
Рет қаралды 78 М.
Вам всем нужны эти плагины Obsidian!
8:29
ZProger [ IT ]
Рет қаралды 9 М.
The New Features of Inertia 2.0 in 3 Minutes
3:01
Laravel
Рет қаралды 10 М.