Recommend this page to a friend! |
![]() ![]() |
Info | ![]() |
![]() |
![]() ![]() |
Reputation | Support forum | Blog (1) | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not yet rated by the users | Total: 204 This week: 1 | All time: 8,393 This week: 149![]() |
Version | License | PHP version | Categories | |||
laravel-html2pdf 1.0.0 | The PHP License | 5 | HTML, PHP 5, Files and Folders, Unix |
Description | Author | |
This package can generate PDF documents from HTML using wkhtmltopdf. |
> A Simple package for easily generating PDF documents from HTML.This package is specially for laravel but you can use this without laravel.
This was tested on:
sudo apt-get update
sudo apt-get install xvfb libfontconfig wkhtmltopdf
RUN apt-get update && apt-get install xvfb libfontconfig wkhtmltopdf
composer require nahidulhasan/html2pdf
If laravel version < 5.5, add the ServiceProvider to the providers array in config/app.php
NahidulHasan\Html2pdf\Html2pdfServiceProvider::class,
You can optionally use the facade for shorter code. Add this to your facades:
'Pdf' => NahidulHasan\Html2pdf\Facades\Pdf::class,
To create PDF add something like this to one of your controllers.
use NahidulHasan\Html2pdf\Facades\Pdf;
$document = Pdf::generatePdf('<h1>Test</h1>');
You can also create PDF from directly calling laravel blade file. Suppose you have a mail template named greeting in view/mails folder and want to send parameter then you have to call generatePdf method as described in below
<!-- mail template stored in resources/views/mails/greeting.blade.php -->
$document = Pdf::generatePdf(view('mails.greeting', ['name' => 'James', 'testVar' => 'demo']));
Now If you want to send mail to your client attaching pdf then you can follow this code
/
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->from('username@gmail.com')
->view('mails.demo')
->attachData($document, 'Invoice.pdf');
}
It is also possible to use the following methods :
You can use this library without using Laravel.
Example:
use NahidulHasan\Html2pdf\Pdf;
$obj = new Pdf();
$document = $obj->generatePdf('<h1>Test</h1>');
Html2PDF for Laravel is open-sourced software licensed under the MIT license
![]() |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() ![]() |
Data | Auxiliary data | ||
![]() ![]() |
Doc. | Documentation |
![]() |
/ | src |
File | Role | Description | ||
---|---|---|---|---|
![]() |
||||
![]() |
Class | Class source | ||
![]() |
Class | Class source |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.