PHP code example of elibyy / tcpdf-laravel

1. Go to this page and download the library: Download elibyy/tcpdf-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/ */

    

elibyy / tcpdf-laravel example snippets


'providers' => [
    //...
    Elibyy\TCPDF\ServiceProvider::class,
]

//...

'aliases' => [
    //...
    'PDF' => Elibyy\TCPDF\Facades\TCPDF::class
]

$app->register(Elibyy\TCPDF\ServiceProvider::class);
class_alias(Elibyy\TCPDF\Facades\TCPDF::class, 'PDF');

use PDF; // at the top of the file

  PDF::SetTitle('Hello World');
  PDF::AddPage();
  PDF::Write(0, 'Hello World');
  PDF::Output('hello_world.pdf');

use PDF; // at the top of the file

  for ($i = 0; $i < 5; $i++) {
    PDF::SetTitle('Hello World'.$i);
    PDF::AddPage();
    PDF::Write(0, 'Hello World'.$i);
    PDF::Output(public_path('hello_world' . $i . '.pdf'), 'F');
    PDF::reset();
  }