PHP code example of dskripchenko / php-pdf-fonts-liberation

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

    

dskripchenko / php-pdf-fonts-liberation example snippets


use Dskripchenko\PhpPdf\Build\DocumentBuilder;
use Dskripchenko\PhpPdf\Layout\Engine;
use Dskripchenko\PhpPdfFontsLiberation\LiberationFontProvider;

$bytes = DocumentBuilder::new()
    ->heading(1, 'Annual Report')
    ->paragraph('Тысяча красивых символов с правильным кернингом.')
    ->toBytes(new Engine(fontProvider: new LiberationFontProvider));

use Dskripchenko\PhpPdf\Font\ChainedFontProvider;
use Dskripchenko\PhpPdf\Font\DirectoryFontProvider;
use Dskripchenko\PhpPdfFontsLiberation\LiberationFontProvider;

$fonts = new ChainedFontProvider([
    new DirectoryFontProvider(__DIR__.'/my-brand-fonts'),  // checked first
    new LiberationFontProvider,                            // fallback
]);