1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Thermal; |
4
|
|
|
|
5
|
|
|
class Printer |
6
|
|
|
{ |
7
|
|
|
const ALIGN_LEFT = 0; |
8
|
|
|
const ALIGN_CENTER = 1; |
9
|
|
|
const ALIGN_RIGHT = 2; |
10
|
|
|
|
11
|
|
|
const STYLE_BOLD = 1; |
12
|
|
|
const STYLE_ITALIC = 2; |
13
|
|
|
const STYLE_UNDERLINE = 4; |
14
|
|
|
const STYLE_CONDENSED = 8; |
15
|
|
|
const STYLE_DOUBLE_WIDTH = 16; |
16
|
|
|
const STYLE_DOUBLE_HEIGHT = 32; |
17
|
|
|
|
18
|
|
|
const CUT_FULL = 0; |
19
|
|
|
const CUT_PARTIAL = 1; |
20
|
|
|
|
21
|
|
|
const DRAWER_1 = 0; |
22
|
|
|
const DRAWER_2 = 1; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Model |
26
|
|
|
* |
27
|
|
|
* @var Model |
28
|
|
|
*/ |
29
|
|
|
private $model; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Constructor |
33
|
|
|
* |
34
|
|
|
* @param Model $model |
35
|
|
|
* @param Connection\Connection $connection |
36
|
|
|
*/ |
37
|
12 |
|
public function __construct($model, $connection) |
38
|
|
|
{ |
39
|
12 |
|
$connection->open(); |
40
|
12 |
|
$this->model = $model; |
41
|
12 |
|
$this->model->getProfile()->setConnection($connection); |
42
|
12 |
|
$this->model->getProfile()->initialize(); |
43
|
12 |
|
} |
44
|
|
|
|
45
|
1 |
|
public function setCodePage($codepage) |
46
|
|
|
{ |
47
|
1 |
|
$this->model->getProfile()->setCodePage($codepage); |
48
|
1 |
|
return $this; |
49
|
|
|
} |
50
|
|
|
|
51
|
1 |
|
public function buzzer() |
52
|
|
|
{ |
53
|
1 |
|
$this->model->getProfile()->buzzer(); |
54
|
1 |
|
return $this; |
55
|
|
|
} |
56
|
|
|
|
57
|
1 |
|
public function cutter($mode = self::CUT_PARTIAL) |
58
|
|
|
{ |
59
|
1 |
|
$this->model->getProfile()->cutter($mode); |
60
|
1 |
|
return $this; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param int $number drawer id |
65
|
|
|
* @param int $on_time time in milliseconds that activate the drawer |
66
|
|
|
* @param int $off_time time in milliseconds that deactivate the drawer |
67
|
|
|
*/ |
68
|
2 |
|
public function drawer($number = self::DRAWER_1, $on_time = 120, $off_time = 240) |
69
|
|
|
{ |
70
|
2 |
|
$this->model->getProfile()->drawer($number, $on_time, $off_time); |
71
|
2 |
|
return $this; |
72
|
|
|
} |
73
|
|
|
|
74
|
1 |
|
public function draw($image) |
75
|
|
|
{ |
76
|
1 |
|
$this->model->getProfile()->draw($image); |
77
|
1 |
|
return $this; |
78
|
|
|
} |
79
|
|
|
|
80
|
1 |
|
public function qrcode($data, $size = null) |
81
|
|
|
{ |
82
|
1 |
|
$this->model->getProfile()->qrcode($data, $size); |
|
|
|
|
83
|
1 |
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
2 |
|
public function setAlignment($align) |
87
|
|
|
{ |
88
|
2 |
|
$this->model->getProfile()->setAlignment($align); |
89
|
2 |
|
return $this; |
90
|
|
|
} |
91
|
|
|
|
92
|
2 |
|
public function write($text, $styles = 0, $align = self::ALIGN_LEFT) |
93
|
|
|
{ |
94
|
2 |
|
$this->model->getProfile()->write($text, $styles, $align); |
95
|
2 |
|
return $this; |
96
|
|
|
} |
97
|
|
|
|
98
|
1 |
|
public function writeln($text, $styles = 0, $align = self::ALIGN_LEFT) |
99
|
|
|
{ |
100
|
1 |
|
if (strlen($text) > 0) { |
101
|
1 |
|
$this->write($text, $styles, $align); |
102
|
|
|
} |
103
|
1 |
|
$this->feed(); |
104
|
1 |
|
return $this; |
105
|
|
|
} |
106
|
|
|
|
107
|
2 |
|
public function feed($lines = 1) |
108
|
|
|
{ |
109
|
2 |
|
$this->model->getProfile()->feed($lines); |
110
|
2 |
|
return $this; |
111
|
|
|
} |
112
|
|
|
|
113
|
4 |
|
public function getColumns() |
114
|
|
|
{ |
115
|
4 |
|
return $this->model->getProfile()->getColumns(); |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Set columns aproximated to informed |
120
|
|
|
* @param int $columns aproximated number of columns |
121
|
|
|
*/ |
122
|
4 |
|
public function setColumns($columns) |
123
|
|
|
{ |
124
|
4 |
|
$this->model->getProfile()->setColumns($columns); |
125
|
4 |
|
return $this; |
126
|
|
|
} |
127
|
|
|
|
128
|
1 |
|
public function close() |
129
|
|
|
{ |
130
|
1 |
|
$this->model->getProfile()->finalize(); |
131
|
1 |
|
return $this; |
132
|
|
|
} |
133
|
|
|
} |
134
|
|
|
|
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.