Skip to content

Commit

Permalink
add sample
Browse files Browse the repository at this point in the history
  • Loading branch information
giansalex committed Apr 16, 2018
1 parent 79e7fba commit 1ec7ecf
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: <b>(056) 123375</b>',
'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.

Expand Down

0 comments on commit 1ec7ecf

Please sign in to comment.