FyrePDF is a free, open-source PDF generation library for PHP.
Dependencies
- Google Chrome
In Ubuntu:
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt install ./google-chrome-stable_current_amd64.deb
Using Composer
composer require fyre/pdf
In PHP:
use Fyre\Utility\Pdf;$sourceis a string representing the source URL or HTML file.
$pdf = new Pdf($source);Create From HTML
Generate a Pdf from a HTML string.
$pdf = Pdf::createFromHtml($html);Create From URL
Generate a Pdf from a URL or file path.
$urlis a string representing the source URL or HTML file.
$pdf = Pdf::createFromUrl($url);To Binary
Get the binary data.
$data = $pdf->toBinary();Save
Save the pdf as a file.
$filePathis a string representing the file path.
$pdf->save($filePath);Get Binary Path
Get the Chrome binary path.
$binaryPath = Pdf::getBinaryPath();Get Timeout
Get the timeout.
$timeout = Pdf::getTimeout();Set Binary Path
Set the Chrome binary path.
$binaryPathis a string representing the Chrome binary path.
Pdf::setBinaryPath($binaryPath);Set Timeout
Set the timeout.
$timeoutis a number representing the timeout.
Pdf::setTimeout($timeout);