PHP code example of statikbe / laravel-puppeteer-pdf-converter

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

    

statikbe / laravel-puppeteer-pdf-converter example snippets


//set options and get pdf from conversion API
try {
    $pdfOptions = new PdfOptions();
    $pdfOptions->setScale(0.6)
        ->setPageMargins(new PdfPageMargin(40, PdfPageMargin::MARGIN_IN_PIXELS));
    $pdfUrl = PuppeteerPdfConverter::convertRoute('report_index', ['organisation' => $organisation], 'report.pdf', $pdfOptions);
    return redirect($pdfUrl);
}
catch(PdfApiException $exception){
    Log::error(sprintf('PDF report could not be created: %s (for organisation: %s)', $exception->getMessage(), $organisation));
    return view('pdf_error', ['error' => $exception->getMessage()]);
}
 
$merger = new \Statikbe\PuppeteerPdfConverter\PdfMerger();
$urls = ['http://example.com/first.pdf', 'http://example.com/second.pdf'];
$mergedPdfUrl = $merger->mergePdfUrls($urls, 
    \Statikbe\PuppeteerPdfConverter\Enum\MergerOutput::URL, 
    'merged_file.pdf');

$merger = new \Statikbe\PuppeteerPdfConverter\PdfMerger();
$files = ['/path/to/first.pdf', '/path/to/second.pdf'];
$response = $merger->mergePdfFiles($files, \Statikbe\PuppeteerPdfConverter\Enum\MergerOutput::BASE64);

PuppeteerPdfConverter::isLocalTunnelConfigured();
bash
php artisan vendor:publish --tag="puppeteer-pdf-converter-config"