PHP code example of websolutionstuff / pdf-laravel
1. Go to this page and download the library: Download websolutionstuff/pdf-laravel library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use PDF; // at the top of the file
PDF::SetTitle('Websolutionstuff PDF File');
PDF::AddPage();
PDF::Write(0, 'Websolutionstuff PDF File Generate');
PDF::Output('websolutionstuff.pdf');
use PDF; // at the top of the file
for ($i = 0; $i < 5; $i++) {
PDF::SetTitle('Websolutionstuff PDF File'.$i);
PDF::AddPage();
PDF::Write(0, 'Websolutionstuff PDF File Generate'.$i);
PDF::Output(public_path('websolutionstuff' . $i . '.pdf'), 'F');
PDF::reset();
}
// remove default header/footer
PDF::setPrintHeader(false);
PDF::setPrintFooter(false);
// set margins
PDF::SetMargins(20,20,20);
// set auto page breaks
PDF::SetAutoPageBreak(TRUE, 20);
// set font
PDF::SetFont('times', 'BI', 20);
// add a page
PDF::AddPage();
// set some text to print
$txt = <<<EOD
PDF Example 2
Default page header and footer are disabled using setPrintHeader() and setPrintFooter() methods.
EOD;
// print a block of text using Write()
PDF::Write(0, $txt, '', 0, 'C', true, 0, false, false, 0);
//Close and output PDF document
PDF::Output('example_2.pdf', 'I');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.