/
Html2PdfFactory.php
47 lines (42 loc) · 1.21 KB
/
Html2PdfFactory.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
* @license http://opensource.org/licenses/MIT MIT
* @copyright Copyright (c) 2015 Vinicius Fagundes
*/
namespace Zff\Html2Pdf;
use Interop\Container\ContainerInterface;
use Interop\Container\Exception\ContainerException;
use HTML2PDF as Html2Pdf;
use Zend\ServiceManager\Exception\ServiceNotCreatedException;
use Zend\ServiceManager\Exception\ServiceNotFoundException;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
class Html2PdfFactory
{
/**
* Create an object
*
* @param null|array $options
* @return Html2Pdf
*/
public static function factory(array $options = null)
{
$defaultOptions = [
'orientation' => 'P',
'format' => 'A4',
'lang' => 'en',
'unicode' => true,
'encoding' => 'UTF-8',
'margins' => [0, 0, 0, 0],
];
$options = array_merge($defaultOptions, $options);
return new Html2Pdf(
$options['orientation'],
$options['format'],
$options['lang'],
$options['unicode'],
$options['encoding'],
$options['margins']
);
}
}