1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* HTML2PDF Librairy - myPdf class |
4
|
|
|
* |
5
|
|
|
* HTML => PDF convertor |
6
|
|
|
* distributed under the LGPL License |
7
|
|
|
* |
8
|
|
|
* @author Laurent MINGUET <[email protected]> |
9
|
|
|
* @version 4.03 |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
require_once(dirname(__FILE__).'/tcpdfConfig.php'); |
13
|
|
|
require_once(dirname(__FILE__).'/../_tcpdf_'.HTML2PDF_USED_TCPDF_VERSION.'/tcpdf.php'); |
14
|
|
|
|
15
|
|
|
class HTML2PDF_myPdf extends TCPDF |
16
|
|
|
{ |
17
|
|
|
protected $_footerParam = array(); |
18
|
|
|
protected $_transf = array(); |
19
|
|
|
protected $_myLastPageGroup = null; |
20
|
|
|
protected $_myLastPageGroupNb = 0; |
21
|
|
|
|
22
|
|
|
// used to make a radius with bezier : (4/3 * (sqrt(2) - 1)) |
23
|
|
|
const MY_ARC = 0.5522847498; |
24
|
|
|
|
25
|
|
|
// nb of segment to build a arc with bezier curv |
26
|
|
|
const ARC_NB_SEGMENT = 8; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* class constructor |
30
|
|
|
* |
31
|
|
|
* @param string $orientation page orientation, same as TCPDF |
32
|
|
|
* @param string $unit User measure unit, same as TCPDF |
33
|
|
|
* @param mixed $format The format used for pages, same as TCPDF |
34
|
|
|
* @param boolean $unicode TRUE means that the input text is unicode (default = true) |
35
|
|
|
* @param String $encoding charset encoding; default is UTF-8 |
36
|
|
|
* @param boolean $diskcache if TRUE reduce the RAM memory usage by caching temporary data on filesystem (slower). |
37
|
|
|
* @access public |
38
|
|
|
*/ |
39
|
|
|
public function __construct( |
40
|
|
|
$orientation = 'P', |
41
|
|
|
$unit = 'mm', |
42
|
|
|
$format = 'A4', |
43
|
|
|
$unicode = true, |
44
|
|
|
$encoding = 'UTF-8', |
45
|
|
|
$diskcache = false) |
46
|
|
|
{ |
47
|
|
|
// call the parent constructor |
48
|
|
|
parent::__construct($orientation, $unit, $format, $unicode, $encoding, $diskcache); |
49
|
|
|
|
50
|
|
|
// init the specific parameters used by HTML2PDF |
51
|
|
|
$this->SetCreator(PDF_CREATOR); |
52
|
|
|
$this->SetAutoPageBreak(false, 0); |
53
|
|
|
$this->linestyleCap = '2 J'; |
54
|
|
|
$this->setPrintHeader(false); |
55
|
|
|
$this->jpeg_quality = 90; |
56
|
|
|
|
57
|
|
|
// prepare the automatic footer |
58
|
|
|
$this->SetMyFooter(); |
59
|
|
|
|
60
|
|
|
$this->cMargin = 0; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Set the parameters for the automatic footer |
65
|
|
|
* |
66
|
|
|
* @param boolean $page display the page number |
67
|
|
|
* @param boolean $date display the date |
68
|
|
|
* @param boolean $hour display the hour |
69
|
|
|
* @param boolean $form display a warning abour forms |
70
|
|
|
* @access public |
71
|
|
|
*/ |
72
|
|
|
public function SetMyFooter($page = false, $date = false, $hour = false, $form = false) |
73
|
|
|
{ |
74
|
|
|
$page = ($page ? true : false); |
75
|
|
|
$date = ($date ? true : false); |
76
|
|
|
$hour = ($hour ? true : false); |
77
|
|
|
$form = ($form ? true : false); |
78
|
|
|
|
79
|
|
|
$this->_footerParam = array('page' => $page, 'date' => $date, 'hour' => $hour, 'form' => $form); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* This function is call automatically by TCPDF at the end of a page |
84
|
|
|
* It takes no parameters |
85
|
|
|
* |
86
|
|
|
* @access public |
87
|
|
|
*/ |
88
|
|
|
public function Footer() |
89
|
|
|
{ |
90
|
|
|
// prepare the text from the tranlated text |
91
|
|
|
$txt = ''; |
92
|
|
|
if ($this->_footerParam['form']) { |
93
|
|
|
$txt = (HTML2PDF_locale::get('pdf05')); |
94
|
|
|
} |
95
|
|
|
if ($this->_footerParam['date'] && $this->_footerParam['hour']) { |
96
|
|
|
$txt .= ($txt ? ' - ' : '').(HTML2PDF_locale::get('pdf03')); |
97
|
|
|
} |
98
|
|
View Code Duplication |
if ($this->_footerParam['date'] && ! $this->_footerParam['hour']) { |
99
|
|
|
$txt .= ($txt ? ' - ' : '').(HTML2PDF_locale::get('pdf01')); |
100
|
|
|
} |
101
|
|
View Code Duplication |
if ( ! $this->_footerParam['date'] && $this->_footerParam['hour']) { |
102
|
|
|
$txt .= ($txt ? ' - ' : '').(HTML2PDF_locale::get('pdf02')); |
103
|
|
|
} |
104
|
|
|
if ($this->_footerParam['page']) { |
105
|
|
|
$txt .= ($txt ? ' - ' : '').(HTML2PDF_locale::get('pdf04')); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
if (strlen($txt) > 0) { |
109
|
|
|
// replace some values |
110
|
|
|
$toReplace = array( |
111
|
|
|
'[[date_d]]' => date('d'), |
112
|
|
|
'[[date_m]]' => date('m'), |
113
|
|
|
'[[date_y]]' => date('Y'), |
114
|
|
|
'[[date_h]]' => date('H'), |
115
|
|
|
'[[date_i]]' => date('i'), |
116
|
|
|
'[[date_s]]' => date('s'), |
117
|
|
|
'[[page_cu]]' => $this->getMyNumPage(), |
118
|
|
|
'[[page_nb]]' => $this->getMyAliasNbPages(), |
119
|
|
|
); |
120
|
|
|
$txt = str_replace(array_keys($toReplace), array_values($toReplace), $txt); |
121
|
|
|
|
122
|
|
|
// draw the footer |
123
|
|
|
parent::SetY(-11); |
|
|
|
|
124
|
|
|
$this->SetFont('helvetica', 'I', 8); |
125
|
|
|
$this->Cell(0, 10, $txt, 0, 0, 'R'); |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* after cloning a object, we does not want to clone all the front informations |
131
|
|
|
* because it take a lot a time and a lot of memory => we use reference |
132
|
|
|
* |
133
|
|
|
* @param &HTML2PDF_myPdf object |
134
|
|
|
* @param HTML2PDF_myPdf $pdf |
135
|
|
|
* @access public |
136
|
|
|
*/ |
137
|
|
|
public function cloneFontFrom(&$pdf) |
138
|
|
|
{ |
139
|
|
|
$this->fonts = &$pdf->getFonts(); |
140
|
|
|
$this->FontFiles = &$pdf->getFontFiles(); |
141
|
|
|
$this->diffs = &$pdf->getDiffs(); |
142
|
|
|
$this->fontlist = &$pdf->getFontList(); |
143
|
|
|
$this->numfonts = &$pdf->getNumFonts(); |
144
|
|
|
$this->fontkeys = &$pdf->getFontKeys(); |
145
|
|
|
$this->font_obj_ids = &$pdf->getFontObjIds(); |
146
|
|
|
$this->annotation_fonts = &$pdf->getAnnotFonts(); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* multiple public accessor for some private attributs |
151
|
|
|
* used only by cloneFontFrom |
152
|
|
|
* |
153
|
|
|
* @return &array |
|
|
|
|
154
|
|
|
* @access public |
155
|
|
|
*/ |
156
|
|
|
public function &getFonts() |
157
|
|
|
{ |
158
|
|
|
return $this->fonts; |
159
|
|
|
} |
160
|
|
|
public function &getFontFiles() |
161
|
|
|
{ |
162
|
|
|
return $this->FontFiles; |
163
|
|
|
} |
164
|
|
|
public function &getDiffs() |
165
|
|
|
{ |
166
|
|
|
return $this->diffs; |
167
|
|
|
} |
168
|
|
|
public function &getFontList() |
169
|
|
|
{ |
170
|
|
|
return $this->fontlist; |
171
|
|
|
} |
172
|
|
|
public function &getNumFonts() |
173
|
|
|
{ |
174
|
|
|
return $this->numfonts; |
175
|
|
|
} |
176
|
|
|
public function &getFontKeys() |
177
|
|
|
{ |
178
|
|
|
return $this->fontkeys; |
179
|
|
|
} |
180
|
|
|
public function &getFontObjIds() |
181
|
|
|
{ |
182
|
|
|
return $this->font_obj_ids; |
183
|
|
|
} |
184
|
|
|
public function &getAnnotFonts() |
185
|
|
|
{ |
186
|
|
|
return $this->annotation_fonts; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
/** |
190
|
|
|
* Verify that a Font is already loaded |
191
|
|
|
* |
192
|
|
|
* @param string Font Key |
193
|
|
|
* @return boolean |
194
|
|
|
* @access public |
195
|
|
|
*/ |
196
|
|
|
public function isLoadedFont($fontKey) |
197
|
|
|
{ |
198
|
|
|
if (isset($this->fonts[$fontKey])) { |
199
|
|
|
return true; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
if (isset($this->CoreFonts[$fontKey])) { |
203
|
|
|
return true; |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
return false; |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* Get the Word Spacing |
211
|
|
|
* |
212
|
|
|
* @access public |
213
|
|
|
* @return float word spacing |
214
|
|
|
*/ |
215
|
|
|
public function getWordSpacing() |
216
|
|
|
{ |
217
|
|
|
return $this->ws; |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* set the Word Spacing |
222
|
|
|
* |
223
|
|
|
* @param float word spacing |
224
|
|
|
* @access public |
225
|
|
|
*/ |
226
|
|
|
public function setWordSpacing($ws = 0.) |
227
|
|
|
{ |
228
|
|
|
$this->ws = $ws; |
229
|
|
|
$this->_out(sprintf('%.3F Tw', $ws * $this->k)); |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
/** |
233
|
|
|
* start to use a rectangular Cliping Path with radius corners |
234
|
|
|
* |
235
|
|
|
* @param float $x (top left corner) |
236
|
|
|
* @param float $y (top left corner) |
237
|
|
|
* @param float $w (x+w = botom rigth corner) |
238
|
|
|
* @param float $h (y+h = botom rigth corner) |
239
|
|
|
* @param array $cornerTL radius of the Top Left corner |
240
|
|
|
* @param array $cornerTR radius of the Top Right corner |
241
|
|
|
* @param array $cornerBL radius of the Bottom Left corner |
242
|
|
|
* @param array $cornerBR radius of the Bottom Right corner |
243
|
|
|
* @access public |
244
|
|
|
*/ |
245
|
|
|
public function clippingPathStart( |
246
|
|
|
$x = null, |
247
|
|
|
$y = null, |
248
|
|
|
$w = null, |
249
|
|
|
$h = null, |
250
|
|
|
$cornerTL = null, |
251
|
|
|
$cornerTR = null, |
252
|
|
|
$cornerBL = null, |
253
|
|
|
$cornerBR = null) |
254
|
|
|
{ |
255
|
|
|
// init the path |
256
|
|
|
$path = ''; |
257
|
|
|
|
258
|
|
|
// if we have the position and the size of the rectangle, we can proceed |
259
|
|
|
if ($x !== null && $y !== null && $w !== null && $h !== null) { |
260
|
|
|
// the positions of the rectangle's corners |
261
|
|
|
$x1 = $x * $this->k; |
262
|
|
|
$y1 = ($this->h - $y) * $this->k; |
263
|
|
|
|
264
|
|
|
$x2 = ($x + $w) * $this->k; |
265
|
|
|
$y2 = ($this->h - $y) * $this->k; |
266
|
|
|
|
267
|
|
|
$x3 = ($x + $w) * $this->k; |
268
|
|
|
$y3 = ($this->h - $y - $h) * $this->k; |
269
|
|
|
|
270
|
|
|
$x4 = $x * $this->k; |
271
|
|
|
$y4 = ($this->h - $y - $h) * $this->k; |
272
|
|
|
|
273
|
|
|
// if we have at least one radius corner, then we proceed to a specific path, else it is just a rectangle |
274
|
|
|
if ($cornerTL || $cornerTR || $cornerBL || $cornerBR) { |
275
|
|
|
// prepare the radius values |
276
|
|
|
if ($cornerTL) { |
277
|
|
|
$cornerTL[0] = $cornerTL[0] * $this->k; |
278
|
|
|
$cornerTL[1] = -$cornerTL[1] * $this->k; |
279
|
|
|
} |
280
|
|
|
if ($cornerTR) { |
281
|
|
|
$cornerTR[0] = $cornerTR[0] * $this->k; |
282
|
|
|
$cornerTR[1] = -$cornerTR[1] * $this->k; |
283
|
|
|
} |
284
|
|
|
if ($cornerBL) { |
285
|
|
|
$cornerBL[0] = $cornerBL[0] * $this->k; |
286
|
|
|
$cornerBL[1] = -$cornerBL[1] * $this->k; |
287
|
|
|
} |
288
|
|
|
if ($cornerBR) { |
289
|
|
|
$cornerBR[0] = $cornerBR[0] * $this->k; |
290
|
|
|
$cornerBR[1] = -$cornerBR[1] * $this->k; |
291
|
|
|
} |
292
|
|
|
|
293
|
|
|
// if TL radius then specific start else (X1,Y1) |
294
|
|
|
if ($cornerTL) { |
295
|
|
|
$path .= sprintf('%.2F %.2F m ', $x1 + $cornerTL[0], $y1); |
296
|
|
|
} else { |
297
|
|
|
$path .= sprintf('%.2F %.2F m ', $x1, $y1); |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
// if TR radius then line + arc, else line to (X2,Y2) |
301
|
|
|
if ($cornerTR) { |
302
|
|
|
$xt1 = ($x2 - $cornerTR[0]) + $cornerTR[0] * self::MY_ARC; |
303
|
|
|
$yt1 = ($y2 + $cornerTR[1]) - $cornerTR[1]; |
304
|
|
|
$xt2 = ($x2 - $cornerTR[0]) + $cornerTR[0]; |
305
|
|
|
$yt2 = ($y2 + $cornerTR[1]) - $cornerTR[1] * self::MY_ARC; |
306
|
|
|
|
307
|
|
|
$path .= sprintf('%.2F %.2F l ', $x2 - $cornerTR[0], $y2); |
308
|
|
|
$path .= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $x2, $y2 + $cornerTR[1]); |
309
|
|
|
} else { |
310
|
|
|
$path .= sprintf('%.2F %.2F l ', $x2, $y2); |
311
|
|
|
} |
312
|
|
|
|
313
|
|
|
// if BR radius then line + arc, else line to (X3, Y3) |
314
|
|
|
if ($cornerBR) { |
315
|
|
|
$xt1 = ($x3 - $cornerBR[0]) + $cornerBR[0]; |
316
|
|
|
$yt1 = ($y3 - $cornerBR[1]) + $cornerBR[1] * self::MY_ARC; |
317
|
|
|
$xt2 = ($x3 - $cornerBR[0]) + $cornerBR[0] * self::MY_ARC; |
318
|
|
|
$yt2 = ($y3 - $cornerBR[1]) + $cornerBR[1]; |
319
|
|
|
|
320
|
|
|
$path .= sprintf('%.2F %.2F l ', $x3, $y3 - $cornerBR[1]); |
321
|
|
|
$path .= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $x3 - $cornerBR[0], $y3); |
322
|
|
|
} else { |
323
|
|
|
$path .= sprintf('%.2F %.2F l ', $x3, $y3); |
324
|
|
|
} |
325
|
|
|
|
326
|
|
|
// if BL radius then line + arc, else line to (X4, Y4) |
327
|
|
|
if ($cornerBL) { |
328
|
|
|
$xt1 = ($x4 + $cornerBL[0]) - $cornerBL[0] * self::MY_ARC; |
329
|
|
|
$yt1 = ($y4 - $cornerBL[1]) + $cornerBL[1]; |
330
|
|
|
$xt2 = ($x4 + $cornerBL[0]) - $cornerBL[0]; |
331
|
|
|
$yt2 = ($y4 - $cornerBL[1]) + $cornerBL[1] * self::MY_ARC; |
332
|
|
|
|
333
|
|
|
$path .= sprintf('%.2F %.2F l ', $x4 + $cornerBL[0], $y4); |
334
|
|
|
$path .= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $x4, $y4 - $cornerBL[1]); |
335
|
|
|
} else { |
336
|
|
|
$path .= sprintf('%.2F %.2F l ', $x4, $y4); |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
// if RL radius then line + arc |
340
|
|
|
if ($cornerTL) { |
341
|
|
|
$xt1 = ($x1 + $cornerTL[0]) - $cornerTL[0]; |
342
|
|
|
$yt1 = ($y1 + $cornerTL[1]) - $cornerTL[1] * self::MY_ARC; |
343
|
|
|
$xt2 = ($x1 + $cornerTL[0]) - $cornerTL[0] * self::MY_ARC; |
344
|
|
|
$yt2 = ($y1 + $cornerTL[1]) - $cornerTL[1]; |
345
|
|
|
|
346
|
|
|
$path .= sprintf('%.2F %.2F l ', $x1, $y1 + $cornerTL[1]); |
347
|
|
|
$path .= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $x1 + $cornerTL[0], $y1); |
348
|
|
|
} |
349
|
|
|
} else { |
350
|
|
|
$path .= sprintf('%.2F %.2F m ', $x1, $y1); |
351
|
|
|
$path .= sprintf('%.2F %.2F l ', $x2, $y2); |
352
|
|
|
$path .= sprintf('%.2F %.2F l ', $x3, $y3); |
353
|
|
|
$path .= sprintf('%.2F %.2F l ', $x4, $y4); |
354
|
|
|
} |
355
|
|
|
|
356
|
|
|
// close the path |
357
|
|
|
$path .= ' h W n'; |
358
|
|
|
} |
359
|
|
|
|
360
|
|
|
// using the path as a clipping path |
361
|
|
|
$this->_out('q '.$path.' '); |
362
|
|
|
} |
363
|
|
|
|
364
|
|
|
/** |
365
|
|
|
* stop to use the Cliping Path |
366
|
|
|
* |
367
|
|
|
* @access public |
368
|
|
|
*/ |
369
|
|
|
public function clippingPathStop() |
370
|
|
|
{ |
371
|
|
|
$this->_out(' Q'); |
372
|
|
|
} |
373
|
|
|
|
374
|
|
|
/** |
375
|
|
|
* draw a filled corner of a border with a external and a internal radius |
376
|
|
|
* /--------+ ext2 |
377
|
|
|
* / | |
378
|
|
|
* / /-------+ int2 |
379
|
|
|
* / / |
380
|
|
|
* | / |
381
|
|
|
* | | |
382
|
|
|
* | | |
383
|
|
|
* ext1 +-+ int1 + cen |
384
|
|
|
* |
385
|
|
|
* @param float $ext1X |
386
|
|
|
* @param float $ext1Y |
387
|
|
|
* @param float $ext2X |
388
|
|
|
* @param float $ext2Y |
389
|
|
|
* @param float $int1X |
390
|
|
|
* @param float $int1Y |
391
|
|
|
* @param float $int2X |
392
|
|
|
* @param float $int2Y |
393
|
|
|
* @param float $cenX |
394
|
|
|
* @param float $cenY |
395
|
|
|
* @access public |
396
|
|
|
*/ |
397
|
|
|
public function drawCurve($ext1X, $ext1Y, $ext2X, $ext2Y, $int1X, $int1Y, $int2X, $int2Y, $cenX, $cenY) |
398
|
|
|
{ |
399
|
|
|
// prepare the coordinates |
400
|
|
|
$ext1X = $ext1X * $this->k; |
401
|
|
|
$ext2X = $ext2X * $this->k; |
402
|
|
|
$int1X = $int1X * $this->k; |
403
|
|
|
$int2X = $int2X * $this->k; |
404
|
|
|
$cenX = $cenX * $this->k; |
405
|
|
|
|
406
|
|
|
$ext1Y = ($this->h - $ext1Y) * $this->k; |
407
|
|
|
$ext2Y = ($this->h - $ext2Y) * $this->k; |
408
|
|
|
$int1Y = ($this->h - $int1Y) * $this->k; |
409
|
|
|
$int2Y = ($this->h - $int2Y) * $this->k; |
410
|
|
|
$cenY = ($this->h - $cenY) * $this->k; |
411
|
|
|
|
412
|
|
|
// init the curve |
413
|
|
|
$path = ''; |
414
|
|
|
|
415
|
|
View Code Duplication |
if ($ext1X - $cenX != 0) { |
416
|
|
|
$xt1 = $cenX + ($ext1X - $cenX); |
417
|
|
|
$yt1 = $cenY + ($ext2Y - $cenY) * self::MY_ARC; |
418
|
|
|
$xt2 = $cenX + ($ext1X - $cenX) * self::MY_ARC; |
419
|
|
|
$yt2 = $cenY + ($ext2Y - $cenY); |
420
|
|
|
} else { |
421
|
|
|
$xt1 = $cenX + ($ext2X - $cenX) * self::MY_ARC; |
422
|
|
|
$yt1 = $cenY + ($ext1Y - $cenY); |
423
|
|
|
$xt2 = $cenX + ($ext2X - $cenX); |
424
|
|
|
$yt2 = $cenY + ($ext1Y - $cenY) * self::MY_ARC; |
425
|
|
|
} |
426
|
|
|
$path .= sprintf('%.2F %.2F m ', $ext1X, $ext1Y); |
427
|
|
|
$path .= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $ext2X, $ext2Y); |
428
|
|
|
|
429
|
|
|
if ($int1X - $cenX != 0) { |
430
|
|
|
$xt1 = $cenX + ($int1X - $cenX) * self::MY_ARC; |
431
|
|
|
$yt1 = $cenY + ($int2Y - $cenY); |
432
|
|
|
$xt2 = $cenX + ($int1X - $cenX); |
433
|
|
|
$yt2 = $cenY + ($int2Y - $cenY) * self::MY_ARC; |
434
|
|
|
} else { |
435
|
|
|
$xt1 = $cenX + ($int2X - $cenX); |
436
|
|
|
$yt1 = $cenY + ($int1Y - $cenY) * self::MY_ARC; |
437
|
|
|
$xt2 = $cenX + ($int2X - $cenX) * self::MY_ARC; |
438
|
|
|
$yt2 = $cenY + ($int1Y - $cenY); |
439
|
|
|
} |
440
|
|
|
$path .= sprintf('%.2F %.2F l ', $int2X, $int2Y); |
441
|
|
|
$path .= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $int1X, $int1Y); |
442
|
|
|
|
443
|
|
|
// draw the curve |
444
|
|
|
$this->_out($path.'f'); |
445
|
|
|
} |
446
|
|
|
|
447
|
|
|
/** |
448
|
|
|
* draw a filled corner of a border with only a external radius |
449
|
|
|
* /--+ ext2 |
450
|
|
|
* / | |
451
|
|
|
* / | |
452
|
|
|
* / | |
453
|
|
|
* | | |
454
|
|
|
* | | |
455
|
|
|
* | | |
456
|
|
|
* ext1 +-----+ int + cen |
457
|
|
|
* |
458
|
|
|
* @param float $ext1X |
459
|
|
|
* @param float $ext1Y |
460
|
|
|
* @param float $ext2X |
461
|
|
|
* @param float $ext2Y |
462
|
|
|
* @param float $intX |
463
|
|
|
* @param float $intY |
464
|
|
|
* @param float $cenX |
465
|
|
|
* @param float $cenY |
466
|
|
|
* @access public |
467
|
|
|
*/ |
468
|
|
|
public function drawCorner($ext1X, $ext1Y, $ext2X, $ext2Y, $intX, $intY, $cenX, $cenY) |
469
|
|
|
{ |
470
|
|
|
// prepare the coordinates |
471
|
|
|
$ext1X = $ext1X * $this->k; |
472
|
|
|
$ext2X = $ext2X * $this->k; |
473
|
|
|
$intX = $intX * $this->k; |
474
|
|
|
$cenX = $cenX * $this->k; |
475
|
|
|
|
476
|
|
|
$ext1Y = ($this->h - $ext1Y) * $this->k; |
477
|
|
|
$ext2Y = ($this->h - $ext2Y) * $this->k; |
478
|
|
|
$intY = ($this->h - $intY) * $this->k; |
479
|
|
|
$cenY = ($this->h - $cenY) * $this->k; |
480
|
|
|
|
481
|
|
|
// init the curve |
482
|
|
|
$path = ''; |
483
|
|
|
|
484
|
|
View Code Duplication |
if ($ext1X - $cenX != 0) { |
485
|
|
|
$xt1 = $cenX + ($ext1X - $cenX); |
486
|
|
|
$yt1 = $cenY + ($ext2Y - $cenY) * self::MY_ARC; |
487
|
|
|
$xt2 = $cenX + ($ext1X - $cenX) * self::MY_ARC; |
488
|
|
|
$yt2 = $cenY + ($ext2Y - $cenY); |
489
|
|
|
} else { |
490
|
|
|
$xt1 = $cenX + ($ext2X - $cenX) * self::MY_ARC; |
491
|
|
|
$yt1 = $cenY + ($ext1Y - $cenY); |
492
|
|
|
$xt2 = $cenX + ($ext2X - $cenX); |
493
|
|
|
$yt2 = $cenY + ($ext1Y - $cenY) * self::MY_ARC; |
494
|
|
|
} |
495
|
|
|
$path .= sprintf('%.2F %.2F m ', $ext1X, $ext1Y); |
496
|
|
|
$path .= sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c ', $xt1, $yt1, $xt2, $yt2, $ext2X, $ext2Y); |
497
|
|
|
$path .= sprintf('%.2F %.2F l ', $intX, $intY); |
498
|
|
|
$path .= sprintf('%.2F %.2F l ', $ext1X, $ext1Y); |
499
|
|
|
|
500
|
|
|
// draw the curve |
501
|
|
|
$this->_out($path.'f'); |
502
|
|
|
} |
503
|
|
|
|
504
|
|
|
/** |
505
|
|
|
* Start a transformation |
506
|
|
|
* |
507
|
|
|
* @access public |
508
|
|
|
*/ |
509
|
|
|
public function startTransform() |
510
|
|
|
{ |
511
|
|
|
$this->_out('q'); |
512
|
|
|
} |
513
|
|
|
|
514
|
|
|
/** |
515
|
|
|
* Stop a transformation |
516
|
|
|
* |
517
|
|
|
* @access public |
518
|
|
|
*/ |
519
|
|
|
public function stopTransform() |
520
|
|
|
{ |
521
|
|
|
$this->_out('Q'); |
522
|
|
|
} |
523
|
|
|
|
524
|
|
|
/** |
525
|
|
|
* add a Translate transformation |
526
|
|
|
* |
527
|
|
|
* @access public |
528
|
|
|
*/ |
529
|
|
|
public function setTranslate($xT, $yT) |
530
|
|
|
{ |
531
|
|
|
// Matrix for Translate |
532
|
|
|
$tm[0] = 1; |
|
|
|
|
533
|
|
|
$tm[1] = 0; |
534
|
|
|
$tm[2] = 0; |
535
|
|
|
$tm[3] = 1; |
536
|
|
|
$tm[4] = $xT * $this->k; |
537
|
|
|
$tm[5] = -$yT * $this->k; |
538
|
|
|
|
539
|
|
|
// apply the Transform Matric |
540
|
|
|
$this->_out(sprintf('%.3F %.3F %.3F %.3F %.3F %.3F cm', $tm[0], $tm[1], $tm[2], $tm[3], $tm[4], $tm[5])); |
541
|
|
|
} |
542
|
|
|
|
543
|
|
|
/** |
544
|
|
|
* add a Rotate transformation |
545
|
|
|
* |
546
|
|
|
* @param float $angle |
547
|
|
|
* @access public |
548
|
|
|
*/ |
549
|
|
|
public function setRotation($angle, $xC = null, $yC = null) |
550
|
|
|
{ |
551
|
|
|
// if no center, rotate around the current posiition |
552
|
|
|
if ($xC === null) $xC = $this->x; |
553
|
|
|
if ($yC === null) $yC = $this->y; |
554
|
|
|
|
555
|
|
|
// prepare the coordinate |
556
|
|
|
$yC = ($this->h - $yC) * $this->k; |
557
|
|
|
$xC *= $this->k; |
558
|
|
|
|
559
|
|
|
// Matrix for Rotate |
560
|
|
|
$tm[0] = cos(deg2rad($angle)); |
|
|
|
|
561
|
|
|
$tm[1] = sin(deg2rad($angle)); |
562
|
|
|
$tm[2] = -$tm[1]; |
563
|
|
|
$tm[3] = $tm[0]; |
564
|
|
|
$tm[4] = $xC + $tm[1] * $yC - $tm[0] * $xC; |
565
|
|
|
$tm[5] = $yC - $tm[0] * $yC - $tm[1] * $xC; |
566
|
|
|
|
567
|
|
|
// apply the Transform Matric |
568
|
|
|
$this->_out(sprintf('%.3F %.3F %.3F %.3F %.3F %.3F cm', $tm[0], $tm[1], $tm[2], $tm[3], $tm[4], $tm[5])); |
569
|
|
|
} |
570
|
|
|
|
571
|
|
|
/** |
572
|
|
|
* we redifine the original SetX method, because we don't want the automatic treatment. |
573
|
|
|
* It is HTML2PDF that make the treatment |
574
|
|
|
* |
575
|
|
|
* @param float $x |
576
|
|
|
* @param boolean $rtloff NOT USED |
577
|
|
|
* @access public |
578
|
|
|
*/ |
579
|
|
|
public function SetX($x, $rtloff = false) |
580
|
|
|
{ |
581
|
|
|
$this->x = $x; |
582
|
|
|
} |
583
|
|
|
|
584
|
|
|
/** |
585
|
|
|
* we redifine the original SetY method, because we don't want the automatic treatment. |
586
|
|
|
* It is HTML2PDF that make the treatment |
587
|
|
|
* |
588
|
|
|
* @param float $y |
589
|
|
|
* @param boolean $resetx Reset the X position |
590
|
|
|
* @param boolean $rtloff NOT USED |
591
|
|
|
* @access public |
592
|
|
|
*/ |
593
|
|
|
public function SetY($y, $resetx = true, $rtloff = false) |
594
|
|
|
{ |
595
|
|
|
if ($resetx) |
596
|
|
|
$this->x = $this->lMargin; |
597
|
|
|
|
598
|
|
|
$this->y = $y; |
599
|
|
|
} |
600
|
|
|
|
601
|
|
|
/** |
602
|
|
|
* we redifine the original SetXY method, because we don't want the automatic treatment. |
603
|
|
|
* It is HTML2PDF that make the treatment |
604
|
|
|
* |
605
|
|
|
* @param integer $x |
606
|
|
|
* @param integer $y |
607
|
|
|
* @param boolean $rtloff NOT USED |
608
|
|
|
* @access public |
609
|
|
|
*/ |
610
|
|
|
public function SetXY($x, $y, $rtloff = false) |
611
|
|
|
{ |
612
|
|
|
$this->x = $x; |
613
|
|
|
$this->y = $y; |
614
|
|
|
} |
615
|
|
|
|
616
|
|
|
/** |
617
|
|
|
* multiple public accessor because HTML2PDF need to use TCPDF without being a extend of it |
618
|
|
|
* |
619
|
|
|
* @param mixed |
620
|
|
|
* @return mixed |
621
|
|
|
* @access public |
622
|
|
|
*/ |
623
|
|
|
public function getK() |
624
|
|
|
{ |
625
|
|
|
return $this->k; |
626
|
|
|
} |
627
|
|
|
|
628
|
|
|
/** |
629
|
|
|
* @return double |
630
|
|
|
*/ |
631
|
|
|
public function getW() |
632
|
|
|
{ |
633
|
|
|
return $this->w; |
634
|
|
|
} |
635
|
|
|
|
636
|
|
|
/** |
637
|
|
|
* @return double |
638
|
|
|
*/ |
639
|
|
|
public function getH() |
640
|
|
|
{ |
641
|
|
|
return $this->h; |
642
|
|
|
} |
643
|
|
|
public function getlMargin() |
644
|
|
|
{ |
645
|
|
|
return $this->lMargin; |
646
|
|
|
} |
647
|
|
|
|
648
|
|
|
/** |
649
|
|
|
* @return double |
650
|
|
|
*/ |
651
|
|
|
public function getrMargin() |
652
|
|
|
{ |
653
|
|
|
return $this->rMargin; |
654
|
|
|
} |
655
|
|
|
|
656
|
|
|
/** |
657
|
|
|
* @return double |
658
|
|
|
*/ |
659
|
|
|
public function gettMargin() |
660
|
|
|
{ |
661
|
|
|
return $this->tMargin; |
662
|
|
|
} |
663
|
|
|
public function getbMargin() |
664
|
|
|
{ |
665
|
|
|
return $this->bMargin; |
666
|
|
|
} |
667
|
|
|
public function setbMargin($v) |
668
|
|
|
{ |
669
|
|
|
$this->bMargin = $v; |
670
|
|
|
} |
671
|
|
|
|
672
|
|
|
/** |
673
|
|
|
* SVG - Convert a SVG Style in PDF Style |
674
|
|
|
* |
675
|
|
|
* @param array $styles SVG Style |
676
|
|
|
* @return string PDF style |
677
|
|
|
* @access public |
678
|
|
|
*/ |
679
|
|
|
public function svgSetStyle($styles) |
680
|
|
|
{ |
681
|
|
|
// init the PDF style |
682
|
|
|
$style = ''; |
683
|
|
|
|
684
|
|
|
// Style : fill |
685
|
|
|
if ($styles['fill']) { |
686
|
|
|
$this->setFillColorArray($styles['fill']); |
687
|
|
|
$style .= 'F'; |
688
|
|
|
} |
689
|
|
|
|
690
|
|
|
// Style : stroke |
691
|
|
|
if ($styles['stroke'] && $styles['stroke-width']) { |
692
|
|
|
$this->SetDrawColorArray($styles['stroke']); |
693
|
|
|
$this->SetLineWidth($styles['stroke-width']); |
694
|
|
|
$style .= 'D'; |
695
|
|
|
} |
696
|
|
|
|
697
|
|
|
// Style : opacity |
698
|
|
|
if ($styles['fill-opacity']) { |
699
|
|
|
$this->SetAlpha($styles['fill-opacity']); |
700
|
|
|
} |
701
|
|
|
|
702
|
|
|
return $style; |
703
|
|
|
} |
704
|
|
|
|
705
|
|
|
/** |
706
|
|
|
* SVG - make a Rectangle |
707
|
|
|
* |
708
|
|
|
* @param float $x |
709
|
|
|
* @param float $y |
710
|
|
|
* @param float $w |
711
|
|
|
* @param float $h |
712
|
|
|
* @param string $style PDF Style |
713
|
|
|
* @access public |
714
|
|
|
*/ |
715
|
|
|
public function svgRect($x, $y, $w, $h, $style) |
716
|
|
|
{ |
717
|
|
|
// prepare the 4 corners |
718
|
|
|
$x1 = $x; |
719
|
|
|
$x2 = $x + $w; |
720
|
|
|
$x3 = $x + $w; |
721
|
|
|
$x4 = $x; |
722
|
|
|
|
723
|
|
|
$y1 = $y; |
724
|
|
|
$y2 = $y; |
725
|
|
|
$y3 = $y + $h; |
726
|
|
|
$y4 = $y + $h; |
727
|
|
|
|
728
|
|
|
// get the Closing operator from the PDF Style |
729
|
|
View Code Duplication |
if ($style == 'F') $op = 'f'; |
730
|
|
|
elseif ($style == 'FD' || $style == 'DF') $op = 'B'; |
731
|
|
|
else $op = 'S'; |
732
|
|
|
|
733
|
|
|
// drawing |
734
|
|
|
$this->_Point($x1, $y1, true); |
735
|
|
|
$this->_Line($x2, $y2, true); |
736
|
|
|
$this->_Line($x3, $y3, true); |
737
|
|
|
$this->_Line($x4, $y4, true); |
738
|
|
|
$this->_Line($x1, $y1, true); |
739
|
|
|
$this->_out($op); |
740
|
|
|
} |
741
|
|
|
|
742
|
|
|
/** |
743
|
|
|
* SVG - make a Line |
744
|
|
|
* |
745
|
|
|
* @param float $x1 |
746
|
|
|
* @param float $y1 |
747
|
|
|
* @param float $x2 |
748
|
|
|
* @param float $y2 |
749
|
|
|
* @access public |
750
|
|
|
*/ |
751
|
|
|
public function svgLine($x1, $y1, $x2, $y2) |
752
|
|
|
{ |
753
|
|
|
// get the Closing operator |
754
|
|
|
$op = 'S'; |
755
|
|
|
|
756
|
|
|
// drawing |
757
|
|
|
$this->_Point($x1, $y1, true); |
758
|
|
|
$this->_Line($x2, $y2, true); |
759
|
|
|
$this->_out($op); |
760
|
|
|
} |
761
|
|
|
|
762
|
|
|
/** |
763
|
|
|
* SVG - make a Ellipse |
764
|
|
|
* |
765
|
|
|
* @param float $x0 x Center |
766
|
|
|
* @param float $y0 y Center |
767
|
|
|
* @param float $rx x radius |
768
|
|
|
* @param float $ry y radius |
769
|
|
|
* @param string $style PDF Style |
770
|
|
|
* @access public |
771
|
|
|
*/ |
772
|
|
|
public function svgEllipse($x0, $y0, $rx, $ry, $style) |
773
|
|
|
{ |
774
|
|
|
// get the Closing operator from the PDF Style |
775
|
|
View Code Duplication |
if ($style == 'F') $op = 'f'; |
776
|
|
|
elseif ($style == 'FD' || $style == 'DF') $op = 'B'; |
777
|
|
|
else $op = 'S'; |
778
|
|
|
|
779
|
|
|
// drawing |
780
|
|
|
$this->_Arc($x0, $y0, $rx, $ry, 0, 2 * M_PI, true, true, true); |
781
|
|
|
$this->_out($op); |
782
|
|
|
} |
783
|
|
|
|
784
|
|
|
/** |
785
|
|
|
* SVG - make a Advanced Polygone |
786
|
|
|
* |
787
|
|
|
* @param array $actions list of actions |
788
|
|
|
* @param string $style PDF Style |
789
|
|
|
* @access public |
790
|
|
|
*/ |
791
|
|
|
public function svgPolygone($actions, $style) |
792
|
|
|
{ |
793
|
|
|
// get the Closing operator from the PDF Style |
794
|
|
View Code Duplication |
if ($style == 'F') $op = 'f'; |
795
|
|
|
elseif ($style == 'FD' || $style == 'DF') $op = 'B'; |
796
|
|
|
else $op = 'S'; |
797
|
|
|
|
798
|
|
|
// To save the First action and the last point |
799
|
|
|
$first = array('', 0, 0); |
800
|
|
|
$last = array(0, 0, 0, 0); |
801
|
|
|
|
802
|
|
|
foreach ($actions as $action) { |
803
|
|
|
switch ($action[0]) |
804
|
|
|
{ |
805
|
|
|
// Start the Path |
806
|
|
|
case 'M': |
807
|
|
|
case 'm': |
808
|
|
|
$first = $action; |
809
|
|
|
$x = $action[1]; $y = $action[2]; $xc = $x; $yc = $y; |
810
|
|
|
$this->_Point($x, $y, true); |
811
|
|
|
break; |
812
|
|
|
|
813
|
|
|
// Close the Path |
814
|
|
|
case 'Z': |
815
|
|
|
case 'z': |
816
|
|
|
$x = $first[1]; $y = $first[2]; $xc = $x; $yc = $y; |
817
|
|
|
$this->_Line($x, $y, true); |
818
|
|
|
break; |
819
|
|
|
|
820
|
|
|
// Make a Line (new point) |
821
|
|
|
case 'L': |
822
|
|
|
$x = $action[1]; $y = $action[2]; $xc = $x; $yc = $y; |
823
|
|
|
$this->_Line($x, $y, true); |
824
|
|
|
break; |
825
|
|
|
|
826
|
|
|
// Make a Line (vector from last point) |
827
|
|
View Code Duplication |
case 'l': |
828
|
|
|
$x = $last[0] + $action[1]; $y = $last[1] + $action[2]; $xc = $x; $yc = $y; |
829
|
|
|
$this->_Line($x, $y, true); |
830
|
|
|
break; |
831
|
|
|
|
832
|
|
|
// Make a Horizontal Line (new point) |
833
|
|
|
case 'H': |
834
|
|
|
$x = $action[1]; $y = $last[1]; $xc = $x; $yc = $y; |
835
|
|
|
$this->_Line($x, $y, true); |
836
|
|
|
break; |
837
|
|
|
|
838
|
|
|
// Make a Horisontal Line (vector from last point) |
839
|
|
View Code Duplication |
case 'h': |
840
|
|
|
$x = $last[0] + $action[1]; $y = $last[1]; $xc = $x; $yc = $y; |
841
|
|
|
$this->_Line($x, $y, true); |
842
|
|
|
break; |
843
|
|
|
|
844
|
|
|
// Make a Vertical Line (new point) |
845
|
|
|
case 'V': |
846
|
|
|
$x = $last[0]; $y = $action[1]; $xc = $x; $yc = $y; |
847
|
|
|
$this->_Line($x, $y, true); |
848
|
|
|
break; |
849
|
|
|
|
850
|
|
|
// Make a Vertical Line (vector from last point) |
851
|
|
View Code Duplication |
case 'v': |
852
|
|
|
$x = $last[0]; $y = $last[1] + $action[1]; $xc = $x; $yc = $y; |
853
|
|
|
$this->_Line($x, $y, true); |
854
|
|
|
break; |
855
|
|
|
|
856
|
|
|
// Make a Arc (new point) |
857
|
|
|
case 'A': |
858
|
|
|
$rx = $action[1]; // rx |
859
|
|
|
$ry = $action[2]; // ry |
860
|
|
|
$a = $action[3]; // deviation angle of the axis X |
861
|
|
|
$l = $action[4]; // large-arc-flag |
862
|
|
|
$s = $action[5]; // sweep-flag |
863
|
|
|
$x1 = $last[0]; // begin x |
864
|
|
|
$y1 = $last[1]; // begin y |
865
|
|
|
$x2 = $action[6]; // final x |
866
|
|
|
$y2 = $action[7]; // final y |
867
|
|
|
|
868
|
|
|
$this->_Arc2($x1, $y1, $x2, $y2, $rx, $ry, $a, $l, $s, true); |
869
|
|
|
$x = $x2; $y = $y2; $xc = $x; $yc = $y; |
870
|
|
|
break; |
871
|
|
|
|
872
|
|
|
// Make a Arc (vector from last point) |
873
|
|
|
case 'a': |
874
|
|
|
$rx = $action[1]; // rx |
875
|
|
|
$ry = $action[2]; // ry |
876
|
|
|
$a = $action[3]; // deviation angle of the axis X |
877
|
|
|
$l = $action[4]; // large-arc-flag |
878
|
|
|
$s = $action[5]; // sweep-flag |
879
|
|
|
$x1 = $last[0]; // begin x |
880
|
|
|
$y1 = $last[1]; // begin y |
881
|
|
|
$x2 = $last[0] + $action[6]; // final x |
882
|
|
|
$y2 = $last[1] + $action[7]; // final y |
883
|
|
|
|
884
|
|
|
$this->_Arc2($x1, $y1, $x2, $y2, $rx, $ry, $a, $l, $s, true); |
885
|
|
|
$x = $x2; $y = $y2; $xc = $x; $yc = $y; |
886
|
|
|
break; |
887
|
|
|
|
888
|
|
|
// Make a Bezier Curve (new point) |
889
|
|
|
case 'C': |
890
|
|
|
$x1 = $action[1]; |
891
|
|
|
$y1 = $action[2]; |
892
|
|
|
$x2 = $action[3]; |
893
|
|
|
$y2 = $action[4]; |
894
|
|
|
$xf = $action[5]; |
895
|
|
|
$yf = $action[6]; |
896
|
|
|
$this->_Curve($x1, $y1, $x2, $y2, $xf, $yf, true); |
897
|
|
|
$x = $xf; $y = $yf; $xc = $x2; $yc = $y2; |
898
|
|
|
break; |
899
|
|
|
|
900
|
|
|
// Make a Bezier Curve (vector from last point) |
901
|
|
|
case 'c': |
902
|
|
|
$x1 = $last[0] + $action[1]; |
903
|
|
|
$y1 = $last[1] + $action[2]; |
904
|
|
|
$x2 = $last[0] + $action[3]; |
905
|
|
|
$y2 = $last[1] + $action[4]; |
906
|
|
|
$xf = $last[0] + $action[5]; |
907
|
|
|
$yf = $last[1] + $action[6]; |
908
|
|
|
$this->_Curve($x1, $y1, $x2, $y2, $xf, $yf, true); |
909
|
|
|
$x = $xf; $y = $yf; $xc = $x2; $yc = $y2; |
910
|
|
|
break; |
911
|
|
|
|
912
|
|
|
// Unknown Path |
913
|
|
|
default: |
914
|
|
|
throw new HTML2PDF_exception(0, 'SVG Path Error : ['.$action[0].'] unkown'); |
915
|
|
|
} |
916
|
|
|
|
917
|
|
|
// save the last point |
918
|
|
|
$last = array($x, $y, $xc, $yc); |
919
|
|
|
} |
920
|
|
|
|
921
|
|
|
// finish the path |
922
|
|
|
$this->_out($op); |
923
|
|
|
} |
924
|
|
|
|
925
|
|
|
/** |
926
|
|
|
* SVG - go to a point |
927
|
|
|
* |
928
|
|
|
* @param float $x |
929
|
|
|
* @param float $y |
930
|
|
|
* @param boolean $trans apply transformation |
931
|
|
|
* @access protected |
932
|
|
|
*/ |
933
|
|
|
protected function _Point($x, $y, $trans = false) |
934
|
|
|
{ |
935
|
|
|
if ($trans) { |
936
|
|
|
$this->ptTransform($x, $y); |
937
|
|
|
} |
938
|
|
|
|
939
|
|
|
$this->_out(sprintf('%.2F %.2F m', $x, $y)); |
940
|
|
|
} |
941
|
|
|
|
942
|
|
|
/** |
943
|
|
|
* SVG - make a line from the last point to (x,y) |
944
|
|
|
* |
945
|
|
|
* @param float $x |
946
|
|
|
* @param float $y |
947
|
|
|
* @param boolean $trans apply transformation |
948
|
|
|
* @access protected |
949
|
|
|
*/ |
950
|
|
|
protected function _Line($x, $y, $trans = false) |
951
|
|
|
{ |
952
|
|
|
if ($trans) { |
953
|
|
|
$this->ptTransform($x, $y); |
954
|
|
|
} |
955
|
|
|
|
956
|
|
|
$this->_out(sprintf('%.2F %.2F l', $x, $y)); |
957
|
|
|
} |
958
|
|
|
|
959
|
|
|
/** |
960
|
|
|
* SVG - make a bezier curve from the last point to (xf,yf), with the 2 direction points (x1,y1) and (x2,y2) |
961
|
|
|
* |
962
|
|
|
* @param float $x1 |
963
|
|
|
* @param float $y1 |
964
|
|
|
* @param float $x2 |
965
|
|
|
* @param float $y2 |
966
|
|
|
* @param float $xf |
967
|
|
|
* @param float $yf |
968
|
|
|
* @param boolean $trans apply transformation |
969
|
|
|
* @access protected |
970
|
|
|
*/ |
971
|
|
|
protected function _Curve($x1, $y1, $x2, $y2, $xf, $yf, $trans = false) |
972
|
|
|
{ |
973
|
|
|
if ($trans) { |
974
|
|
|
$this->ptTransform($x1, $y1); |
975
|
|
|
$this->ptTransform($x2, $y2); |
976
|
|
|
$this->ptTransform($xf, $yf); |
977
|
|
|
} |
978
|
|
|
$this->_out(sprintf('%.2F %.2F %.2F %.2F %.2F %.2F c', $x1, $y1, $x2, $y2, $xf, $yf)); |
979
|
|
|
} |
980
|
|
|
|
981
|
|
|
/** |
982
|
|
|
* SVG - make a arc with Center, Radius, from angleBegin to angleEnd |
983
|
|
|
* |
984
|
|
|
* @param float $xc |
985
|
|
|
* @param float $yc |
986
|
|
|
* @param float $rx |
987
|
|
|
* @param float $ry |
988
|
|
|
* @param float $angleBegin in radians |
989
|
|
|
* @param float $angleEnd in radians |
990
|
|
|
* @param boolean $direction |
991
|
|
|
* @param boolean $drawFirst, true => add the first point |
|
|
|
|
992
|
|
|
* @param boolean $trans apply transformation |
993
|
|
|
* @access protected |
994
|
|
|
*/ |
995
|
|
|
protected function _Arc( |
996
|
|
|
$xc, |
997
|
|
|
$yc, |
998
|
|
|
$rx, |
999
|
|
|
$ry, |
1000
|
|
|
$angleBegin, |
1001
|
|
|
$angleEnd, |
1002
|
|
|
$direction = true, |
1003
|
|
|
$drawFirst = true, |
1004
|
|
|
$trans = false) |
1005
|
|
|
{ |
1006
|
|
|
// if we want the no trigo direction : add 2PI to the begin angle, to invert the direction |
1007
|
|
|
if ( ! $direction) $angleBegin += M_PI * 2.; |
1008
|
|
|
|
1009
|
|
|
// cut in segment to convert in berize curv |
1010
|
|
|
$dt = ($angleEnd - $angleBegin) / self::ARC_NB_SEGMENT; |
1011
|
|
|
$dtm = $dt / 3; |
1012
|
|
|
|
1013
|
|
|
// center of the arc |
1014
|
|
|
$x0 = $xc; $y0 = $yc; |
1015
|
|
|
|
1016
|
|
|
// calculing the first point |
1017
|
|
|
$t1 = $angleBegin; |
1018
|
|
|
$a0 = $x0 + ($rx * cos($t1)); |
1019
|
|
|
$b0 = $y0 + ($ry * sin($t1)); |
1020
|
|
|
$c0 = -$rx * sin($t1); |
1021
|
|
|
$d0 = $ry * cos($t1); |
1022
|
|
|
|
1023
|
|
|
// if drawFirst => draw the first point |
1024
|
|
|
if ($drawFirst) { |
1025
|
|
|
$this->_Point($a0, $b0, $trans); |
1026
|
|
|
} |
1027
|
|
|
|
1028
|
|
|
// foreach segment |
1029
|
|
|
for ($i = 1; $i <= self::ARC_NB_SEGMENT; $i++) { |
1030
|
|
|
// calculing the next point |
1031
|
|
|
$t1 = ($i * $dt) + $angleBegin; |
1032
|
|
|
$a1 = $x0 + ($rx * cos($t1)); |
1033
|
|
|
$b1 = $y0 + ($ry * sin($t1)); |
1034
|
|
|
$c1 = -$rx * sin($t1); |
1035
|
|
|
$d1 = $ry * cos($t1); |
1036
|
|
|
|
1037
|
|
|
// make the bezier curv |
1038
|
|
|
$this->_Curve( |
1039
|
|
|
$a0 + ($c0 * $dtm), $b0 + ($d0 * $dtm), |
1040
|
|
|
$a1 - ($c1 * $dtm), $b1 - ($d1 * $dtm), |
1041
|
|
|
$a1, $b1, |
1042
|
|
|
$trans |
1043
|
|
|
); |
1044
|
|
|
|
1045
|
|
|
// save the point |
1046
|
|
|
$a0 = $a1; |
1047
|
|
|
$b0 = $b1; |
1048
|
|
|
$c0 = $c1; |
1049
|
|
|
$d0 = $d1; |
1050
|
|
|
} |
1051
|
|
|
} |
1052
|
|
|
|
1053
|
|
|
/** |
1054
|
|
|
* SVG - make a arc from Pt1 to Pt2, with Radius |
1055
|
|
|
* |
1056
|
|
|
* @param float $x1 |
1057
|
|
|
* @param float $y1 |
1058
|
|
|
* @param float $x2 |
1059
|
|
|
* @param float $y2 |
1060
|
|
|
* @param float $rx |
1061
|
|
|
* @param float $ry |
1062
|
|
|
* @param float $angle deviation angle of the axis X |
1063
|
|
|
* @param integer $l large-arc-flag |
1064
|
|
|
* @param integer $s sweep-flag |
1065
|
|
|
* @param boolean $trans apply transformation |
1066
|
|
|
* @access protected |
1067
|
|
|
*/ |
1068
|
|
|
protected function _Arc2($x1, $y1, $x2, $y2, $rx, $ry, $angle = 0., $l = 0, $s = 0, $trans = false) |
1069
|
|
|
{ |
1070
|
|
|
// array to stock the parameters |
1071
|
|
|
$v = array(); |
1072
|
|
|
|
1073
|
|
|
// the original values |
1074
|
|
|
$v['x1'] = $x1; |
1075
|
|
|
$v['y1'] = $y1; |
1076
|
|
|
$v['x2'] = $x2; |
1077
|
|
|
$v['y2'] = $y2; |
1078
|
|
|
$v['rx'] = $rx; |
1079
|
|
|
$v['ry'] = $ry; |
1080
|
|
|
|
1081
|
|
|
// rotate with the deviation angle of the axis X |
1082
|
|
|
$v['xr1'] = $v['x1'] * cos($angle) - $v['y1'] * sin($angle); |
1083
|
|
|
$v['yr1'] = $v['x1'] * sin($angle) + $v['y1'] * cos($angle); |
1084
|
|
|
$v['xr2'] = $v['x2'] * cos($angle) - $v['y2'] * sin($angle); |
1085
|
|
|
$v['yr2'] = $v['x2'] * sin($angle) + $v['y2'] * cos($angle); |
1086
|
|
|
|
1087
|
|
|
// the normalized vector |
1088
|
|
|
$v['Xr1'] = $v['xr1'] / $v['rx']; |
1089
|
|
|
$v['Yr1'] = $v['yr1'] / $v['ry']; |
1090
|
|
|
$v['Xr2'] = $v['xr2'] / $v['rx']; |
1091
|
|
|
$v['Yr2'] = $v['yr2'] / $v['ry']; |
1092
|
|
|
$v['dXr'] = $v['Xr2'] - $v['Xr1']; |
1093
|
|
|
$v['dYr'] = $v['Yr2'] - $v['Yr1']; |
1094
|
|
|
$v['D'] = $v['dXr'] * $v['dXr'] + $v['dYr'] * $v['dYr']; |
1095
|
|
|
|
1096
|
|
|
// if |vector| is Null, or if |vector| > 2 : impossible to make a arc => Line |
1097
|
|
|
if ($v['D'] == 0 || $v['D'] > 4) { |
1098
|
|
|
$this->_Line($x2, $y2, $trans); |
1099
|
|
|
return false; |
1100
|
|
|
} |
1101
|
|
|
|
1102
|
|
|
// convert paramters for make a arc with Center, Radius, from angleBegin to angleEnd |
1103
|
|
|
$v['s1'] = array(); |
1104
|
|
|
$v['s1']['t'] = sqrt((4. - $v['D']) / $v['D']); |
1105
|
|
|
$v['s1']['Xr'] = ($v['Xr1'] + $v['Xr2']) / 2. + $v['s1']['t'] * ($v['Yr2'] - $v['Yr1']) / 2.; |
1106
|
|
|
$v['s1']['Yr'] = ($v['Yr1'] + $v['Yr2']) / 2. + $v['s1']['t'] * ($v['Xr1'] - $v['Xr2']) / 2.; |
1107
|
|
|
$v['s1']['xr'] = $v['s1']['Xr'] * $v['rx']; |
1108
|
|
|
$v['s1']['yr'] = $v['s1']['Yr'] * $v['ry']; |
1109
|
|
|
$v['s1']['x'] = $v['s1']['xr'] * cos($angle) + $v['s1']['yr'] * sin($angle); |
1110
|
|
|
$v['s1']['y'] = -$v['s1']['xr'] * sin($angle) + $v['s1']['yr'] * cos($angle); |
1111
|
|
|
$v['s1']['a1'] = atan2($v['y1'] - $v['s1']['y'], $v['x1'] - $v['s1']['x']); |
1112
|
|
|
$v['s1']['a2'] = atan2($v['y2'] - $v['s1']['y'], $v['x2'] - $v['s1']['x']); |
1113
|
|
View Code Duplication |
if ($v['s1']['a1'] > $v['s1']['a2']) $v['s1']['a1'] -= 2 * M_PI; |
1114
|
|
|
|
1115
|
|
|
$v['s2'] = array(); |
1116
|
|
|
$v['s2']['t'] = -$v['s1']['t']; |
1117
|
|
|
$v['s2']['Xr'] = ($v['Xr1'] + $v['Xr2']) / 2. + $v['s2']['t'] * ($v['Yr2'] - $v['Yr1']) / 2.; |
1118
|
|
|
$v['s2']['Yr'] = ($v['Yr1'] + $v['Yr2']) / 2. + $v['s2']['t'] * ($v['Xr1'] - $v['Xr2']) / 2.; |
1119
|
|
|
$v['s2']['xr'] = $v['s2']['Xr'] * $v['rx']; |
1120
|
|
|
$v['s2']['yr'] = $v['s2']['Yr'] * $v['ry']; |
1121
|
|
|
$v['s2']['x'] = $v['s2']['xr'] * cos($angle) + $v['s2']['yr'] * sin($angle); |
1122
|
|
|
$v['s2']['y'] = -$v['s2']['xr'] * sin($angle) + $v['s2']['yr'] * cos($angle); |
1123
|
|
|
$v['s2']['a1'] = atan2($v['y1'] - $v['s2']['y'], $v['x1'] - $v['s2']['x']); |
1124
|
|
|
$v['s2']['a2'] = atan2($v['y2'] - $v['s2']['y'], $v['x2'] - $v['s2']['x']); |
1125
|
|
View Code Duplication |
if ($v['s2']['a1'] > $v['s2']['a2']) $v['s2']['a1'] -= 2 * M_PI; |
1126
|
|
|
|
1127
|
|
|
if ( ! $l) { |
1128
|
|
View Code Duplication |
if ($s) { |
1129
|
|
|
$xc = $v['s2']['x']; |
1130
|
|
|
$yc = $v['s2']['y']; |
1131
|
|
|
$a1 = $v['s2']['a1']; |
1132
|
|
|
$a2 = $v['s2']['a2']; |
1133
|
|
|
$this->_Arc($xc, $yc, $rx, $ry, $a1, $a2, true, false, $trans); |
1134
|
|
|
} else { |
1135
|
|
|
$xc = $v['s1']['x']; |
1136
|
|
|
$yc = $v['s1']['y']; |
1137
|
|
|
$a1 = $v['s1']['a1']; |
1138
|
|
|
$a2 = $v['s1']['a2']; |
1139
|
|
|
$this->_Arc($xc, $yc, $rx, $ry, $a1, $a2, false, false, $trans); |
1140
|
|
|
} |
1141
|
|
View Code Duplication |
} else { |
1142
|
|
|
if ($s) { |
1143
|
|
|
$xc = $v['s1']['x']; |
1144
|
|
|
$yc = $v['s1']['y']; |
1145
|
|
|
$a1 = $v['s1']['a1']; |
1146
|
|
|
$a2 = $v['s1']['a2']; |
1147
|
|
|
$this->_Arc($xc, $yc, $rx, $ry, $a1, $a2, true, false, $trans); |
1148
|
|
|
} else { |
1149
|
|
|
$xc = $v['s2']['x']; |
1150
|
|
|
$yc = $v['s2']['y']; |
1151
|
|
|
$a1 = $v['s2']['a1']; |
1152
|
|
|
$a2 = $v['s2']['a2']; |
1153
|
|
|
$this->_Arc($xc, $yc, $rx, $ry, $a1, $a2, false, false, $trans); |
1154
|
|
|
} |
1155
|
|
|
} |
1156
|
|
|
} |
1157
|
|
|
|
1158
|
|
|
/** |
1159
|
|
|
* SVG - transform the point (reference) |
1160
|
|
|
* |
1161
|
|
|
* @param float &$x |
1162
|
|
|
* @param float &$y |
1163
|
|
|
* @param boolean $trans true => convert into PDF unit |
1164
|
|
|
* @param double $x |
1165
|
|
|
* @param double $y |
1166
|
|
|
* @return boolean |
1167
|
|
|
* @access public |
1168
|
|
|
*/ |
1169
|
|
|
public function ptTransform(&$x, &$y, $trans = true) |
1170
|
|
|
{ |
1171
|
|
|
// load the last Transfomation Matrix |
1172
|
|
|
$nb = count($this->_transf); |
1173
|
|
View Code Duplication |
if ($nb) $m = $this->_transf[$nb - 1]; |
1174
|
|
|
else $m = array(1, 0, 0, 1, 0, 0); |
1175
|
|
|
|
1176
|
|
|
// apply the Transformation Matrix |
1177
|
|
|
list($x, $y) = array(($x * $m[0] + $y * $m[2] + $m[4]), ($x * $m[1] + $y * $m[3] + $m[5])); |
1178
|
|
|
|
1179
|
|
|
// if true => convert into PDF unit |
1180
|
|
|
if ($trans) { |
1181
|
|
|
$x = $x * $this->k; |
1182
|
|
|
$y = ($this->h - $y) * $this->k; |
1183
|
|
|
} |
1184
|
|
|
|
1185
|
|
|
return true; |
1186
|
|
|
} |
1187
|
|
|
|
1188
|
|
|
/** |
1189
|
|
|
* SVG - add a transformation Matric |
1190
|
|
|
* |
1191
|
|
|
* @param array $n matrix |
1192
|
|
|
* @access public |
1193
|
|
|
*/ |
1194
|
|
|
public function doTransform($n = null) |
1195
|
|
|
{ |
1196
|
|
|
// get the last Transformation Matrix |
1197
|
|
|
$nb = count($this->_transf); |
1198
|
|
View Code Duplication |
if ($nb) $m = $this->_transf[$nb - 1]; |
1199
|
|
|
else $m = array(1, 0, 0, 1, 0, 0); |
1200
|
|
|
|
1201
|
|
|
// if no transform, get the Identity Matrix |
1202
|
|
|
if ( ! $n) $n = array(1, 0, 0, 1, 0, 0); |
1203
|
|
|
|
1204
|
|
|
// create the new Transformation Matrix |
1205
|
|
|
$this->_transf[] = array( |
1206
|
|
|
$m[0] * $n[0] + $m[2] * $n[1], |
1207
|
|
|
$m[1] * $n[0] + $m[3] * $n[1], |
1208
|
|
|
$m[0] * $n[2] + $m[2] * $n[3], |
1209
|
|
|
$m[1] * $n[2] + $m[3] * $n[3], |
1210
|
|
|
$m[0] * $n[4] + $m[2] * $n[5] + $m[4], |
1211
|
|
|
$m[1] * $n[4] + $m[3] * $n[5] + $m[5] |
1212
|
|
|
); |
1213
|
|
|
} |
1214
|
|
|
|
1215
|
|
|
/** |
1216
|
|
|
* SVG - remove a transformation Matric |
1217
|
|
|
* |
1218
|
|
|
* @access public |
1219
|
|
|
*/ |
1220
|
|
|
public function undoTransform() |
1221
|
|
|
{ |
1222
|
|
|
array_pop($this->_transf); |
1223
|
|
|
} |
1224
|
|
|
|
1225
|
|
|
/** |
1226
|
|
|
* Convert a HTML2PDF barcode in a TCPDF barcode |
1227
|
|
|
* |
1228
|
|
|
* @param string $code code to print |
1229
|
|
|
* @param string $type type of barcode (see tcpdf/barcodes.php for supported formats) |
1230
|
|
|
* @param int $x x position in user units |
1231
|
|
|
* @param int $y y position in user units |
1232
|
|
|
* @param int $w width in user units |
1233
|
|
|
* @param int $h height in user units |
1234
|
|
|
* @param int $labelFontsize of the Test Label. If false : no Label |
1235
|
|
|
* @param array $color color of the foreground |
1236
|
|
|
* @access public |
1237
|
|
|
*/ |
1238
|
|
|
public function myBarcode($code, $type, $x, $y, $w, $h, $labelFontsize, $color) |
1239
|
|
|
{ |
1240
|
|
|
// the style of the barcode |
1241
|
|
|
$style = array( |
1242
|
|
|
'position' => 'S', |
1243
|
|
|
'text' => ($labelFontsize ? true : false), |
1244
|
|
|
'fgcolor' => $color, |
1245
|
|
|
'bgcolor' => false, |
1246
|
|
|
); |
1247
|
|
|
|
1248
|
|
|
// build the barcode |
1249
|
|
|
$this->write1DBarcode($code, $type, $x, $y, $w, $h, '', $style, 'N'); |
1250
|
|
|
|
1251
|
|
|
// it Label => add the FontSize to the height |
1252
|
|
|
if ($labelFontsize) $h += ($labelFontsize); |
1253
|
|
|
|
1254
|
|
|
// return the size of the barcode |
1255
|
|
|
return array($w, $h); |
1256
|
|
|
} |
1257
|
|
|
|
1258
|
|
|
/** |
1259
|
|
|
* create a automatic Index on a page |
1260
|
|
|
* |
1261
|
|
|
* @param html2pdf $obj parent object |
1262
|
|
|
* @param string $titre Title of the Index Page |
1263
|
|
|
* @param integer $sizeTitle Font size for hthe Title |
1264
|
|
|
* @param integer $sizeBookmark Font size for the bookmarks |
1265
|
|
|
* @param boolean $bookmarkTitle Bookmark the Title |
1266
|
|
|
* @param boolean $displayPage Display the page number for each bookmark |
1267
|
|
|
* @param integer $page draw the automatic Index on a specific Page. if null => add a page at the end |
1268
|
|
|
* @param string $fontName FontName to use |
1269
|
|
|
* @access public |
1270
|
|
|
*/ |
1271
|
|
|
public function createIndex( |
1272
|
|
|
&$obj, |
1273
|
|
|
$titre = 'Index', |
1274
|
|
|
$sizeTitle = 20, |
1275
|
|
|
$sizeBookmark = 15, |
1276
|
|
|
$bookmarkTitle = true, |
1277
|
|
|
$displayPage = true, |
1278
|
|
|
$page = null, |
1279
|
|
|
$fontName = 'helvetica') |
1280
|
|
|
{ |
1281
|
|
|
// bookmark the Title if wanted |
1282
|
|
|
if ($bookmarkTitle) { |
1283
|
|
|
$this->Bookmark($titre, 0, -1); |
1284
|
|
|
} |
1285
|
|
|
|
1286
|
|
|
// display the Title with the good Font size |
1287
|
|
|
$this->SetFont($fontName, '', $sizeTitle); |
1288
|
|
|
$this->Cell(0, 5, $titre, 0, 1, 'C'); |
1289
|
|
|
|
1290
|
|
|
// set the good Font size for the bookmarks |
1291
|
|
|
$this->SetFont($fontName, '', $sizeBookmark); |
1292
|
|
|
$this->Ln(10); |
1293
|
|
|
|
1294
|
|
|
// get the number of bookmarks |
1295
|
|
|
$size = sizeof($this->outlines); |
1296
|
|
|
|
1297
|
|
|
// get the size of the "P. xx" cell |
1298
|
|
|
$pageCellSize = $this->GetStringWidth('p. '.$this->outlines[$size - 1]['p']) + 2; |
1299
|
|
|
|
1300
|
|
|
// Foreach bookmark |
1301
|
|
|
for ($i = 0; $i < $size; $i++) { |
1302
|
|
|
// if we need a new page => add a new page |
1303
|
|
|
if ($this->getY() + $this->FontSize >= ($this->h - $this->bMargin)) { |
1304
|
|
|
$obj->_INDEX_NewPage($page); |
1305
|
|
|
$this->SetFont($fontName, '', $sizeBookmark); |
1306
|
|
|
} |
1307
|
|
|
|
1308
|
|
|
// Offset of the current level |
1309
|
|
|
$level = $this->outlines[$i]['l']; |
1310
|
|
|
if ($level > 0) $this->Cell($level * 8); |
1311
|
|
|
|
1312
|
|
|
// Caption (cut to fit on the width page) |
1313
|
|
|
$str = $this->outlines[$i]['t']; |
1314
|
|
|
$strsize = $this->GetStringWidth($str); |
1315
|
|
|
$availableSize = $this->w - $this->lMargin - $this->rMargin - $pageCellSize - ($level * 8) - 4; |
1316
|
|
|
while ($strsize >= $availableSize) { |
1317
|
|
|
$str = substr($str, 0, -1); |
1318
|
|
|
$strsize = $this->GetStringWidth($str); |
1319
|
|
|
} |
1320
|
|
|
|
1321
|
|
|
// if we want to display the page nmber |
1322
|
|
|
if ($displayPage) { |
1323
|
|
|
// display the Bookmark Caption |
1324
|
|
|
$this->Cell($strsize + 2, $this->FontSize + 2, $str); |
1325
|
|
|
|
1326
|
|
|
//Filling dots |
1327
|
|
|
$w = $this->w - $this->lMargin - $this->rMargin - $pageCellSize - ($level * 8) - ($strsize + 2); |
1328
|
|
|
$nb = $w / $this->GetStringWidth('.'); |
1329
|
|
|
$dots = str_repeat('.', $nb); |
1330
|
|
|
$this->Cell($w, $this->FontSize + 2, $dots, 0, 0, 'R'); |
1331
|
|
|
|
1332
|
|
|
//Page number |
1333
|
|
|
$this->Cell($pageCellSize, $this->FontSize + 2, 'p. '.$this->outlines[$i]['p'], 0, 1, 'R'); |
1334
|
|
|
} else { |
1335
|
|
|
// display the Bookmark Caption |
1336
|
|
|
$this->Cell($strsize + 2, $this->FontSize + 2, $str, 0, 1); |
1337
|
|
|
} |
1338
|
|
|
} |
1339
|
|
|
} |
1340
|
|
|
|
1341
|
|
|
/** |
1342
|
|
|
* Returns the string alias used for the total number of pages. |
1343
|
|
|
* |
1344
|
|
|
* @access public |
1345
|
|
|
* @return string; |
|
|
|
|
1346
|
|
|
* @see TCPDF::getAliasNbPages(), TCPDF::getPageGroupAlias() |
1347
|
|
|
*/ |
1348
|
|
|
public function getMyAliasNbPages() |
1349
|
|
|
{ |
1350
|
|
|
if ($this->_myLastPageGroupNb == 0) { |
1351
|
|
|
return $this->getAliasNbPages(); |
1352
|
|
|
} else { |
1353
|
|
|
$old = $this->currpagegroup; |
1354
|
|
|
$this->currpagegroup = '{nb'.$this->_myLastPageGroupNb.'}'; |
1355
|
|
|
$new = $this->getPageGroupAlias(); |
1356
|
|
|
$this->currpagegroup = $old; |
1357
|
|
|
|
1358
|
|
|
return $new; |
1359
|
|
|
} |
1360
|
|
|
} |
1361
|
|
|
|
1362
|
|
|
/** |
1363
|
|
|
* Returns the current page number. |
1364
|
|
|
* |
1365
|
|
|
* @access public |
1366
|
|
|
* @param integer $page |
1367
|
|
|
* @return integer; |
|
|
|
|
1368
|
|
|
*/ |
1369
|
|
|
public function getMyNumPage($page = null) |
1370
|
|
|
{ |
1371
|
|
|
if ($page === null) { |
1372
|
|
|
$page = $this->page; |
1373
|
|
|
} |
1374
|
|
|
|
1375
|
|
|
if ($this->_myLastPageGroupNb == 0) { |
1376
|
|
|
return $page; |
1377
|
|
|
} else { |
1378
|
|
|
return $page - $this->_myLastPageGroup; |
1379
|
|
|
} |
1380
|
|
|
} |
1381
|
|
|
|
1382
|
|
|
/** |
1383
|
|
|
* Start a new group of pages |
1384
|
|
|
* |
1385
|
|
|
* @access public |
1386
|
|
|
* @return integer; |
|
|
|
|
1387
|
|
|
* @see tcpdf::startPageGroup |
1388
|
|
|
*/ |
1389
|
|
|
public function myStartPageGroup() |
1390
|
|
|
{ |
1391
|
|
|
$this->_myLastPageGroup = $this->page - 1; |
1392
|
|
|
$this->_myLastPageGroupNb++; |
1393
|
|
|
} |
1394
|
|
|
|
1395
|
|
|
/** |
1396
|
|
|
* get $_myLastPageGroup; |
1397
|
|
|
* |
1398
|
|
|
* @access public |
1399
|
|
|
* @return integer $_myLastPageGroup; |
1400
|
|
|
*/ |
1401
|
|
|
public function getMyLastPageGroup() |
1402
|
|
|
{ |
1403
|
|
|
return $this->_myLastPageGroup; |
1404
|
|
|
} |
1405
|
|
|
|
1406
|
|
|
/** |
1407
|
|
|
* set $_myLastPageGroup; |
1408
|
|
|
* |
1409
|
|
|
* @access public |
1410
|
|
|
* @param integer $myLastPageGroup; |
|
|
|
|
1411
|
|
|
* @param integer $myLastPageGroup |
1412
|
|
|
*/ |
1413
|
|
|
public function setMyLastPageGroup($myLastPageGroup) |
1414
|
|
|
{ |
1415
|
|
|
$this->_myLastPageGroup = $myLastPageGroup; |
1416
|
|
|
} |
1417
|
|
|
|
1418
|
|
|
/** |
1419
|
|
|
* get $_myLastPageGroupNb; |
1420
|
|
|
* |
1421
|
|
|
* @access public |
1422
|
|
|
* @return integer $_myLastPageGroupNb; |
1423
|
|
|
*/ |
1424
|
|
|
public function getMyLastPageGroupNb() |
1425
|
|
|
{ |
1426
|
|
|
return $this->_myLastPageGroupNb; |
1427
|
|
|
} |
1428
|
|
|
|
1429
|
|
|
/** |
1430
|
|
|
* set $_myLastPageGroupNb; |
1431
|
|
|
* |
1432
|
|
|
* @access public |
1433
|
|
|
* @param integer $myLastPageGroupNb; |
|
|
|
|
1434
|
|
|
* @param integer $myLastPageGroupNb |
1435
|
|
|
*/ |
1436
|
|
|
public function setMyLastPageGroupNb($myLastPageGroupNb) |
1437
|
|
|
{ |
1438
|
|
|
$this->_myLastPageGroupNb = $myLastPageGroupNb; |
1439
|
|
|
} |
1440
|
|
|
} |
1441
|
|
|
|
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.