PHP code example of carthage-software / ext-typst

1. Go to this page and download the library: Download carthage-software/ext-typst 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/ */

    

carthage-software / ext-typst example snippets


$world = new Typst\World();
$compiler = new Typst\Compiler($world);

const TEMPLATE = <<<'TYPST'
#set page(height: auto)
= Hello from Typst

This is a *bold* statement with _italic_ flair.
TYPST;

$document = $compiler->compileString(TEMPLATE);

$document->toPdf()->save('output.pdf');
$document->toImage()->save('output.png');
$document->toSvg()->save('output.svg');