PHP code example of pdf-api-io / pdfapi-laravel

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

    

pdf-api-io / pdfapi-laravel example snippets


return [
    'api_key' => env('PDF_API_KEY'),
];

use Pdfapiio\PdfapiLaravel\Facades\PdfApi;

$templates = PdfApi::getTemplates();

use Pdfapiio\PdfapiLaravel\Facades\PdfApi;

$pdf = PdfApi::render('your-template-id', [
    'some-variable' => 'some-value',
]);

echo $pdf; // Output: "%PDF-1.7 %���� 6 0 obj << /Type /Page /Parent 1 0 R..."

use Pdfapiio\PdfapiLaravel\Facades\PdfApi;

$pdf = PdfApi::asJson()->render('your-template-id', [
    'some-variable' => 'some-value',
]);

$content = base64_decode($pdf['data']);

use Pdfapiio\PdfapiLaravel\Facades\PdfApi;

PdfApi::output(ApiOutputType::PDF)->render('your-template', []); // Returns the PDF as a string
PdfApi::output(ApiOutputType::URL)->render('your-template', []); // Returns the URL to the rendered PDF

use Pdfapiio\PdfapiLaravel\Facades\PdfApi;

$pdf = PdfApi::merge([
    [
        'id' => 'your-template-id',
        'data' => [
            'some-variable' => '
        ],
    ],
    [
        'id' => 'your-template-id',
        'data' => [
            'some-variable' => '
        ],
    ],
]);
bash
php artisan vendor:publish --tag="pdfapi-laravel-config"