PHP code example of choowx / satori-php

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

    

choowx / satori-php example snippets


use Choowx\Satori\Satori;

$svg = Satori::html('<div style="color: black">hello, world</div>')->convert();
// $svg = '<svg width="1200" height="630" viewBox="0 0 1200 630" xmlns="http://www.w3.org/2000/svg"><path fill="black"...

use Choowx\Satori\Satori;

$svg = Satori::html('<div style="color: black">hello, world</div>')
    ->width(600)
    ->height(315)
    ->convert();
// $svg = '<svg width="600" height="315" viewBox="0 0 600 315"...

use Choowx\Satori\Font;
use Choowx\Satori\Satori;

$svg = Satori::html('<div style="color: black">hello, world</div>')
    ->withFonts([
        Font::path('/path/to/Roboto-Regular.ttf')
            ->name('Roboto')
            ->weight(400)
            ->style('regular'),
        Font::path('/path/to/Roboto-Bold.ttf')
            ->name('Roboto')
            ->weight(700)
            ->style('bold'),
    ])
    ->convert();
bash
composer