PHP code example of ratiw / jsonpdf

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

    

ratiw / jsonpdf example snippets


          // This part usually comes from file or http request
        $document = array(
            'body' => array(
                array(
                    'type' => 'text',
                    'width' => 40,
                    'height' => 10,
                    'text' => 'Hello World!',
                    'font' => 'Arial',
                    'font-style' => 'B',
                    'font-size' => 16,
                ),
                array(
                    'type' => 'text',
                    'text' => 'Hi, {name}!',
                ),
            ),
        );
        
        $data = array(
            'name' => 'Rati'
        );

        // The main code is here
        $pdf = new ratiw\JsonPDF\JsonPDF('P', 'mm', 'A4');
        $pdf->make(json_encode($document), json_encode($data), 'both');
        // $pdf->make(json_encode($document), json_encode($data), 'form');
        // $pdf->make(json_encode($document), json_encode($data), 'data');
        $pdf->render();