generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:spatie/laravel-pdf
- Loading branch information
Showing
7 changed files
with
45 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
--- | ||
title: Alternatives | ||
weight: 5 | ||
weight: 6 | ||
--- | ||
|
||
Laravel PDF uses Chrome Headless to generate PDFs. This is a great solution for most use cases. You can use any CSS you want, and it will be rendered correctly. However, generating a PDF this way can be resource intensive. | ||
|
||
If you don't like the trade-off mentioned above, here are some alternatives to generate PDFs: | ||
If you don't like the trade-off mentioned above, here are some alternatives to generate PDFs which don't use Chomium under the hood: | ||
|
||
- [laravel-dompdf](https://github.com/barryvdh/laravel-dompdf) - A DOMPDF Wrapper for Laravel | ||
- [wkhtmltopdf](http://wkhtmltopdf.org/) - A command line tool to render HTML into PDF and various image formats using the QT Webkit rendering engine. This is the engine used behind the scenes in Snappy. | ||
- [mPDF](http://www.mpdf1.com/mpdf/index.php) - A PHP class to generate PDF files from HTML with Unicode/UTF-8 and CJK support. | ||
- [FPDF](http://www.fpdf.org/) - A PHP class for generating PDF files on-the-fly. | ||
|
||
|
||
These do use Chromium: | ||
|
||
- [SnapPDF](https://github.com/beganovich/snappdf) - Convert webpages or HTML into the PDF file using Chromium-powered browsers. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
use Spatie\LaravelPdf\Facades\Pdf; | ||
use Spatie\LaravelPdf\FakePdfBuilder; | ||
use Spatie\LaravelPdf\PdfBuilder; | ||
|
||
use function Spatie\LaravelPdf\Support\pdf; | ||
|
||
test('the `pdf` function returns the pdf builder instance', function () { | ||
expect(pdf())->toBeInstanceOf(PdfBuilder::class); | ||
}); | ||
|
||
test('the `pdf` function respect fakes', function () { | ||
Pdf::fake(); | ||
|
||
expect(pdf())->toBeInstanceOf(FakePdfBuilder::class); | ||
}); | ||
|
||
test('the `pdf` function accepts a view and parameters', function () { | ||
Pdf::fake(); | ||
|
||
expect(pdf('foo', ['bar' => 'bax'])) | ||
->toBeInstanceOf(FakePdfBuilder::class) | ||
->viewName->toBe('foo') | ||
->viewData->toBe(['bar' => 'bax']); | ||
}); |