PHP code example of org_heigl / html-to-pdflib

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

    

org_heigl / html-to-pdflib example snippets


$converter = new Converter();
$pdflibtext = $converter->convert($htmlcontent);

// $pdflibtext now contains calls to macros.
// The macros themselves need to be prepend to the text though!!
$pdflibtext = '<macro {
    bold {fontname=Helvetica fontsize=12 encoding=winansi}
    bolditalic {fontname=Helvetica fontsize=8 encoding=winansi}
    italic {fontname=Helvetica fontsize=8 encoding=winansi}
}>' . $pdflibtext;

use Org_Heigl\HtmlToPdflib\Converter;
use Org_Heigl\HtmlToPdflib\ConverterList;
use Org_Heigl\HtmlToPdflib\Converter\Em;
use Org_Heigl\HtmlToPdflib\Converter\Li;
use Org_Heigl\HtmlToPdflib\Converter\Ol;
use Org_Heigl\HtmlToPdflib\Converter\P;
use Org_Heigl\HtmlToPdflib\Converter\Strong;
use Org_Heigl\HtmlToPdflib\Converter\Ul;
use Org_Heigl\HtmlToPdflib\Factory;

$converter = new Converter(Factory::fromConverterList(ConverterList::createViaReflection([
    'em' => Em::class,
    'li' => Li::class,
    'ol' => Ol::class,
    'p' => P::class,
    'strong' => Strong::class,
    'ul' => Ul::class,
])));