PHP code example of sun / pdf

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

    

sun / pdf example snippets



$pdf = new Sun\PDF;
$pdf->download("<h1>Hello world</h1>");

$pdf = new Sun\PDF;
$pdf->stream("<h1>Hello world</h1>");

$pdf = new Sun\PDF;
$pdf->output("<h1>Hello world</h1>");

$pdf = new Sun\PDF("/path/to/SunPdf.js");

$pdf = new Sun\PDF(null, "/path/to/views");
    
$pdf = new Sun\PDF(null, "/path/to/views");

// download pdf 
$pdf->download("/path/to/views/test.php", ['name' => 'Iftekher Sunny']);

// viewing pdf in the browser
$pdf->stream("/path/to/views/test.php", ['name' => 'Iftekher Sunny']);

Sun\Provider\PDFServiceProvider::class,

'PDF'   =>  Sun\Facade\PDFFacade::class,

Sun\Provider\PDFProvider::class,

'PDF'   =>  Sun\Alien\PDFAlien::class,