Download the PHP package jbreuer95/laravel-make-pdf without Composer
On this page you can find all versions of the php package jbreuer95/laravel-make-pdf. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jbreuer95/laravel-make-pdf
More information about jbreuer95/laravel-make-pdf
Files in jbreuer95/laravel-make-pdf
Package laravel-make-pdf
Short Description Convert HTML to PDF using a headless Chrome instance
License MIT
Homepage https://github.com/jbreuer95/laravel-make-pdf
Informations about the package laravel-make-pdf
Convert HTML to PDF with headless Chrome
This package allows you to easily convert HTML to PDF using headless Chrome through Selenium, without needing Node.js. It is inspired by Spatie's laravel-pdf package, which uses BrowserShot and Puppeteer, but our solution offers a more PHP-centric approach using Selenium.
Requirements
Laravel Make PDF requires PHP 8.1+ and Laravel 10+.
Installation & Setup
You can install the package via Composer:
After installation, download headless Chrome using the following Artisan command:
To customize the package configuration, publish the configuration file:
Here is the content of the published config file:
Usage
Converting HTML to PDF with this package is simple and efficient. Below are a few common use cases:
Basic Example
Convert a Blade view to a PDF and stream it to the browser:
Or force the browser to download the PDF file
Options
Render Raw HTML:
Instead of passing a Blade view, you can directly pass HTML:
Header and Footer
You can include a view in the header and footer of every page:
Alternatively, set raw HTML for the header and footer:
In the header or footer, the following placeholders can be used and will be replaced with their print-specific values:
Note: The header and footer do not inherit the same CSS as the main content, and the default font size is 0. You should include any required CSS directly in the header/footer. Here’s an example of a styled footer view:
Landscape Orientation
Switch the page orientation to landscape:
Set Paper Format
Specify a standard paper format:
The following formats are available: LETTER
, LEGAL
, A0
, A1
, A2
, A3
, A4
, A5
, A6
.
Set Custom Paper Size
Set a custom paper size, specifying height and width in inches (or another unit):
Set Margins
Set custom margins for the PDF document:
Custom Filename
Define a custom name for the PDF when downloading from the browser.
The .pdf
extension is automatically appended if omitted:
Save to File
Use the save
method to store the PDF at a given file path:
Retrieve PDF as a String
To obtain the raw PDF content as a string, use the raw
method:
Stream PDF
Display the PDF directly in the browser without saving it to disk:
Force Download
Prompt the browser to immediately download the PDF:
License
This package is open-sourced software licensed under the MIT License.
Please see the License File for more information.
All versions of laravel-make-pdf with dependencies
ext-zip Version *
guzzlehttp/guzzle Version ^7.9
illuminate/contracts Version ^10.0||^11.0
php-webdriver/webdriver Version ^1.15
spatie/laravel-package-tools Version ^1.16