PHP code example of tecsiaron / ublrenderer

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

    

tecsiaron / ublrenderer example snippets


$content=file_get_contents("path_to.xml");
$renderer = new UBLRenderer($content);
$renderer->WriteFile();

$content=UBLRenderer::LoadUBLFromZip("test.zip")->ubl;
$renderer = new UBLRenderer($content);
$renderer->WriteFile();

$renderer->WriteFiles(new HTMLFileWriter("path_to_output.html"));

// get the contents of the XML
$renderer = new UBLRenderer($content);
$invoice=$renderer->ParseUBL();
$validation=$invoice->CanRender();
$validationFailReason="Validation failed:\n";
if(is_array($validation))
{
	echo "Failed to render invoice: ". implode("\n", $validation)
}
else
{
	$html=$renderer->CreateHTML(invoice);
}

composer 

php vendor/bin/ubl2html.php <input.xml or input.zip> <output.html>