|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace NFePHP\DA\Legacy; |
|
4
|
|
|
|
|
5
|
|
|
use NFePHP\DA\Legacy\FPDF\Fpdf; |
|
6
|
|
|
|
|
7
|
|
|
class Pdf extends Fpdf |
|
8
|
|
|
{ |
|
9
|
|
|
|
|
10
|
|
|
private $t128; // tabela de codigos 128 |
|
11
|
|
|
private $abcSet=""; // conjunto de caracteres legiveis em 128 |
|
12
|
|
|
private $aSet=""; // grupo A do conjunto de de caracteres legiveis |
|
13
|
|
|
private $bSet=""; // grupo B do conjunto de caracteres legiveis |
|
14
|
|
|
private $cSet=""; // grupo C do conjunto de caracteres legiveis |
|
15
|
|
|
private $setFrom; // converter de |
|
16
|
|
|
private $setTo; // converter para |
|
17
|
|
|
private $jStart = array("A"=>103, "B"=>104, "C"=>105); // Caracteres de seleção do grupo 128 |
|
18
|
|
|
private $jSwap = array("A"=>101, "B"=>100, "C"=>99); // Caracteres de troca de grupo |
|
19
|
|
|
|
|
20
|
1 |
|
public function __construct($orientation = 'P', $unit = 'mm', $format = 'A4') |
|
21
|
|
|
{ |
|
22
|
|
|
//passar parametros para a classe principal |
|
23
|
1 |
|
parent::__construct($orientation, $unit, $format); |
|
24
|
|
|
// composição dos caracteres do barcode 128 |
|
25
|
1 |
|
$this->t128[] = array(2, 1, 2, 2, 2, 2); //0 : [ ] |
|
|
|
|
|
|
26
|
1 |
|
$this->t128[] = array(2, 2, 2, 1, 2, 2); //1 : [!] |
|
|
|
|
|
|
27
|
1 |
|
$this->t128[] = array(2, 2, 2, 2, 2, 1); //2 : ["] |
|
28
|
1 |
|
$this->t128[] = array(1, 2, 1, 2, 2, 3); //3 : [#] |
|
29
|
1 |
|
$this->t128[] = array(1, 2, 1, 3, 2, 2); //4 : [$] |
|
|
|
|
|
|
30
|
1 |
|
$this->t128[] = array(1, 3, 1, 2, 2, 2); //5 : [%] |
|
|
|
|
|
|
31
|
1 |
|
$this->t128[] = array(1, 2, 2, 2, 1, 3); //6 : [&] |
|
|
|
|
|
|
32
|
1 |
|
$this->t128[] = array(1, 2, 2, 3, 1, 2); //7 : ['] |
|
33
|
1 |
|
$this->t128[] = array(1, 3, 2, 2, 1, 2); //8 : [(] |
|
|
|
|
|
|
34
|
1 |
|
$this->t128[] = array(2, 2, 1, 2, 1, 3); //9 : [)] |
|
|
|
|
|
|
35
|
1 |
|
$this->t128[] = array(2, 2, 1, 3, 1, 2); //10 : [*] |
|
|
|
|
|
|
36
|
1 |
|
$this->t128[] = array(2, 3, 1, 2, 1, 2); //11 : [+] |
|
|
|
|
|
|
37
|
1 |
|
$this->t128[] = array(1, 1, 2, 2, 3, 2); //12 : [,] |
|
|
|
|
|
|
38
|
1 |
|
$this->t128[] = array(1, 2, 2, 1, 3, 2); //13 : [-] |
|
|
|
|
|
|
39
|
1 |
|
$this->t128[] = array(1, 2, 2, 2, 3, 1); //14 : [.] |
|
|
|
|
|
|
40
|
1 |
|
$this->t128[] = array(1, 1, 3, 2, 2, 2); //15 : [/] |
|
|
|
|
|
|
41
|
1 |
|
$this->t128[] = array(1, 2, 3, 1, 2, 2); //16 : [0] |
|
|
|
|
|
|
42
|
1 |
|
$this->t128[] = array(1, 2, 3, 2, 2, 1); //17 : [1] |
|
|
|
|
|
|
43
|
1 |
|
$this->t128[] = array(2, 2, 3, 2, 1, 1); //18 : [2] |
|
|
|
|
|
|
44
|
1 |
|
$this->t128[] = array(2, 2, 1, 1, 3, 2); //19 : [3] |
|
|
|
|
|
|
45
|
1 |
|
$this->t128[] = array(2, 2, 1, 2, 3, 1); //20 : [4] |
|
|
|
|
|
|
46
|
1 |
|
$this->t128[] = array(2, 1, 3, 2, 1, 2); //21 : [5] |
|
|
|
|
|
|
47
|
1 |
|
$this->t128[] = array(2, 2, 3, 1, 1, 2); //22 : [6] |
|
|
|
|
|
|
48
|
1 |
|
$this->t128[] = array(3, 1, 2, 1, 3, 1); //23 : [7] |
|
|
|
|
|
|
49
|
1 |
|
$this->t128[] = array(3, 1, 1, 2, 2, 2); //24 : [8] |
|
|
|
|
|
|
50
|
1 |
|
$this->t128[] = array(3, 2, 1, 1, 2, 2); //25 : [9] |
|
|
|
|
|
|
51
|
1 |
|
$this->t128[] = array(3, 2, 1, 2, 2, 1); //26 : [:] |
|
|
|
|
|
|
52
|
1 |
|
$this->t128[] = array(3, 1, 2, 2, 1, 2); //27 : [;] |
|
|
|
|
|
|
53
|
1 |
|
$this->t128[] = array(3, 2, 2, 1, 1, 2); //28 : [<] |
|
|
|
|
|
|
54
|
1 |
|
$this->t128[] = array(3, 2, 2, 2, 1, 1); //29 : [=] |
|
|
|
|
|
|
55
|
1 |
|
$this->t128[] = array(2, 1, 2, 1, 2, 3); //30 : [>] |
|
|
|
|
|
|
56
|
1 |
|
$this->t128[] = array(2, 1, 2, 3, 2, 1); //31 : [?] |
|
|
|
|
|
|
57
|
1 |
|
$this->t128[] = array(2, 3, 2, 1, 2, 1); //32 : [@] |
|
|
|
|
|
|
58
|
1 |
|
$this->t128[] = array(1, 1, 1, 3, 2, 3); //33 : [A] |
|
|
|
|
|
|
59
|
1 |
|
$this->t128[] = array(1, 3, 1, 1, 2, 3); //34 : [B] |
|
|
|
|
|
|
60
|
1 |
|
$this->t128[] = array(1, 3, 1, 3, 2, 1); //35 : [C] |
|
|
|
|
|
|
61
|
1 |
|
$this->t128[] = array(1, 1, 2, 3, 1, 3); //36 : [D] |
|
|
|
|
|
|
62
|
1 |
|
$this->t128[] = array(1, 3, 2, 1, 1, 3); //37 : [E] |
|
|
|
|
|
|
63
|
1 |
|
$this->t128[] = array(1, 3, 2, 3, 1, 1); //38 : [F] |
|
|
|
|
|
|
64
|
1 |
|
$this->t128[] = array(2, 1, 1, 3, 1, 3); //39 : [G] |
|
|
|
|
|
|
65
|
1 |
|
$this->t128[] = array(2, 3, 1, 1, 1, 3); //40 : [H] |
|
|
|
|
|
|
66
|
1 |
|
$this->t128[] = array(2, 3, 1, 3, 1, 1); //41 : [I] |
|
|
|
|
|
|
67
|
1 |
|
$this->t128[] = array(1, 1, 2, 1, 3, 3); //42 : [J] |
|
|
|
|
|
|
68
|
1 |
|
$this->t128[] = array(1, 1, 2, 3, 3, 1); //43 : [K] |
|
|
|
|
|
|
69
|
1 |
|
$this->t128[] = array(1, 3, 2, 1, 3, 1); //44 : [L] |
|
|
|
|
|
|
70
|
1 |
|
$this->t128[] = array(1, 1, 3, 1, 2, 3); //45 : [M] |
|
|
|
|
|
|
71
|
1 |
|
$this->t128[] = array(1, 1, 3, 3, 2, 1); //46 : [N] |
|
|
|
|
|
|
72
|
1 |
|
$this->t128[] = array(1, 3, 3, 1, 2, 1); //47 : [O] |
|
|
|
|
|
|
73
|
1 |
|
$this->t128[] = array(3, 1, 3, 1, 2, 1); //48 : [P] |
|
|
|
|
|
|
74
|
1 |
|
$this->t128[] = array(2, 1, 1, 3, 3, 1); //49 : [Q] |
|
|
|
|
|
|
75
|
1 |
|
$this->t128[] = array(2, 3, 1, 1, 3, 1); //50 : [R] |
|
|
|
|
|
|
76
|
1 |
|
$this->t128[] = array(2, 1, 3, 1, 1, 3); //51 : [S] |
|
|
|
|
|
|
77
|
1 |
|
$this->t128[] = array(2, 1, 3, 3, 1, 1); //52 : [T] |
|
|
|
|
|
|
78
|
1 |
|
$this->t128[] = array(2, 1, 3, 1, 3, 1); //53 : [U] |
|
|
|
|
|
|
79
|
1 |
|
$this->t128[] = array(3, 1, 1, 1, 2, 3); //54 : [V] |
|
|
|
|
|
|
80
|
1 |
|
$this->t128[] = array(3, 1, 1, 3, 2, 1); //55 : [W] |
|
|
|
|
|
|
81
|
1 |
|
$this->t128[] = array(3, 3, 1, 1, 2, 1); //56 : [X] |
|
|
|
|
|
|
82
|
1 |
|
$this->t128[] = array(3, 1, 2, 1, 1, 3); //57 : [Y] |
|
|
|
|
|
|
83
|
1 |
|
$this->t128[] = array(3, 1, 2, 3, 1, 1); //58 : [Z] |
|
|
|
|
|
|
84
|
1 |
|
$this->t128[] = array(3, 3, 2, 1, 1, 1); //59 : [[] |
|
|
|
|
|
|
85
|
1 |
|
$this->t128[] = array(3, 1, 4, 1, 1, 1); //60 : [\] |
|
|
|
|
|
|
86
|
1 |
|
$this->t128[] = array(2, 2, 1, 4, 1, 1); //61 : []] |
|
|
|
|
|
|
87
|
1 |
|
$this->t128[] = array(4, 3, 1, 1, 1, 1); //62 : [^] |
|
|
|
|
|
|
88
|
1 |
|
$this->t128[] = array(1, 1, 1, 2, 2, 4); //63 : [_] |
|
|
|
|
|
|
89
|
1 |
|
$this->t128[] = array(1, 1, 1, 4, 2, 2); //64 : [`] |
|
90
|
1 |
|
$this->t128[] = array(1, 2, 1, 1, 2, 4); //65 : [a] |
|
|
|
|
|
|
91
|
1 |
|
$this->t128[] = array(1, 2, 1, 4, 2, 1); //66 : [b] |
|
|
|
|
|
|
92
|
1 |
|
$this->t128[] = array(1, 4, 1, 1, 2, 2); //67 : [c] |
|
|
|
|
|
|
93
|
1 |
|
$this->t128[] = array(1, 4, 1, 2, 2, 1); //68 : [d] |
|
|
|
|
|
|
94
|
1 |
|
$this->t128[] = array(1, 1, 2, 2, 1, 4); //69 : [e] |
|
|
|
|
|
|
95
|
1 |
|
$this->t128[] = array(1, 1, 2, 4, 1, 2); //70 : [f] |
|
|
|
|
|
|
96
|
1 |
|
$this->t128[] = array(1, 2, 2, 1, 1, 4); //71 : [g] |
|
|
|
|
|
|
97
|
1 |
|
$this->t128[] = array(1, 2, 2, 4, 1, 1); //72 : [h] |
|
|
|
|
|
|
98
|
1 |
|
$this->t128[] = array(1, 4, 2, 1, 1, 2); //73 : [i] |
|
|
|
|
|
|
99
|
1 |
|
$this->t128[] = array(1, 4, 2, 2, 1, 1); //74 : [j] |
|
|
|
|
|
|
100
|
1 |
|
$this->t128[] = array(2, 4, 1, 2, 1, 1); //75 : [k] |
|
|
|
|
|
|
101
|
1 |
|
$this->t128[] = array(2, 2, 1, 1, 1, 4); //76 : [l] |
|
|
|
|
|
|
102
|
1 |
|
$this->t128[] = array(4, 1, 3, 1, 1, 1); //77 : [m] |
|
|
|
|
|
|
103
|
1 |
|
$this->t128[] = array(2, 4, 1, 1, 1, 2); //78 : [n] |
|
|
|
|
|
|
104
|
1 |
|
$this->t128[] = array(1, 3, 4, 1, 1, 1); //79 : [o] |
|
|
|
|
|
|
105
|
1 |
|
$this->t128[] = array(1, 1, 1, 2, 4, 2); //80 : [p] |
|
|
|
|
|
|
106
|
1 |
|
$this->t128[] = array(1, 2, 1, 1, 4, 2); //81 : [q] |
|
|
|
|
|
|
107
|
1 |
|
$this->t128[] = array(1, 2, 1, 2, 4, 1); //82 : [r] |
|
|
|
|
|
|
108
|
1 |
|
$this->t128[] = array(1, 1, 4, 2, 1, 2); //83 : [s] |
|
|
|
|
|
|
109
|
1 |
|
$this->t128[] = array(1, 2, 4, 1, 1, 2); //84 : [t] |
|
|
|
|
|
|
110
|
1 |
|
$this->t128[] = array(1, 2, 4, 2, 1, 1); //85 : [u] |
|
|
|
|
|
|
111
|
1 |
|
$this->t128[] = array(4, 1, 1, 2, 1, 2); //86 : [v] |
|
|
|
|
|
|
112
|
1 |
|
$this->t128[] = array(4, 2, 1, 1, 1, 2); //87 : [w] |
|
|
|
|
|
|
113
|
1 |
|
$this->t128[] = array(4, 2, 1, 2, 1, 1); //88 : [x] |
|
|
|
|
|
|
114
|
1 |
|
$this->t128[] = array(2, 1, 2, 1, 4, 1); //89 : [y] |
|
|
|
|
|
|
115
|
1 |
|
$this->t128[] = array(2, 1, 4, 1, 2, 1); //90 : [z] |
|
|
|
|
|
|
116
|
1 |
|
$this->t128[] = array(4, 1, 2, 1, 2, 1); //91 : [{] |
|
|
|
|
|
|
117
|
1 |
|
$this->t128[] = array(1, 1, 1, 1, 4, 3); //92 : [|] |
|
|
|
|
|
|
118
|
1 |
|
$this->t128[] = array(1, 1, 1, 3, 4, 1); //93 : [}] |
|
|
|
|
|
|
119
|
1 |
|
$this->t128[] = array(1, 3, 1, 1, 4, 1); //94 : [~] |
|
|
|
|
|
|
120
|
1 |
|
$this->t128[] = array(1, 1, 4, 1, 1, 3); //95 : [DEL] |
|
|
|
|
|
|
121
|
1 |
|
$this->t128[] = array(1, 1, 4, 3, 1, 1); //96 : [FNC3] |
|
|
|
|
|
|
122
|
1 |
|
$this->t128[] = array(4, 1, 1, 1, 1, 3); //97 : [FNC2] |
|
|
|
|
|
|
123
|
1 |
|
$this->t128[] = array(4, 1, 1, 3, 1, 1); //98 : [SHIFT] |
|
|
|
|
|
|
124
|
1 |
|
$this->t128[] = array(1, 1, 3, 1, 4, 1); //99 : [Cswap] |
|
|
|
|
|
|
125
|
1 |
|
$this->t128[] = array(1, 1, 4, 1, 3, 1); //100 : [Bswap] |
|
|
|
|
|
|
126
|
1 |
|
$this->t128[] = array(3, 1, 1, 1, 4, 1); //101 : [Aswap] |
|
|
|
|
|
|
127
|
1 |
|
$this->t128[] = array(4, 1, 1, 1, 3, 1); //102 : [FNC1] |
|
|
|
|
|
|
128
|
1 |
|
$this->t128[] = array(2, 1, 1, 4, 1, 2); //103 : [Astart] |
|
|
|
|
|
|
129
|
1 |
|
$this->t128[] = array(2, 1, 1, 2, 1, 4); //104 : [Bstart] |
|
|
|
|
|
|
130
|
1 |
|
$this->t128[] = array(2, 1, 1, 2, 3, 2); //105 : [Cstart] |
|
|
|
|
|
|
131
|
1 |
|
$this->t128[] = array(2, 3, 3, 1, 1, 1); //106 : [STOP] |
|
|
|
|
|
|
132
|
1 |
|
$this->t128[] = array(2, 1); //107 : [END BAR] |
|
|
|
|
|
|
133
|
1 |
|
for ($i = 32; $i <= 95; $i++) { // conjunto de caracteres |
|
134
|
1 |
|
$this->abcSet .= chr($i); |
|
135
|
|
|
} |
|
136
|
1 |
|
$this->aSet = $this->abcSet; |
|
137
|
1 |
|
$this->bSet = $this->abcSet; |
|
138
|
1 |
|
for ($i = 0; $i <= 31; $i++) { |
|
139
|
1 |
|
$this->abcSet .= chr($i); |
|
140
|
1 |
|
$this->aSet .= chr($i); |
|
141
|
|
|
} |
|
142
|
1 |
|
for ($i = 96; $i <= 126; $i++) { |
|
143
|
1 |
|
$this->abcSet .= chr($i); |
|
144
|
1 |
|
$this->bSet .= chr($i); |
|
145
|
|
|
} |
|
146
|
1 |
|
$this->cSet="0123456789"; |
|
147
|
1 |
|
for ($i = 0; $i < 96; $i++) { |
|
148
|
|
|
// convertendo grupos A & B |
|
149
|
1 |
|
if (isset($this->setFrom["A"])) { |
|
150
|
|
|
$this->setFrom["A"] .= chr($i); |
|
151
|
|
|
} |
|
152
|
1 |
|
if (isset($this->setFrom["B"])) { |
|
153
|
|
|
$this->setFrom["B"] .= chr($i + 32); |
|
154
|
|
|
} |
|
155
|
1 |
|
if (isset($this->setTo["A"])) { |
|
156
|
|
|
$this->setTo["A"] .= chr(($i < 32) ? $i+64 : $i-32); |
|
157
|
|
|
} |
|
158
|
1 |
|
if (isset($this->setTo["A"])) { |
|
159
|
|
|
$this->setTo["B"] .= chr($i); |
|
160
|
|
|
} |
|
161
|
|
|
} |
|
162
|
1 |
|
} |
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
|
|
* Code128 |
|
166
|
|
|
* Imprime barcode 128 |
|
167
|
|
|
*/ |
|
168
|
1 |
|
public function code128($x, $y, $code, $w, $h) |
|
169
|
|
|
{ |
|
170
|
1 |
|
$Aguid=""; |
|
171
|
1 |
|
$Bguid=""; |
|
172
|
1 |
|
$Cguid=""; |
|
173
|
1 |
|
for ($i=0; $i < strlen($code); $i++) { |
|
174
|
1 |
|
$needle=substr($code, $i, 1); |
|
175
|
1 |
|
$Aguid .= ((strpos($this->aSet, $needle)===false) ? "N" : "O"); |
|
176
|
1 |
|
$Bguid .= ((strpos($this->bSet, $needle)===false) ? "N" : "O"); |
|
177
|
1 |
|
$Cguid .= ((strpos($this->cSet, $needle)===false) ? "N" : "O"); |
|
178
|
|
|
} |
|
179
|
1 |
|
$SminiC = "OOOO"; |
|
180
|
1 |
|
$IminiC = 4; |
|
181
|
1 |
|
$crypt = ""; |
|
182
|
1 |
|
while ($code > "") { |
|
183
|
1 |
|
$i = strpos($Cguid, $SminiC); |
|
184
|
1 |
|
if ($i!==false) { |
|
185
|
1 |
|
$Aguid [$i] = "N"; |
|
186
|
1 |
|
$Bguid [$i] = "N"; |
|
187
|
|
|
} |
|
188
|
1 |
|
if (substr($Cguid, 0, $IminiC) == $SminiC) { |
|
189
|
1 |
|
$crypt .= chr(($crypt > "") ? $this->jSwap["C"] : $this->jStart["C"]); |
|
190
|
1 |
|
$made = strpos($Cguid, "N"); |
|
191
|
1 |
|
if ($made === false) { |
|
192
|
1 |
|
$made = strlen($Cguid); |
|
193
|
|
|
} |
|
194
|
1 |
|
if (fmod($made, 2)==1) { |
|
195
|
|
|
$made--; |
|
196
|
|
|
} |
|
197
|
1 |
|
for ($i=0; $i < $made; |
|
198
|
|
|
$i += 2) { |
|
199
|
1 |
|
$crypt .= chr(strval(substr($code, $i, 2))); |
|
200
|
|
|
} |
|
201
|
1 |
|
$jeu = "C"; |
|
|
|
|
|
|
202
|
|
|
} else { |
|
203
|
|
|
$madeA = strpos($Aguid, "N"); |
|
204
|
|
|
if ($madeA === false) { |
|
205
|
|
|
$madeA = strlen($Aguid); |
|
206
|
|
|
} |
|
207
|
|
|
$madeB = strpos($Bguid, "N"); |
|
208
|
|
|
if ($madeB === false) { |
|
209
|
|
|
$madeB = strlen($Bguid); |
|
210
|
|
|
} |
|
211
|
|
|
$made = (($madeA < $madeB) ? $madeB : $madeA ); |
|
212
|
|
|
$jeu = (($madeA < $madeB) ? "B" : "A" ); |
|
213
|
|
|
$jeuguid = $jeu . "guid"; |
|
|
|
|
|
|
214
|
|
|
$crypt .= chr(($crypt > "") ? $this->jSwap["$jeu"] : $this->jStart["$jeu"]); |
|
215
|
|
|
$crypt .= strtr(substr($code, 0, $made), $this->setFrom[$jeu], $this->setTo[$jeu]); |
|
216
|
|
|
} |
|
217
|
1 |
|
$code = substr($code, $made); |
|
218
|
1 |
|
$Aguid = substr($Aguid, $made); |
|
219
|
1 |
|
$Bguid = substr($Bguid, $made); |
|
220
|
1 |
|
$Cguid = substr($Cguid, $made); |
|
221
|
|
|
} |
|
222
|
1 |
|
$check = ord($crypt[0]); |
|
223
|
1 |
|
for ($i=0; $i<strlen($crypt); $i++) { |
|
224
|
1 |
|
$check += (ord($crypt[$i]) * $i); |
|
225
|
|
|
} |
|
226
|
1 |
|
$check %= 103; |
|
227
|
1 |
|
$crypt .= chr($check) . chr(106) . chr(107); |
|
228
|
1 |
|
$i = (strlen($crypt) * 11) - 8; |
|
229
|
1 |
|
$modul = $w/$i; |
|
230
|
1 |
|
for ($i=0; $i<strlen($crypt); $i++) { |
|
231
|
1 |
|
$c = $this->t128[ord($crypt[$i])]; |
|
232
|
1 |
|
for ($j=0; $j<count($c); $j++) { |
|
|
|
|
|
|
233
|
1 |
|
$this->Rect($x, $y, $c[$j]*$modul, $h, "F"); |
|
234
|
1 |
|
$x += ($c[$j++]+$c[$j])*$modul; |
|
235
|
|
|
} |
|
236
|
|
|
} |
|
237
|
1 |
|
} |
|
238
|
|
|
|
|
239
|
|
|
/** |
|
240
|
|
|
* rotate |
|
241
|
|
|
* Rotaciona para impressão paisagem (landscape) |
|
242
|
|
|
* @param number $angle |
|
243
|
|
|
* @param number $x |
|
244
|
|
|
* @param number $y |
|
245
|
|
|
*/ |
|
246
|
|
|
public function rotate($angle, $x = -1, $y = -1) |
|
247
|
|
|
{ |
|
248
|
|
|
if ($x == -1) { |
|
249
|
|
|
$x = $this->x; |
|
250
|
|
|
} |
|
251
|
|
|
if ($y == -1) { |
|
252
|
|
|
$y = $this->y; |
|
253
|
|
|
} |
|
254
|
|
|
if (isset($this->angle) && $this->angle != 0) { |
|
|
|
|
|
|
255
|
|
|
$this->out('Q'); |
|
256
|
|
|
} |
|
257
|
|
|
$this->angle = $angle; |
|
258
|
|
|
if ($angle != 0) { |
|
259
|
|
|
$angle *= M_PI/180; |
|
260
|
|
|
$c = cos($angle); |
|
261
|
|
|
$s = sin($angle); |
|
262
|
|
|
$cx =$x*$this->k; |
|
263
|
|
|
$cy = ($this->h-$y)*$this->k; |
|
264
|
|
|
$this->out( |
|
265
|
|
|
sprintf( |
|
266
|
|
|
'q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm', |
|
267
|
|
|
$c, |
|
268
|
|
|
$s, |
|
269
|
|
|
-$s, |
|
270
|
|
|
$c, |
|
271
|
|
|
$cx, |
|
272
|
|
|
$cy, |
|
273
|
|
|
-$cx, |
|
274
|
|
|
-$cy |
|
275
|
|
|
) |
|
276
|
|
|
); |
|
277
|
|
|
} |
|
278
|
|
|
} |
|
279
|
|
|
|
|
280
|
|
|
/** |
|
281
|
|
|
* roundedRect |
|
282
|
|
|
* Desenha um retangulo com cantos arredondados |
|
283
|
|
|
* @param number $x |
|
284
|
|
|
* @param number $y |
|
285
|
|
|
* @param number $w |
|
286
|
|
|
* @param number $h |
|
287
|
|
|
* @param number $r |
|
288
|
|
|
* @param string $corners |
|
289
|
|
|
* @param string $style |
|
290
|
|
|
*/ |
|
291
|
1 |
|
public function roundedRect($x, $y, $w, $h, $r, $corners = '1234', $style = '') |
|
292
|
|
|
{ |
|
293
|
1 |
|
$k = $this->k; |
|
294
|
1 |
|
$hp = $this->h; |
|
295
|
1 |
|
if ($style == 'F') { |
|
296
|
|
|
$op = 'f'; |
|
297
|
1 |
|
} elseif ($style == 'FD' || $style == 'DF') { |
|
298
|
|
|
$op = 'B'; |
|
299
|
|
|
} else { |
|
300
|
1 |
|
$op = 'S'; |
|
301
|
|
|
} |
|
302
|
1 |
|
$MyArc = 4/3 * (sqrt(2) - 1); |
|
303
|
1 |
|
$this->out(sprintf('%.2F %.2F m', ($x+$r)*$k, ($hp-$y)*$k)); |
|
304
|
1 |
|
$xc = $x+$w-$r; |
|
305
|
1 |
|
$yc = $y+$r; |
|
306
|
1 |
|
$this->out(sprintf('%.2F %.2F l', $xc*$k, ($hp-$y)*$k)); |
|
307
|
1 |
|
if (strpos($corners, '2')===false) { |
|
308
|
|
|
$this->out(sprintf('%.2F %.2F l', ($x+$w)*$k, ($hp-$y)*$k)); |
|
309
|
|
|
} else { |
|
310
|
1 |
|
$this->arc($xc + $r*$MyArc, $yc - $r, $xc + $r, $yc - $r*$MyArc, $xc + $r, $yc); |
|
311
|
|
|
} |
|
312
|
1 |
|
$xc = $x+$w-$r; |
|
313
|
1 |
|
$yc = $y+$h-$r; |
|
314
|
1 |
|
$this->out(sprintf('%.2F %.2F l', ($x+$w)*$k, ($hp-$yc)*$k)); |
|
315
|
1 |
|
if (strpos($corners, '3')===false) { |
|
316
|
|
|
$this->out(sprintf('%.2F %.2F l', ($x+$w)*$k, ($hp-($y+$h))*$k)); |
|
317
|
|
|
} else { |
|
318
|
1 |
|
$this->arc($xc + $r, $yc + $r*$MyArc, $xc + $r*$MyArc, $yc + $r, $xc, $yc + $r); |
|
319
|
|
|
} |
|
320
|
1 |
|
$xc = $x+$r; |
|
321
|
1 |
|
$yc = $y+$h-$r; |
|
322
|
1 |
|
$this->out(sprintf('%.2F %.2F l', $xc*$k, ($hp-($y+$h))*$k)); |
|
323
|
1 |
|
if (strpos($corners, '4')===false) { |
|
324
|
|
|
$this->out(sprintf('%.2F %.2F l', ($x)*$k, ($hp-($y+$h))*$k)); |
|
325
|
|
|
} else { |
|
326
|
1 |
|
$this->arc($xc - $r*$MyArc, $yc + $r, $xc - $r, $yc + $r*$MyArc, $xc - $r, $yc); |
|
327
|
|
|
} |
|
328
|
1 |
|
$xc = $x+$r ; |
|
329
|
1 |
|
$yc = $y+$r; |
|
330
|
1 |
|
$this->out(sprintf('%.2F %.2F l', ($x)*$k, ($hp-$yc)*$k)); |
|
331
|
1 |
|
if (strpos($corners, '1')===false) { |
|
332
|
|
|
$this->out(sprintf('%.2F %.2F l', ($x)*$k, ($hp-$y)*$k)); |
|
333
|
|
|
$this->out(sprintf('%.2F %.2F l', ($x+$r)*$k, ($hp-$y)*$k)); |
|
334
|
|
|
} else { |
|
335
|
1 |
|
$this->arc($xc - $r, $yc - $r*$MyArc, $xc - $r*$MyArc, $yc - $r, $xc, $yc - $r); |
|
336
|
|
|
} |
|
337
|
1 |
|
$this->out($op); |
|
338
|
1 |
|
} |
|
339
|
|
|
|
|
340
|
|
|
/** |
|
341
|
|
|
* arc |
|
342
|
|
|
* Desenha o arco para arredondar o canto do retangulo |
|
343
|
|
|
* @param number $x1 |
|
344
|
|
|
* @param number $y1 |
|
345
|
|
|
* @param number $x2 |
|
346
|
|
|
* @param number $y2 |
|
347
|
|
|
* @param number $x3 |
|
348
|
|
|
* @param number $y3 |
|
349
|
|
|
*/ |
|
350
|
1 |
|
private function arc($x1, $y1, $x2, $y2, $x3, $y3) |
|
351
|
|
|
{ |
|
352
|
1 |
|
$h = $this->h; |
|
353
|
1 |
|
$this->out( |
|
354
|
|
|
sprintf( |
|
355
|
1 |
|
'%.2F %.2F %.2F %.2F %.2F %.2F c ', |
|
356
|
1 |
|
$x1*$this->k, |
|
357
|
1 |
|
($h-$y1)*$this->k, |
|
358
|
1 |
|
$x2*$this->k, |
|
359
|
1 |
|
($h-$y2)*$this->k, |
|
360
|
1 |
|
$x3*$this->k, |
|
361
|
1 |
|
($h-$y3)*$this->k |
|
362
|
|
|
) |
|
363
|
|
|
); |
|
364
|
1 |
|
} |
|
365
|
|
|
|
|
366
|
|
|
/** |
|
367
|
|
|
* dashedRect |
|
368
|
|
|
* Desenha um retangulo com linhas tracejadas |
|
369
|
|
|
* @param number $x1 |
|
370
|
|
|
* @param number $y1 |
|
371
|
|
|
* @param number $x2 |
|
372
|
|
|
* @param number $y2 |
|
373
|
|
|
* @param number $width |
|
374
|
|
|
* @param number $nb |
|
375
|
|
|
*/ |
|
376
|
|
|
public function dashedRect($x1, $y1, $x2, $y2, $width = 1, $nb = 15) |
|
377
|
|
|
{ |
|
378
|
|
|
$this->setLineWidth($width); |
|
379
|
|
|
$longueur = abs($x1-$x2); |
|
380
|
|
|
$hauteur = abs($y1-$y2); |
|
381
|
|
|
if ($longueur > $hauteur) { |
|
382
|
|
|
$Pointilles = ($longueur/$nb)/2; |
|
383
|
|
|
} else { |
|
384
|
|
|
$Pointilles = ($hauteur/$nb)/2; |
|
385
|
|
|
} |
|
386
|
|
|
for ($i=$x1; $i<=$x2; $i+=$Pointilles+$Pointilles) { |
|
387
|
|
|
for ($j=$i; $j<=($i+$Pointilles); $j++) { |
|
388
|
|
|
if ($j<=($x2-1)) { |
|
389
|
|
|
$this->line($j, $y1, $j+1, $y1); |
|
390
|
|
|
$this->line($j, $y2, $j+1, $y2); |
|
391
|
|
|
} |
|
392
|
|
|
} |
|
393
|
|
|
} |
|
394
|
|
|
for ($i=$y1; $i<=$y2; $i+=$Pointilles+$Pointilles) { |
|
395
|
|
|
for ($j=$i; $j<=($i+$Pointilles); $j++) { |
|
396
|
|
|
if ($j<=($y2-1)) { |
|
397
|
|
|
$this->line($x1, $j, $x1, $j+1); |
|
398
|
|
|
$this->line($x2, $j, $x2, $j+1); |
|
399
|
|
|
} |
|
400
|
|
|
} |
|
401
|
|
|
} |
|
402
|
|
|
}//fim DashedRect |
|
403
|
|
|
|
|
404
|
|
|
/** |
|
405
|
|
|
* drawTextBox |
|
406
|
|
|
* Monta uma caixa de texto |
|
407
|
|
|
* @param string $strText |
|
408
|
|
|
* @param number $w |
|
409
|
|
|
* @param number $h |
|
410
|
|
|
* @param string $align |
|
411
|
|
|
* @param string $valign |
|
412
|
|
|
* @param boolean $border |
|
413
|
|
|
*/ |
|
414
|
|
|
public function drawTextBox($strText, $w, $h, $align = 'L', $valign = 'T', $border = true) |
|
415
|
|
|
{ |
|
416
|
|
|
$xi = $this->getX(); |
|
417
|
|
|
$yi = $this->getY(); |
|
418
|
|
|
$hrow = $this->fontSize; |
|
419
|
|
|
$textrows = $this->drawRows($w, $hrow, $strText, 0, $align, 0, 0, 0); |
|
|
|
|
|
|
420
|
|
|
$maxrows = floor($h/$this->fontSize); |
|
421
|
|
|
$rows = min($textrows, $maxrows); |
|
422
|
|
|
$dy = 0; |
|
423
|
|
|
if (strtoupper($valign) == 'M') { |
|
424
|
|
|
$dy = ($h-$rows*$this->fontSize)/2; |
|
425
|
|
|
} |
|
426
|
|
|
if (strtoupper($valign) == 'B') { |
|
427
|
|
|
$dy = $h-$rows*$this->fontSize; |
|
428
|
|
|
} |
|
429
|
|
|
$this->setY($yi+$dy); |
|
430
|
|
|
$this->setX($xi); |
|
431
|
|
|
$this->drawRows($w, $hrow, $strText, 0, $align, false, $rows, 1); |
|
432
|
|
|
if ($border) { |
|
433
|
|
|
$this->rect($xi, $yi, $w, $h); |
|
434
|
|
|
} |
|
435
|
|
|
} |
|
436
|
|
|
|
|
437
|
|
|
/** |
|
438
|
|
|
* _drawRows |
|
439
|
|
|
* Insere linhas de texto na caixa |
|
440
|
|
|
* @param number $w |
|
441
|
|
|
* @param number $h |
|
442
|
|
|
* @param string $txt |
|
443
|
|
|
* @param string $border |
|
444
|
|
|
* @param string $align |
|
445
|
|
|
* @param boolean $fill |
|
446
|
|
|
* @param number $maxline |
|
447
|
|
|
* @param number $prn |
|
448
|
|
|
* @return int |
|
449
|
|
|
*/ |
|
450
|
|
|
private function drawRows($w, $h, $txt, $border = 0, $align = 'J', $fill = false, $maxline = 0, $prn = 0) |
|
451
|
|
|
{ |
|
452
|
|
|
$cw =& $this->currentFont['cw']; |
|
453
|
|
|
if ($w == 0) { |
|
454
|
|
|
$w = $this->w-$this->rMargin-$this->x; |
|
455
|
|
|
} |
|
456
|
|
|
$wmax = ($w-2*$this->cMargin)*1000/$this->fontSize; |
|
457
|
|
|
$s = str_replace("\r", '', $txt); |
|
458
|
|
|
$nb = strlen($s); |
|
459
|
|
|
if ($nb > 0 && $s[$nb-1] == "\n") { |
|
460
|
|
|
$nb--; |
|
461
|
|
|
} |
|
462
|
|
|
$b=0; |
|
463
|
|
|
if ($border) { |
|
464
|
|
|
if ($border == 1) { |
|
465
|
|
|
$border = 'LTRB'; |
|
466
|
|
|
$b = 'LRT'; |
|
467
|
|
|
$b2 = 'LR'; |
|
468
|
|
|
} else { |
|
469
|
|
|
$b2 = ''; |
|
470
|
|
|
if (is_int(strpos($border, 'L'))) { |
|
471
|
|
|
$b2 .= 'L'; |
|
472
|
|
|
} |
|
473
|
|
|
if (is_int(strpos($border, 'R'))) { |
|
474
|
|
|
$b2 .= 'R'; |
|
475
|
|
|
} |
|
476
|
|
|
$b = is_int(strpos($border, 'T')) ? $b2.'T' : $b2; |
|
477
|
|
|
} |
|
478
|
|
|
} |
|
479
|
|
|
$sep = -1; |
|
480
|
|
|
$i = 0; |
|
481
|
|
|
$j = 0; |
|
482
|
|
|
$l = 0; |
|
483
|
|
|
$ns = 0; |
|
484
|
|
|
$nl = 1; |
|
485
|
|
|
while ($i < $nb) { |
|
486
|
|
|
$c = $s[$i]; |
|
487
|
|
|
if ($c == "\n") { |
|
488
|
|
|
if ($this->ws > 0) { |
|
489
|
|
|
$this->ws = 0; |
|
490
|
|
|
if ($prn == 1) { |
|
491
|
|
|
$this->out('0 Tw'); |
|
492
|
|
|
} |
|
493
|
|
|
} |
|
494
|
|
|
if ($prn == 1) { |
|
495
|
|
|
$this->cell($w, $h, substr($s, $j, $i-$j), $b, 2, $align, $fill); |
|
496
|
|
|
} |
|
497
|
|
|
$i++; |
|
498
|
|
|
$sep = -1; |
|
499
|
|
|
$j = $i; |
|
500
|
|
|
$l = 0; |
|
501
|
|
|
$ns = 0; |
|
502
|
|
|
$nl++; |
|
503
|
|
|
if ($border && $nl == 2) { |
|
504
|
|
|
$b = $b2; |
|
|
|
|
|
|
505
|
|
|
} |
|
506
|
|
|
if ($maxline && $nl > $maxline) { |
|
507
|
|
|
return substr($s, $i); |
|
508
|
|
|
} |
|
509
|
|
|
continue; |
|
510
|
|
|
} |
|
511
|
|
|
if ($c == ' ') { |
|
512
|
|
|
$sep = $i; |
|
513
|
|
|
$ls = $l; |
|
514
|
|
|
$ns++; |
|
515
|
|
|
} |
|
516
|
|
|
$l += $cw[$c]; |
|
517
|
|
|
if ($l > $wmax) { |
|
518
|
|
|
if ($sep == -1) { |
|
519
|
|
|
if ($i == $j) { |
|
520
|
|
|
$i++; |
|
521
|
|
|
} |
|
522
|
|
|
if ($this->ws > 0) { |
|
523
|
|
|
$this->ws = 0; |
|
524
|
|
|
if ($prn == 1) { |
|
525
|
|
|
$this->out('0 Tw'); |
|
526
|
|
|
} |
|
527
|
|
|
} |
|
528
|
|
|
if ($prn == 1) { |
|
529
|
|
|
$this->cell($w, $h, substr($s, $j, $i-$j), $b, 2, $align, $fill); |
|
530
|
|
|
} |
|
531
|
|
|
} else { |
|
532
|
|
|
if ($align == 'J') { |
|
533
|
|
|
$this->ws = ($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0; |
|
|
|
|
|
|
534
|
|
|
if ($prn == 1) { |
|
535
|
|
|
$this->out(sprintf('%.3F Tw', $this->ws*$this->k)); |
|
536
|
|
|
} |
|
537
|
|
|
} |
|
538
|
|
|
if ($prn == 1) { |
|
539
|
|
|
$this->cell($w, $h, substr($s, $j, $sep-$j), $b, 2, $align, $fill); |
|
540
|
|
|
} |
|
541
|
|
|
$i = $sep+1; |
|
542
|
|
|
} |
|
543
|
|
|
$sep = -1; |
|
544
|
|
|
$j = $i; |
|
545
|
|
|
$l = 0; |
|
546
|
|
|
$ns = 0; |
|
547
|
|
|
$nl++; |
|
548
|
|
|
if ($border && $nl == 2) { |
|
549
|
|
|
$b = $b2; |
|
550
|
|
|
} |
|
551
|
|
|
if ($maxline && $nl > $maxline) { |
|
552
|
|
|
return substr($s, $i); |
|
553
|
|
|
} |
|
554
|
|
|
} else { |
|
555
|
|
|
$i++; |
|
556
|
|
|
} |
|
557
|
|
|
} |
|
558
|
|
|
if ($this->ws > 0) { |
|
559
|
|
|
$this->ws = 0; |
|
560
|
|
|
if ($prn == 1) { |
|
561
|
|
|
$this->out('0 Tw'); |
|
562
|
|
|
} |
|
563
|
|
|
} |
|
564
|
|
|
if ($border && is_int(strpos($border, 'B'))) { |
|
565
|
|
|
$b .= 'B'; |
|
566
|
|
|
} |
|
567
|
|
|
if ($prn == 1) { |
|
568
|
|
|
$this->cell($w, $h, substr($s, $j, $i-$j), $b, 2, $align, $fill); |
|
569
|
|
|
} |
|
570
|
|
|
$this->x = $this->lMargin; |
|
571
|
|
|
return $nl; |
|
572
|
|
|
} |
|
573
|
|
|
|
|
574
|
|
|
/** |
|
575
|
|
|
* WordWrap |
|
576
|
|
|
* Quebra o texto para caber na caixa |
|
577
|
|
|
* @param type $text |
|
578
|
|
|
* @param type $maxwidth |
|
579
|
|
|
* @return int |
|
580
|
|
|
*/ |
|
581
|
1 |
|
public function wordWrap(&$text, $maxwidth) |
|
582
|
|
|
{ |
|
583
|
1 |
|
$text = trim($text); |
|
584
|
1 |
|
if ($text === '') { |
|
585
|
|
|
return 0; |
|
586
|
|
|
} |
|
587
|
1 |
|
$space = $this->getStringWidth(' '); |
|
588
|
1 |
|
$lines = explode("\n", $text); |
|
589
|
1 |
|
$text = ''; |
|
590
|
1 |
|
$count = 0; |
|
591
|
1 |
|
foreach ($lines as $line) { |
|
592
|
1 |
|
$words = preg_split('/ +/', $line); |
|
593
|
1 |
|
$width = 0; |
|
594
|
1 |
|
foreach ($words as $word) { |
|
595
|
1 |
|
$wordwidth = $this->getStringWidth($word); |
|
596
|
1 |
|
if ($wordwidth > $maxwidth) { |
|
597
|
|
|
// Word is too long, we cut it |
|
598
|
|
|
for ($i=0; $i<strlen($word); $i++) { |
|
599
|
|
|
$wordwidth = $this->getStringWidth(substr($word, $i, 1)); |
|
600
|
|
|
if ($width + $wordwidth <= $maxwidth) { |
|
601
|
|
|
$width += $wordwidth; |
|
602
|
|
|
$text .= substr($word, $i, 1); |
|
603
|
|
|
} else { |
|
604
|
|
|
$width = $wordwidth; |
|
605
|
|
|
$text = rtrim($text)."\n".substr($word, $i, 1); |
|
606
|
|
|
$count++; |
|
607
|
|
|
} |
|
608
|
|
|
} |
|
609
|
1 |
|
} elseif ($width + $wordwidth <= $maxwidth) { |
|
610
|
1 |
|
$width += $wordwidth + $space; |
|
611
|
1 |
|
$text .= $word.' '; |
|
612
|
|
|
} else { |
|
613
|
|
|
$width = $wordwidth + $space; |
|
614
|
|
|
$text = rtrim($text)."\n".$word.' '; |
|
615
|
1 |
|
$count++; |
|
616
|
|
|
} |
|
617
|
|
|
} |
|
618
|
1 |
|
$text = rtrim($text)."\n"; |
|
619
|
1 |
|
$count++; |
|
620
|
|
|
} |
|
621
|
1 |
|
$text = rtrim($text); |
|
622
|
1 |
|
return $count; |
|
623
|
|
|
} |
|
624
|
|
|
|
|
625
|
|
|
/** |
|
626
|
|
|
* CellFit |
|
627
|
|
|
* Celula com escala horizontal caso o texto seja muito largo |
|
628
|
|
|
* @param number $w |
|
629
|
|
|
* @param number $h |
|
630
|
|
|
* @param string $txt |
|
631
|
|
|
* @param number $border |
|
632
|
|
|
* @param number $ln |
|
633
|
|
|
* @param string $align |
|
634
|
|
|
* @param boolean $fill |
|
635
|
|
|
* @param string $link |
|
636
|
|
|
* @param boolean $scale |
|
637
|
|
|
* @param boolean $force |
|
638
|
|
|
*/ |
|
639
|
|
|
public function cellFit( |
|
640
|
|
|
$w, |
|
641
|
|
|
$h = 0, |
|
642
|
|
|
$txt = '', |
|
643
|
|
|
$border = 0, |
|
644
|
|
|
$ln = 0, |
|
645
|
|
|
$align = '', |
|
646
|
|
|
$fill = false, |
|
647
|
|
|
$link = '', |
|
648
|
|
|
$scale = false, |
|
649
|
|
|
$force = true |
|
650
|
|
|
) { |
|
651
|
|
|
$str_width=$this->getStringWidth($txt); |
|
652
|
|
|
if ($w == 0) { |
|
653
|
|
|
$w = $this->w-$this->rMargin-$this->x; |
|
654
|
|
|
} |
|
655
|
|
|
$ratio = ($w-$this->cMargin*2)/$str_width; |
|
656
|
|
|
$fit = ($ratio < 1 || ($ratio > 1 && $force)); |
|
657
|
|
|
if ($fit) { |
|
658
|
|
|
if ($scale) { |
|
659
|
|
|
//Calcula a escala horizontal |
|
660
|
|
|
$horiz_scale = $ratio*100.0; |
|
661
|
|
|
//Ajusta a escala horizontal |
|
662
|
|
|
$this->out(sprintf('BT %.2F Tz ET', $horiz_scale)); |
|
663
|
|
|
} else { |
|
664
|
|
|
//Calcula o espaçamento de caracteres em pontos |
|
665
|
|
|
$char_space = ($w-$this->cMargin*2-$str_width)/max($this->_MBGetStringLength($txt)-1, 1)*$this->k; |
|
|
|
|
|
|
666
|
|
|
//Ajusta o espaçamento de caracteres |
|
667
|
|
|
$this->out(sprintf('BT %.2F Tc ET', $char_space)); |
|
668
|
|
|
} |
|
669
|
|
|
//Sobrescreve o alinhamento informado (desde que o texto caiba na celula) |
|
670
|
|
|
$align = ''; |
|
671
|
|
|
} |
|
672
|
|
|
//Passa para o método cell |
|
673
|
|
|
$this->cell($w, $h, $txt, $border, $ln, $align, $fill, $link); |
|
674
|
|
|
//Reseta o espaçamento de caracteres e a escala horizontal |
|
675
|
|
|
if ($fit) { |
|
676
|
|
|
$this->out('BT '.($scale ? '100 Tz' : '0 Tc').' ET'); |
|
677
|
|
|
} |
|
678
|
|
|
} |
|
679
|
|
|
|
|
680
|
|
|
/** |
|
681
|
|
|
* CellFitScale |
|
682
|
|
|
* Celula com escalamento horizontal somente se necessário |
|
683
|
|
|
* @param number $w |
|
684
|
|
|
* @param number $h |
|
685
|
|
|
* @param string $txt |
|
686
|
|
|
* @param number $border |
|
687
|
|
|
* @param number $ln |
|
688
|
|
|
* @param string $align |
|
689
|
|
|
* @param boolean $fill |
|
690
|
|
|
* @param string $link |
|
691
|
|
|
*/ |
|
692
|
|
|
public function cellFitScale($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $fill = false, $link = '') |
|
693
|
|
|
{ |
|
694
|
|
|
$this->cellFit($w, $h, $txt, $border, $ln, $align, $fill, $link, true, false); |
|
695
|
|
|
} |
|
696
|
|
|
|
|
697
|
|
|
/** |
|
698
|
|
|
* CellFitScaleForce |
|
699
|
|
|
* Celula com escalamento forçado |
|
700
|
|
|
* @param number $w |
|
701
|
|
|
* @param number $h |
|
702
|
|
|
* @param string $txt |
|
703
|
|
|
* @param number $border |
|
704
|
|
|
* @param number $ln |
|
705
|
|
|
* @param string $align |
|
706
|
|
|
* @param boolean $fill |
|
707
|
|
|
* @param string $link |
|
708
|
|
|
*/ |
|
709
|
|
|
public function cellFitScaleForce( |
|
710
|
|
|
$w, |
|
711
|
|
|
$h = 0, |
|
712
|
|
|
$txt = '', |
|
713
|
|
|
$border = 0, |
|
714
|
|
|
$ln = 0, |
|
715
|
|
|
$align = '', |
|
716
|
|
|
$fill = false, |
|
717
|
|
|
$link = '' |
|
718
|
|
|
) { |
|
719
|
|
|
$this->cellFit($w, $h, $txt, $border, $ln, $align, $fill, $link, true, true); |
|
720
|
|
|
} |
|
721
|
|
|
|
|
722
|
|
|
/** |
|
723
|
|
|
* CellFitSpace |
|
724
|
|
|
* Celula com espaçamento de caracteres somente se necessário |
|
725
|
|
|
* @param number $w |
|
726
|
|
|
* @param number $h |
|
727
|
|
|
* @param string $txt |
|
728
|
|
|
* @param number $border |
|
729
|
|
|
* @param number $ln |
|
730
|
|
|
* @param string $align |
|
731
|
|
|
* @param boolean $fill |
|
732
|
|
|
* @param string $link |
|
733
|
|
|
*/ |
|
734
|
|
|
public function cellFitSpace($w, $h = 0, $txt = '', $border = 0, $ln = 0, $align = '', $fill = false, $link = '') |
|
735
|
|
|
{ |
|
736
|
|
|
$this->cellFit($w, $h, $txt, $border, $ln, $align, $fill, $link, false, false); |
|
737
|
|
|
} |
|
738
|
|
|
|
|
739
|
|
|
/** |
|
740
|
|
|
* CellFitSpaceForce |
|
741
|
|
|
* Celula com espaçamento de caracteres forçado |
|
742
|
|
|
* @param number $w |
|
743
|
|
|
* @param number $h |
|
744
|
|
|
* @param string $txt |
|
745
|
|
|
* @param number $border |
|
746
|
|
|
* @param number $ln |
|
747
|
|
|
* @param string $align |
|
748
|
|
|
* @param boolean $fill |
|
749
|
|
|
* @param string $link |
|
750
|
|
|
*/ |
|
751
|
|
|
public function cellFitSpaceForce( |
|
752
|
|
|
$w, |
|
753
|
|
|
$h = 0, |
|
754
|
|
|
$txt = '', |
|
755
|
|
|
$border = 0, |
|
756
|
|
|
$ln = 0, |
|
757
|
|
|
$align = '', |
|
758
|
|
|
$fill = false, |
|
759
|
|
|
$link = '' |
|
760
|
|
|
) { |
|
761
|
|
|
$this->cellFit($w, $h, $txt, $border, $ln, $align, $fill, $link, false, true); |
|
762
|
|
|
} |
|
763
|
|
|
|
|
764
|
|
|
/** |
|
765
|
|
|
* _MBGetStringLength |
|
766
|
|
|
* Patch para trabalhar com textos de duplo byte CJK |
|
767
|
|
|
* @param string $s |
|
768
|
|
|
* @return int |
|
769
|
|
|
*/ |
|
770
|
|
|
private function mbGetStringLength($s) |
|
771
|
|
|
{ |
|
772
|
|
|
if ($this->currentFont['type'] == 'Type0') { |
|
773
|
|
|
$len = 0; |
|
774
|
|
|
$nbbytes = strlen($s); |
|
775
|
|
|
for ($i = 0; $i < $nbbytes; $i++) { |
|
776
|
|
|
if (ord($s[$i])<128) { |
|
777
|
|
|
$len++; |
|
778
|
|
|
} else { |
|
779
|
|
|
$len++; |
|
780
|
|
|
$i++; |
|
781
|
|
|
} |
|
782
|
|
|
} |
|
783
|
|
|
return $len; |
|
784
|
|
|
} else { |
|
785
|
|
|
return strlen($s); |
|
786
|
|
|
} |
|
787
|
|
|
} |
|
788
|
|
|
|
|
789
|
|
|
/** |
|
790
|
|
|
* DashedLine |
|
791
|
|
|
* Desenha uma linha horizontal tracejada com o FPDF |
|
792
|
|
|
* @param number $x Posição horizontal inicial, em mm |
|
793
|
|
|
* @param number $y Posição vertical inicial, em mm |
|
794
|
|
|
* @param number $w Comprimento da linha, em mm |
|
795
|
|
|
* @param number $h Espessura da linha, em mm |
|
796
|
|
|
* @param number $n Numero de traços na seção da linha com o comprimento $w |
|
797
|
|
|
* @return none |
|
798
|
|
|
*/ |
|
799
|
|
|
public function dashedHLine($x, $y, $w, $h, $n) |
|
800
|
|
|
{ |
|
801
|
|
|
$this->setDrawColor(110); |
|
802
|
|
|
$this->setLineWidth($h); |
|
803
|
|
|
$wDash = ($w/$n)/2; // comprimento dos traços |
|
804
|
|
|
for ($i=$x; $i<=$x+$w; $i += $wDash+$wDash) { |
|
805
|
|
|
for ($j=$i; $j<= ($i+$wDash); $j++) { |
|
806
|
|
|
if ($j <= ($x+$w-1)) { |
|
807
|
|
|
$this->line($j, $y, $j+1, $y); |
|
808
|
|
|
} |
|
809
|
|
|
} |
|
810
|
|
|
} |
|
811
|
|
|
$this->setDrawColor(0); |
|
812
|
|
|
} |
|
813
|
|
|
|
|
814
|
|
|
/** |
|
815
|
|
|
* DashedVLine |
|
816
|
|
|
* Desenha uma linha vertical tracejada com o FPDF |
|
817
|
|
|
* @param number $x Posição horizontal inicial, em mm |
|
818
|
|
|
* @param number $y Posição vertical inicial, em mm |
|
819
|
|
|
* @param number $w Comprimento da linha, em mm |
|
820
|
|
|
* @param number $yfinal Espessura da linha, em mm |
|
821
|
|
|
* @param number $n Numero de traços na seção da linha com o comprimento $w |
|
822
|
|
|
* @return none |
|
823
|
|
|
*/ |
|
824
|
|
|
public function dashedVLine($x, $y, $w, $yfinal, $n) |
|
825
|
|
|
{ |
|
826
|
|
|
$this->setLineWidth($w); |
|
827
|
|
|
//Organizando valores |
|
828
|
|
|
if ($y > $yfinal) { |
|
829
|
|
|
$aux = $yfinal; |
|
830
|
|
|
$yfinal = $y; |
|
831
|
|
|
$y = $aux; |
|
832
|
|
|
} |
|
833
|
|
|
while ($y < $yfinal && $n > 0) { |
|
834
|
|
|
$this->line($x, $y, $x, $y+1); |
|
835
|
|
|
$y += 3; |
|
836
|
|
|
$n--; |
|
837
|
|
|
} |
|
838
|
|
|
} |
|
839
|
|
|
} |
|
840
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.