diff --git a/README.md b/README.md index c046477..d95f475 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,55 @@ Using composer from [packagist](https://packagist.org/packages/greenter/htmltopd composer require greenter/htmltopdf ``` +## Example +Require [html-report](https://github.com/giansalex/greenter-report) and logo.png + +```php +use Greenter\Report\HtmlReport; +use Greenter\Report\PdfReport; +use Greenter\Model\Sale\Invoice; + +$invoice = new Invoice(); +// fill ... + +$html = new HtmlReport('', [ + 'cache' => __DIR__ . '/cache', + 'strict_variables' => true, +]); +$html->setTemplate('invoice.html.twig'); + +$report = new PdfReport($html); +$report->setOptions( [ + 'no-outline', + 'viewport-size' => '1280x1024', + 'page-width' => '21cm', + 'page-height' => '29.7cm', +]); +$report->setBinPath('wkhtmltopdf.exe'); + +$logo = file_get_contents(__DIR__.'/logo.png'); +$params = [ + 'system' => [ + 'logo' => $logo, + 'hash' => '' + ], + 'user' => [ + 'resolucion' => '212321', + 'header' => 'Telf: (056) 123375', + 'extras' => [ + ['name' => 'CONDICION DE PAGO', 'value' => 'Efectivo' ], + ['name' => 'VENDEDOR' , 'value' => 'GITHUB SELLER'], + ], + ] +]; + +$pdf = $report->render($invoice, $params); + +// Write PDF to disk +file_put_contents('invoice.pdf', $pdf); + +``` + ## Preview Representacion Impresa de la Factura Electrónica.