PHP code example of elzobrito / olivia-pdf

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

    

elzobrito / olivia-pdf example snippets




use Oliviapdf\Pdf;



liviapdf\Pdf;

$pdf = new Pdf();
$pdf->AliasNbPages();

$pdf->image_logo = __DIR__ . '/logo.png';
$pdf->title = 'Relatório de Atendimento';
$pdf->subtitle = 'Período de abril de 2026';
$pdf->autentication = 'ABC123456';

$pdf->AddPage();
$pdf->SetFont('Arial', '', 12);

$pdf->WriteHTML('<p align="center"><b>Olivia PDF</b><br>Fork do FPDF com recursos extras.</p>');
$pdf->Ln(8);

$pdf->SetWidths([50, 80, 50]);
$pdf->SetAligns(['L', 'L', 'C']);
$pdf->Row(['Nome', 'Descrição', 'Status']);
$pdf->Row(['Olivia', 'Documento gerado com tabela automática', 'OK']);
$pdf->Row(['Sistema', 'Linha com quebra automática para textos maiores dentro da célula', 'ATIVO']);

$pdf->Ln(10);
$pdf->Circle(20, 90, 5);
$pdf->TextWithRotation(30, 100, 'Texto rotacionado', 45);

$pdf->Output('I', 'exemplo.pdf');

$pdf->AliasNbPages();
$pdf->image_logo = __DIR__ . '/logo.png';
$pdf->title = 'Meu Documento';
$pdf->title_config_array = ['Arial', 'B', 12];
$pdf->subtitle = 'Subtítulo do relatório';
$pdf->subtitle_config_array = ['Arial', '', 10];
$pdf->autentication = 'TOKEN-001';

$pdf->SetFont('Arial', '', 10);
$pdf->SetWidths([40, 100, 40]);
$pdf->SetAligns(['L', 'L', 'C']);

$pdf->Row(['Código', 'Descrição', 'Valor']);
$pdf->Row(['001', 'Item com descrição longa e quebra automática dentro da célula', 'R$ 10,00']);

$pdf->SetFont('Arial', '', 12);
$pdf->WriteHTML('<b>Negrito</b> <i>itálico</i> <u>sublinhado</u><br>');
$pdf->WriteHTML('<a href="https://example.com">Abrir link</a>');
bash
composer validate --no-check-publish
php -l src/Pdf.php