|
1
|
|
|
<?php |
|
2
|
|
|
namespace Eduardokum\CorreiosPhp\Render; |
|
3
|
|
|
|
|
4
|
|
|
use Eduardokum\CorreiosPhp\Config\Testing; |
|
5
|
|
|
use Eduardokum\CorreiosPhp\Contracts\Config\Config as ConfigContract; |
|
6
|
|
|
|
|
7
|
|
|
abstract class Pdf |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* @var \TCPDF |
|
11
|
|
|
*/ |
|
12
|
|
|
protected $tcpdf; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @var ConfigContract |
|
16
|
|
|
*/ |
|
17
|
|
|
protected $config; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @var int |
|
21
|
|
|
*/ |
|
22
|
|
|
protected $padding = 1; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var mixed|string |
|
26
|
|
|
*/ |
|
27
|
|
|
protected $fontRegular; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var mixed|string |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $fontBold; |
|
33
|
|
|
|
|
34
|
|
|
public function __construct(ConfigContract $config = null) |
|
35
|
|
|
{ |
|
36
|
|
|
$this->config = $config ?: new Testing(); |
|
37
|
|
|
$this->fontRegular = \TCPDF_FONTS::addTTFfont(CORREIOS_PHP_BASE . '/resources/assets/fonts/Arial.ttf', 'TrueTypeUnicode', '', 96); |
|
38
|
|
|
$this->fontBold = \TCPDF_FONTS::addTTFfont(CORREIOS_PHP_BASE . '/resources/assets/fonts/ArialBold.ttf', 'TrueTypeUnicode', '', 96); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @return ConfigContract |
|
43
|
|
|
*/ |
|
44
|
|
|
public function getConfig() |
|
45
|
|
|
{ |
|
46
|
|
|
return $this->config; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param $h |
|
51
|
|
|
* @param $txt |
|
52
|
|
|
* @param string $link |
|
53
|
|
|
* @param bool $fill |
|
54
|
|
|
* @param string $align |
|
55
|
|
|
* @param bool $ln |
|
56
|
|
|
* @param int $stretch |
|
57
|
|
|
* @param bool $firstline |
|
58
|
|
|
* @param bool $firstblock |
|
59
|
|
|
* @param int $maxh |
|
60
|
|
|
* @param int $wadj |
|
61
|
|
|
* @param string $margin |
|
62
|
|
|
*/ |
|
63
|
|
|
protected function writeBold($h, $txt, $link = '', $fill = false, $align = '', $ln = false, $stretch = 0, $firstline = false, $firstblock = false, $maxh = 0, $wadj = 0, $margin = '') |
|
64
|
|
|
{ |
|
65
|
|
|
$this->tcpdf->SetFont($this->fontBold, 'B'); |
|
66
|
|
|
$this->tcpdf->Write($h, $txt, $link, $fill, $align, $ln, $stretch, $firstline, $firstblock, $maxh, $wadj, $margin); |
|
67
|
|
|
$this->tcpdf->SetFont($this->fontRegular, null); |
|
68
|
|
|
} |
|
69
|
|
|
} |