PHP code example of mohammadraufzahed / folio

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

    

mohammadraufzahed / folio example snippets


use Folio\Pdf\Document\Pdf;
use Folio\Pdf\Nodes\Column;
use Folio\Pdf\Nodes\Heading;
use Folio\Pdf\Nodes\Page;
use Folio\Pdf\Nodes\Text;
use Folio\Pdf\Styling\Color;
use Folio\Pdf\Styling\Style;

Pdf::make()
    ->page(
        Page::a4()->withContent(
            Column::make()
                ->addChildren([
                    Heading::h1('Invoice'),
                    Text::make('Customer: John Doe'),
                    Text::make('Amount: $100.00'),
                ])
        )
    )
    ->save('invoice.pdf');

use Folio\Pdf\Template\PhpTemplateCompiler;

$compiler = new PhpTemplateCompiler();
$pdf = $compiler->renderFile('invoice.folio', [
    'title' => 'Invoice',
    'customer' => 'John Doe',
]);
$pdf->save('invoice.pdf');

$page = Page::a4();
$styledPage = $page->withContent($content); // Returns new instance

Column::make()
    ->addChildren([
        Heading::h2('Section 1'),
        Text::make('Content here'),
        Row::make()->addChildren([
            Text::make('Left'),
            Text::make('Right'),
        ]),
    ])

Style::make()
    ->withPadding(20.0)
    ->withColor(Color::hex('#333333'))
    ->withFontSize(14.0)
    ->withFontWeight(FontWeight::Bold)