No Chrome, no Node, no problem: PDF generation in Laravel finally grows up
The title is a tad hyperbolic, but this blogpost provides a nice overview of how the Laravel PDF package works under the hood.
Read more [jpcaparas.medium.com]
Posts tagged with pdf
The title is a tad hyperbolic, but this blogpost provides a nice overview of how the Laravel PDF package works under the hood.
Read more [jpcaparas.medium.com]
A while ago, we released laravel-pdf, a package to generate PDFs in Laravel apps.
Under the hood, it used Browsershot (and therefore Puppeteer/Chrome) to convert HTML to PDF. That approach works great, but it does require Node.js and a headless Chrome binary on your server.
Last week, my buddy Dries shared on X how to generate PDFs using Cloudflare services. This way doesn’t require Node or any binaries. Very neat! This unlocks PDF generation for environments where Node or Chrome cannot be installed easily, like Laravel Cloud.
To support this way of rendering a PDF, we’ve released a new major release (v2) of Laravel PDF. The package now ships with three drivers: Browsershot, Cloudflare Browser Rendering, and DOMPDF. You can also create your own driver. On top of that, we've added queued PDF generation and the ability to set PDF metadata. And to let your AI understand our package, we've added a Laravel Boost skill.
Let me walk you through all of it.
Join 9,500+ smart developers
Every month I share what I learn from running Spatie, building Oh Dear, and maintaining 300+ open source packages. Practical takes on Laravel, PHP, and AI that you can actually use.
No spam. Unsubscribe anytime. You can also follow me on X.
– www.youtube.com - submitted by Harish Kumar
Spatie/BrowserShot is a versatile Laravel package that facilitates the generation of PDFs or screenshots by leveraging headless browsers. This package seamlessly integrates with Laravel applications, allowing developers to capture the rendered HTML of web pages or views and convert them into PDFs or images.
Read more [www.youtube.com]
Last week, we released a new package called Laravel PDF that allows you to transform Blade views into PDFs. Under the hood, Chromium is used to perform the transformation. Because Chromium is an up-to-date browser, you can use any modern CSS you like.
Some people have asked if they can use Tailwind to style their documents. And I’m happy to report you can. Let’s take a look at a minimal example to showcase this.
We’ve released a new package called spatie/laravel-pdf, a batteries-included package to generate PDFs in Laravel apps. Under the hood, it uses Chromium to generate PDFs from Blade views. You can use modern CSS features like grid, flexbox, and even frameworks like Tailwind to create beautiful PDFs.
In this post, I’d like to introduce and demonstrate the package.
– fly.io - submitted by Johannes Werbrouck
Invoicing is boring and manually writing up invoices even more so, that's why you should automate the entire process in your app. Here, I show you how to use Spatie’s wonderful Browsershot package to do just that.
Read more [fly.io]
Here's a PDF, made by Ryan Grove, that executes JavaScript when you open it in Chrome.
Read more [rawgit.com]
The last couple of weeks soem strange Imagick errors popped up across all our servers. In a new blogpost my colleague Alex explains the cause and the fix.
Over the last few days we've had a couple of issues with Imagick and processing PDFs on our servers. As it turns out, these issues are caused by automatic security updates. Let's look into the issue and its solution.
Read more [alexvanderbist.com]
To convert html to a pdf or an image using wkhtmltopdf and wkhtmltoimage tends to be the popular option. Unfortunately those tools contain an outdated browser engine to do their thing, so you can't use any newish css syntax. A while ago Google added a headless mode to Chrome. They've also released a…
While working on one of our projects my colleague Sebastian had to create a pdf with some text and charts. In a new post on his blog he explains how he leveraged headless Chrome to create the pdf.
For a project I needed to extract some text from a pdf. Although there were already a few packages that could to this, I still created spatie/pdf-to-text because I wanted something that was really easy to use. And also because it's fun creating packages. Under the hood a utility called pdftotext is…
Converting a pdf to an image is easy using PHP, but the API kinda sucks. $imagick = new Imagick('file.pdf[0]'); $imagick->setImageFormat('jpg'); file_put_contents($pathToImage, $imagick); The pdf-to-image-package aims to fix that. Here is the equivalent code: $pdf = new…