@@ -13,16 +13,16 @@ |
||
13 | 13 | |
14 | 14 | $date = time(); |
15 | 15 | for ($iRow=1; $iRow <= 100; $iRow++) { |
16 | - // just a simple demo - most cases data comes from DB-query ;-) |
|
17 | - $row = array( |
|
18 | - 'text' => 'Text in var Col, Line ' . $iRow, |
|
19 | - 'weight' => (rand(10, 500) / 10), |
|
20 | - 'date' => date('Y-m-d', $date), |
|
21 | - 'price' => (rand(10, 2000) / 9), |
|
22 | - 'grp_id' => rand(1, 4) |
|
23 | - ); |
|
24 | - $pdf->Row($row); |
|
25 | - $date += 24 * 60 * 60; |
|
16 | + // just a simple demo - most cases data comes from DB-query ;-) |
|
17 | + $row = array( |
|
18 | + 'text' => 'Text in var Col, Line ' . $iRow, |
|
19 | + 'weight' => (rand(10, 500) / 10), |
|
20 | + 'date' => date('Y-m-d', $date), |
|
21 | + 'price' => (rand(10, 2000) / 9), |
|
22 | + 'grp_id' => rand(1, 4) |
|
23 | + ); |
|
24 | + $pdf->Row($row); |
|
25 | + $date += 24 * 60 * 60; |
|
26 | 26 | } |
27 | 27 | // ...and end of the grid |
28 | 28 | $pdf->EndGrid(); |
@@ -6,13 +6,13 @@ |
||
6 | 6 | |
7 | 7 | // set some file information |
8 | 8 | $pdf->SetInfo('XFPDF', 'Example', 'PHP classes', 'Keyword1, Keyword2, ...'); |
9 | -$pdf->SetPageHeader( 'Create PDF Table', 'using extpdf package from PHPClasses.org'); |
|
9 | +$pdf->SetPageHeader('Create PDF Table', 'using extpdf package from PHPClasses.org'); |
|
10 | 10 | |
11 | 11 | // prepare grid and just insert a bulk of lines |
12 | 12 | $pdf->Prepare(); |
13 | 13 | |
14 | 14 | $date = time(); |
15 | -for ($iRow=1; $iRow <= 100; $iRow++) { |
|
15 | +for ($iRow = 1; $iRow <= 100; $iRow++) { |
|
16 | 16 | // just a simple demo - most cases data comes from DB-query ;-) |
17 | 17 | $row = array( |
18 | 18 | 'text' => 'Text in var Col, Line ' . $iRow, |
@@ -17,23 +17,23 @@ |
||
17 | 17 | */ |
18 | 18 | class XPDFFont |
19 | 19 | { |
20 | - /** @var string fontname */ |
|
21 | - public string $strFontname; |
|
22 | - /** @var int size */ |
|
23 | - public int $iSize; |
|
24 | - /** @var string style */ |
|
25 | - public string $strStyle; |
|
20 | + /** @var string fontname */ |
|
21 | + public string $strFontname; |
|
22 | + /** @var int size */ |
|
23 | + public int $iSize; |
|
24 | + /** @var string style */ |
|
25 | + public string $strStyle; |
|
26 | 26 | |
27 | - /** |
|
28 | - * Creates a Font-object |
|
29 | - * @param string $strFontname |
|
30 | - * @param string $strStyle 'B', 'I' or 'BI' |
|
31 | - * @param int $iSize |
|
32 | - */ |
|
33 | - function __construct(string $strFontname, string $strStyle, int $iSize) |
|
34 | - { |
|
35 | - $this->strFontname = $strFontname; |
|
36 | - $this->strStyle = $strStyle; |
|
37 | - $this->iSize = $iSize; |
|
38 | - } |
|
27 | + /** |
|
28 | + * Creates a Font-object |
|
29 | + * @param string $strFontname |
|
30 | + * @param string $strStyle 'B', 'I' or 'BI' |
|
31 | + * @param int $iSize |
|
32 | + */ |
|
33 | + function __construct(string $strFontname, string $strStyle, int $iSize) |
|
34 | + { |
|
35 | + $this->strFontname = $strFontname; |
|
36 | + $this->strStyle = $strStyle; |
|
37 | + $this->iSize = $iSize; |
|
38 | + } |
|
39 | 39 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * http://www.fpdf.org/en/doc/index.php |
25 | 25 | *******************************************************************************/ |
26 | 26 | |
27 | -define('FPDF_VERSION','1.82'); |
|
27 | +define('FPDF_VERSION', '1.82'); |
|
28 | 28 | |
29 | 29 | class FPDF |
30 | 30 | { |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * or an array containing the width and the height (expressed in the unit given by unit). <br/> |
176 | 176 | * Default value is 'A4'. |
177 | 177 | */ |
178 | - public function __construct(string $orientation='P', string $unit='mm', $size='A4') |
|
178 | + public function __construct(string $orientation = 'P', string $unit = 'mm', $size = 'A4') |
|
179 | 179 | { |
180 | 180 | // Some checks |
181 | 181 | $this->doChecks(); |
@@ -191,10 +191,10 @@ discard block |
||
191 | 191 | $this->k = 1; |
192 | 192 | break; |
193 | 193 | case 'mm': |
194 | - $this->k = 72/25.4; |
|
194 | + $this->k = 72 / 25.4; |
|
195 | 195 | break; |
196 | 196 | case 'cm': |
197 | - $this->k = 72/2.54; |
|
197 | + $this->k = 72 / 2.54; |
|
198 | 198 | break; |
199 | 199 | case 'in': |
200 | 200 | $this->k = 72; |
@@ -254,12 +254,12 @@ discard block |
||
254 | 254 | * @param float $top Top margin. |
255 | 255 | * @param float $right Right margin. Default value is the left one. |
256 | 256 | */ |
257 | - public function SetMargins(float $left, float $top, ?float $right=null) : void |
|
257 | + public function SetMargins(float $left, float $top, ?float $right = null) : void |
|
258 | 258 | { |
259 | 259 | // Set left, top and right margins |
260 | 260 | $this->lMargin = $left; |
261 | 261 | $this->tMargin = $top; |
262 | - if($right===null) |
|
262 | + if ($right === null) |
|
263 | 263 | $right = $left; |
264 | 264 | $this->rMargin = $right; |
265 | 265 | } |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | { |
275 | 275 | // Set left margin |
276 | 276 | $this->lMargin = $margin; |
277 | - if($this->page>0 && $this->x<$margin) |
|
277 | + if ($this->page > 0 && $this->x < $margin) |
|
278 | 278 | $this->x = $margin; |
279 | 279 | } |
280 | 280 | |
@@ -308,12 +308,12 @@ discard block |
||
308 | 308 | * @param bool $auto indicating if mode should be on or off. |
309 | 309 | * @param float $margin Distance from the bottom of the page. |
310 | 310 | */ |
311 | - public function SetAutoPageBreak(bool $auto, float $margin=0) : void |
|
311 | + public function SetAutoPageBreak(bool $auto, float $margin = 0) : void |
|
312 | 312 | { |
313 | 313 | // Set auto page break mode and triggering margin |
314 | 314 | $this->AutoPageBreak = $auto; |
315 | 315 | $this->bMargin = $margin; |
316 | - $this->PageBreakTrigger = $this->h-$margin; |
|
316 | + $this->PageBreakTrigger = $this->h - $margin; |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -344,17 +344,17 @@ discard block |
||
344 | 344 | * <li> 'defaul't: uses viewer default mode </li></ul> |
345 | 345 | * Default value is default. |
346 | 346 | */ |
347 | - public function SetDisplayMode($zoom, string $layout='default') : void |
|
347 | + public function SetDisplayMode($zoom, string $layout = 'default') : void |
|
348 | 348 | { |
349 | 349 | // Set display mode in viewer |
350 | - if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) |
|
350 | + if ($zoom == 'fullpage' || $zoom == 'fullwidth' || $zoom == 'real' || $zoom == 'default' || !is_string($zoom)) |
|
351 | 351 | $this->ZoomMode = $zoom; |
352 | 352 | else |
353 | - $this->Error('Incorrect zoom display mode: '.$zoom); |
|
354 | - if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') |
|
353 | + $this->Error('Incorrect zoom display mode: ' . $zoom); |
|
354 | + if ($layout == 'single' || $layout == 'continuous' || $layout == 'two' || $layout == 'default') |
|
355 | 355 | $this->LayoutMode = $layout; |
356 | 356 | else |
357 | - $this->Error('Incorrect layout display mode: '.$layout); |
|
357 | + $this->Error('Incorrect layout display mode: ' . $layout); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | /** |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | public function SetCompression(bool $compress) : void |
370 | 370 | { |
371 | 371 | // Set page compression |
372 | - if(function_exists('gzcompress')) |
|
372 | + if (function_exists('gzcompress')) |
|
373 | 373 | $this->compress = $compress; |
374 | 374 | else |
375 | 375 | $this->compress = false; |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | * @param string $title The title. |
381 | 381 | * @param bool $isUTF8 Indicates if the string is encoded in ISO-8859-1 (false) or UTF-8 (true). Default value: false. |
382 | 382 | */ |
383 | - public function SetTitle(string $title, bool $isUTF8=false) : void |
|
383 | + public function SetTitle(string $title, bool $isUTF8 = false) : void |
|
384 | 384 | { |
385 | 385 | // Title of document |
386 | 386 | $this->metadata['Title'] = $isUTF8 ? $title : utf8_encode($title); |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | * @param string $author |
392 | 392 | * @param bool $isUTF8 Indicates if the string is encoded in ISO-8859-1 (false) or UTF-8 (true). Default value: false. |
393 | 393 | */ |
394 | - public function SetAuthor(string $author, bool $isUTF8=false) : void |
|
394 | + public function SetAuthor(string $author, bool $isUTF8 = false) : void |
|
395 | 395 | { |
396 | 396 | // Author of document |
397 | 397 | $this->metadata['Author'] = $isUTF8 ? $author : utf8_encode($author); |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | * @param string $subject |
403 | 403 | * @param bool $isUTF8 Indicates if the string is encoded in ISO-8859-1 (false) or UTF-8 (true). Default value: false. |
404 | 404 | */ |
405 | - public function SetSubject(string $subject, bool $isUTF8=false) : void |
|
405 | + public function SetSubject(string $subject, bool $isUTF8 = false) : void |
|
406 | 406 | { |
407 | 407 | // Subject of document |
408 | 408 | $this->metadata['Subject'] = $isUTF8 ? $subject : utf8_encode($subject); |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | * @param string $keywords |
414 | 414 | * @param bool $isUTF8 Indicates if the string is encoded in ISO-8859-1 (false) or UTF-8 (true). Default value: false. |
415 | 415 | */ |
416 | - public function SetKeywords(string $keywords, bool $isUTF8=false) : void |
|
416 | + public function SetKeywords(string $keywords, bool $isUTF8 = false) : void |
|
417 | 417 | { |
418 | 418 | // Keywords of document |
419 | 419 | $this->metadata['Keywords'] = $isUTF8 ? $keywords : utf8_encode($keywords); |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * @param string $creator |
425 | 425 | * @param bool $isUTF8 Indicates if the string is encoded in ISO-8859-1 (false) or UTF-8 (true). Default value: false. |
426 | 426 | */ |
427 | - public function SetCreator(string $creator, bool $isUTF8=false) : void |
|
427 | + public function SetCreator(string $creator, bool $isUTF8 = false) : void |
|
428 | 428 | { |
429 | 429 | // Creator of document |
430 | 430 | $this->metadata['Creator'] = $isUTF8 ? $creator : utf8_encode($creator); |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | * Defines an alias for the total number of pages. It will be substituted as the document is closed. |
435 | 435 | * @param string $alias The alias. Default value: {nb}. |
436 | 436 | */ |
437 | - public function AliasNbPages(string $alias='{nb}') : void |
|
437 | + public function AliasNbPages(string $alias = '{nb}') : void |
|
438 | 438 | { |
439 | 439 | // Define an alias for total number of pages |
440 | 440 | $this->AliasNbPages = $alias; |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | public function Error(string $msg) : void |
452 | 452 | { |
453 | 453 | // Fatal error |
454 | - throw new \Exception('FPDF error: '.$msg); |
|
454 | + throw new \Exception('FPDF error: ' . $msg); |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | /** |
@@ -463,9 +463,9 @@ discard block |
||
463 | 463 | public function Close() : void |
464 | 464 | { |
465 | 465 | // Terminate document |
466 | - if($this->state==3) |
|
466 | + if ($this->state == 3) |
|
467 | 467 | return; |
468 | - if($this->page==0) |
|
468 | + if ($this->page == 0) |
|
469 | 469 | $this->addPage(); |
470 | 470 | // Page footer |
471 | 471 | $this->InFooter = true; |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | * It must be a multiple of 90; positive values mean clockwise rotation. </br> |
506 | 506 | * The default value is 0. |
507 | 507 | */ |
508 | - public function AddPage(string $orientation='', $size='', int $rotation=0) : void |
|
508 | + public function AddPage(string $orientation = '', $size = '', int $rotation = 0) : void |
|
509 | 509 | { |
510 | 510 | // Start a new page |
511 | 511 | if ($this->state == 3) { |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | * @param int $g Green component (between 0 and 255). |
616 | 616 | * @param int $b Blue component (between 0 and 255). |
617 | 617 | */ |
618 | - public function SetDrawColor(int $r, ?int $g=null, ?int $b=null) : void |
|
618 | + public function SetDrawColor(int $r, ?int $g = null, ?int $b = null) : void |
|
619 | 619 | { |
620 | 620 | // Set color for all stroking operations |
621 | 621 | if (($r === 0 && $g === 0 && $b === 0) || $g === null) { |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | * @param int $g Green component (between 0 and 255). |
637 | 637 | * @param int $b Blue component (between 0 and 255). |
638 | 638 | */ |
639 | - public function SetFillColor(int $r, ?int $g=null, ?int $b=null) : void |
|
639 | + public function SetFillColor(int $r, ?int $g = null, ?int $b = null) : void |
|
640 | 640 | { |
641 | 641 | // Set color for all filling operations |
642 | 642 | if (($r === 0 && $g === 0 && $b === 0) || $g === null) { |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | * @param int $g Green component (between 0 and 255). |
659 | 659 | * @param int $b Blue component (between 0 and 255). |
660 | 660 | */ |
661 | - public function SetTextColor(int $r, ?int $g=null, ?int $b=null) : void |
|
661 | + public function SetTextColor(int $r, ?int $g = null, ?int $b = null) : void |
|
662 | 662 | { |
663 | 663 | // Set color for text |
664 | 664 | if (($r === 0 && $g === 0 && $b === 0) || $g === null) { |
@@ -678,13 +678,13 @@ discard block |
||
678 | 678 | public function GetStringWidth(string $s) : float |
679 | 679 | { |
680 | 680 | // Get width of a string in the current font |
681 | - $s = (string)$s; |
|
681 | + $s = (string) $s; |
|
682 | 682 | $cw = &$this->CurrentFont['cw']; |
683 | 683 | $w = 0; |
684 | 684 | $l = strlen($s); |
685 | - for($i=0;$i<$l;$i++) |
|
685 | + for ($i = 0; $i < $l; $i++) |
|
686 | 686 | $w += $cw[$s[$i]]; |
687 | - return $w*$this->FontSize/1000; |
|
687 | + return $w * $this->FontSize / 1000; |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | /** |
@@ -697,8 +697,8 @@ discard block |
||
697 | 697 | { |
698 | 698 | // Set line width |
699 | 699 | $this->LineWidth = $width; |
700 | - if($this->page>0) |
|
701 | - $this->out(sprintf('%.2F w',$width*$this->k)); |
|
700 | + if ($this->page > 0) |
|
701 | + $this->out(sprintf('%.2F w', $width * $this->k)); |
|
702 | 702 | } |
703 | 703 | |
704 | 704 | /** |
@@ -713,7 +713,7 @@ discard block |
||
713 | 713 | public function Line(float $x1, float $y1, float $x2, float $y2) : void |
714 | 714 | { |
715 | 715 | // Draw a line |
716 | - $this->out(sprintf('%.2F %.2F m %.2F %.2F l S',$x1*$this->k,($this->h-$y1)*$this->k,$x2*$this->k,($this->h-$y2)*$this->k)); |
|
716 | + $this->out(sprintf('%.2F %.2F m %.2F %.2F l S', $x1 * $this->k, ($this->h - $y1) * $this->k, $x2 * $this->k, ($this->h - $y2) * $this->k)); |
|
717 | 717 | } |
718 | 718 | |
719 | 719 | /** |
@@ -731,16 +731,16 @@ discard block |
||
731 | 731 | * <li> 'F': fill. </li> |
732 | 732 | * <li> 'DF' or 'FD': draw the shape and fill. </li></ul> |
733 | 733 | */ |
734 | - public function Rect(float $x, float $y, float $w, float $h, string $style='') : void |
|
734 | + public function Rect(float $x, float $y, float $w, float $h, string $style = '') : void |
|
735 | 735 | { |
736 | 736 | // Draw a rectangle |
737 | - if($style=='F') |
|
737 | + if ($style == 'F') |
|
738 | 738 | $op = 'f'; |
739 | - elseif($style=='FD' || $style=='DF') |
|
739 | + elseif ($style == 'FD' || $style == 'DF') |
|
740 | 740 | $op = 'B'; |
741 | 741 | else |
742 | 742 | $op = 'S'; |
743 | - $this->out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op)); |
|
743 | + $this->out(sprintf('%.2F %.2F %.2F %.2F re %s', $x * $this->k, ($this->h - $y) * $this->k, $w * $this->k, -$h * $this->k, $op)); |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | /** |
@@ -760,24 +760,24 @@ discard block |
||
760 | 760 | * @param string $file The font definition file. <br/> |
761 | 761 | * By default, the name is built from the family and style, in lower case with no space. |
762 | 762 | */ |
763 | - public function AddFont(string $family, string $style='', string $file='') : void |
|
763 | + public function AddFont(string $family, string $style = '', string $file = '') : void |
|
764 | 764 | { |
765 | 765 | // Add a TrueType, OpenType or Type1 font |
766 | 766 | $family = strtolower($family); |
767 | - if($file=='') |
|
768 | - $file = str_replace(' ','',$family).strtolower($style).'.php'; |
|
767 | + if ($file == '') |
|
768 | + $file = str_replace(' ', '', $family) . strtolower($style) . '.php'; |
|
769 | 769 | $style = strtoupper($style); |
770 | - if($style=='IB') |
|
770 | + if ($style == 'IB') |
|
771 | 771 | $style = 'BI'; |
772 | - $fontkey = $family.$style; |
|
773 | - if(isset($this->fonts[$fontkey])) |
|
772 | + $fontkey = $family . $style; |
|
773 | + if (isset($this->fonts[$fontkey])) |
|
774 | 774 | return; |
775 | 775 | $info = $this->loadFont($file); |
776 | - $info['i'] = count($this->fonts)+1; |
|
777 | - if(!empty($info['file'])) |
|
776 | + $info['i'] = count($this->fonts) + 1; |
|
777 | + if (!empty($info['file'])) |
|
778 | 778 | { |
779 | 779 | // Embedded font |
780 | - if($info['type']=='TrueType') |
|
780 | + if ($info['type'] == 'TrueType') |
|
781 | 781 | $this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']); |
782 | 782 | else |
783 | 783 | $this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']); |
@@ -820,54 +820,54 @@ discard block |
||
820 | 820 | * The default value is the current size. <br/> |
821 | 821 | * If no size has been specified since the beginning of the document, the value taken is 12. |
822 | 822 | */ |
823 | - public function SetFont(string $family, string $style='', float $size=0) : void |
|
823 | + public function SetFont(string $family, string $style = '', float $size = 0) : void |
|
824 | 824 | { |
825 | 825 | // Select a font; size given in points |
826 | - if($family=='') |
|
826 | + if ($family == '') |
|
827 | 827 | $family = $this->FontFamily; |
828 | 828 | else |
829 | 829 | $family = strtolower($family); |
830 | 830 | $style = strtoupper($style); |
831 | - if(strpos($style,'U')!==false) |
|
831 | + if (strpos($style, 'U') !== false) |
|
832 | 832 | { |
833 | 833 | $this->underline = true; |
834 | - $style = str_replace('U','',$style); |
|
834 | + $style = str_replace('U', '', $style); |
|
835 | 835 | } |
836 | 836 | else |
837 | 837 | $this->underline = false; |
838 | - if($style=='IB') |
|
838 | + if ($style == 'IB') |
|
839 | 839 | $style = 'BI'; |
840 | - if($size==0) |
|
840 | + if ($size == 0) |
|
841 | 841 | $size = $this->FontSizePt; |
842 | 842 | // Test if font is already selected |
843 | - if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) |
|
843 | + if ($this->FontFamily == $family && $this->FontStyle == $style && $this->FontSizePt == $size) |
|
844 | 844 | return; |
845 | 845 | // Test if font is already loaded |
846 | - $fontkey = $family.$style; |
|
847 | - if(!isset($this->fonts[$fontkey])) |
|
846 | + $fontkey = $family . $style; |
|
847 | + if (!isset($this->fonts[$fontkey])) |
|
848 | 848 | { |
849 | 849 | // Test if one of the core fonts |
850 | - if($family=='arial') |
|
850 | + if ($family == 'arial') |
|
851 | 851 | $family = 'helvetica'; |
852 | - if(in_array($family,$this->CoreFonts)) |
|
852 | + if (in_array($family, $this->CoreFonts)) |
|
853 | 853 | { |
854 | - if($family=='symbol' || $family=='zapfdingbats') |
|
854 | + if ($family == 'symbol' || $family == 'zapfdingbats') |
|
855 | 855 | $style = ''; |
856 | - $fontkey = $family.$style; |
|
857 | - if(!isset($this->fonts[$fontkey])) |
|
858 | - $this->addFont($family,$style); |
|
856 | + $fontkey = $family . $style; |
|
857 | + if (!isset($this->fonts[$fontkey])) |
|
858 | + $this->addFont($family, $style); |
|
859 | 859 | } |
860 | 860 | else |
861 | - $this->Error('Undefined font: '.$family.' '.$style); |
|
861 | + $this->Error('Undefined font: ' . $family . ' ' . $style); |
|
862 | 862 | } |
863 | 863 | // Select it |
864 | 864 | $this->FontFamily = $family; |
865 | 865 | $this->FontStyle = $style; |
866 | 866 | $this->FontSizePt = $size; |
867 | - $this->FontSize = $size/$this->k; |
|
867 | + $this->FontSize = $size / $this->k; |
|
868 | 868 | $this->CurrentFont = &$this->fonts[$fontkey]; |
869 | - if($this->page>0) |
|
870 | - $this->out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
869 | + if ($this->page > 0) |
|
870 | + $this->out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | /** |
@@ -877,12 +877,12 @@ discard block |
||
877 | 877 | public function SetFontSize(float $size) : void |
878 | 878 | { |
879 | 879 | // Set font size in points |
880 | - if($this->FontSizePt==$size) |
|
880 | + if ($this->FontSizePt == $size) |
|
881 | 881 | return; |
882 | 882 | $this->FontSizePt = $size; |
883 | - $this->FontSize = $size/$this->k; |
|
884 | - if($this->page>0) |
|
885 | - $this->out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
883 | + $this->FontSize = $size / $this->k; |
|
884 | + if ($this->page > 0) |
|
885 | + $this->out(sprintf('BT /F%d %.2F Tf ET', $this->CurrentFont['i'], $this->FontSizePt)); |
|
886 | 886 | } |
887 | 887 | |
888 | 888 | /** |
@@ -895,7 +895,7 @@ discard block |
||
895 | 895 | public function AddLink() : int |
896 | 896 | { |
897 | 897 | // Create a new internal link |
898 | - $n = count($this->links)+1; |
|
898 | + $n = count($this->links) + 1; |
|
899 | 899 | $this->links[$n] = array(0, 0); |
900 | 900 | return $n; |
901 | 901 | } |
@@ -906,12 +906,12 @@ discard block |
||
906 | 906 | * @param float $y Y-position of target position; -1 indicates the current position. The default value is 0 (top of page). |
907 | 907 | * @param int $page Number of target page; -1 indicates the current page. This is the default value. |
908 | 908 | */ |
909 | - public function SetLink(int $link, float $y=0, int $page=-1) : void |
|
909 | + public function SetLink(int $link, float $y = 0, int $page = -1) : void |
|
910 | 910 | { |
911 | 911 | // Set destination of internal link |
912 | - if($y==-1) |
|
912 | + if ($y == -1) |
|
913 | 913 | $y = $this->y; |
914 | - if($page==-1) |
|
914 | + if ($page == -1) |
|
915 | 915 | $page = $this->page; |
916 | 916 | $this->links[$link] = array($page, $y); |
917 | 917 | } |
@@ -930,7 +930,7 @@ discard block |
||
930 | 930 | public function Link(float $x, float $y, float $w, float $h, $link) : void |
931 | 931 | { |
932 | 932 | // Put a link on the page |
933 | - $this->PageLinks[$this->page][] = array($x*$this->k, $this->hPt-$y*$this->k, $w*$this->k, $h*$this->k, $link); |
|
933 | + $this->PageLinks[$this->page][] = array($x * $this->k, $this->hPt - $y * $this->k, $w * $this->k, $h * $this->k, $link); |
|
934 | 934 | } |
935 | 935 | |
936 | 936 | /** |
@@ -946,13 +946,13 @@ discard block |
||
946 | 946 | public function Text(float $x, float $y, string $txt) : void |
947 | 947 | { |
948 | 948 | // Output a string |
949 | - if(!isset($this->CurrentFont)) |
|
949 | + if (!isset($this->CurrentFont)) |
|
950 | 950 | $this->Error('No font has been set'); |
951 | - $s = sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->escape($txt)); |
|
952 | - if($this->underline && $txt!='') |
|
953 | - $s .= ' '.$this->doUnderline($x,$y,$txt); |
|
954 | - if($this->ColorFlag) |
|
955 | - $s = 'q '.$this->TextColor.' '.$s.' Q'; |
|
951 | + $s = sprintf('BT %.2F %.2F Td (%s) Tj ET', $x * $this->k, ($this->h - $y) * $this->k, $this->escape($txt)); |
|
952 | + if ($this->underline && $txt != '') |
|
953 | + $s .= ' ' . $this->doUnderline($x, $y, $txt); |
|
954 | + if ($this->ColorFlag) |
|
955 | + $s = 'q ' . $this->TextColor . ' ' . $s . ' Q'; |
|
956 | 956 | $this->out($s); |
957 | 957 | } |
958 | 958 | |
@@ -1010,80 +1010,80 @@ discard block |
||
1010 | 1010 | * Default value: false. <br/> |
1011 | 1011 | * @param string|int $link URL or identifier for internal link created by AddLink(). |
1012 | 1012 | */ |
1013 | - public function Cell(float $w, float $h=0, string $txt='', $border=0, float $ln=0, $align='', $fill=false, $link='') : void |
|
1013 | + public function Cell(float $w, float $h = 0, string $txt = '', $border = 0, float $ln = 0, $align = '', $fill = false, $link = '') : void |
|
1014 | 1014 | { |
1015 | 1015 | // Output a cell |
1016 | 1016 | $k = $this->k; |
1017 | - if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) |
|
1017 | + if ($this->y + $h > $this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) |
|
1018 | 1018 | { |
1019 | 1019 | // Automatic page break |
1020 | 1020 | $x = $this->x; |
1021 | 1021 | $ws = $this->ws; |
1022 | - if($ws>0) |
|
1022 | + if ($ws > 0) |
|
1023 | 1023 | { |
1024 | 1024 | $this->ws = 0; |
1025 | 1025 | $this->out('0 Tw'); |
1026 | 1026 | } |
1027 | - $this->addPage($this->CurOrientation,$this->CurPageSize,$this->CurRotation); |
|
1027 | + $this->addPage($this->CurOrientation, $this->CurPageSize, $this->CurRotation); |
|
1028 | 1028 | $this->x = $x; |
1029 | - if($ws>0) |
|
1029 | + if ($ws > 0) |
|
1030 | 1030 | { |
1031 | 1031 | $this->ws = $ws; |
1032 | - $this->out(sprintf('%.3F Tw',$ws*$k)); |
|
1032 | + $this->out(sprintf('%.3F Tw', $ws * $k)); |
|
1033 | 1033 | } |
1034 | 1034 | } |
1035 | - if($w==0) |
|
1036 | - $w = $this->w-$this->rMargin-$this->x; |
|
1035 | + if ($w == 0) |
|
1036 | + $w = $this->w - $this->rMargin - $this->x; |
|
1037 | 1037 | $s = ''; |
1038 | - if($fill || $border==1) |
|
1038 | + if ($fill || $border == 1) |
|
1039 | 1039 | { |
1040 | - if($fill) |
|
1041 | - $op = ($border==1) ? 'B' : 'f'; |
|
1040 | + if ($fill) |
|
1041 | + $op = ($border == 1) ? 'B' : 'f'; |
|
1042 | 1042 | else |
1043 | 1043 | $op = 'S'; |
1044 | - $s = sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op); |
|
1044 | + $s = sprintf('%.2F %.2F %.2F %.2F re %s ', $this->x * $k, ($this->h - $this->y) * $k, $w * $k, -$h * $k, $op); |
|
1045 | 1045 | } |
1046 | - if(is_string($border)) |
|
1046 | + if (is_string($border)) |
|
1047 | 1047 | { |
1048 | 1048 | $x = $this->x; |
1049 | 1049 | $y = $this->y; |
1050 | - if(strpos($border,'L')!==false) |
|
1051 | - $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); |
|
1052 | - if(strpos($border,'T')!==false) |
|
1053 | - $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); |
|
1054 | - if(strpos($border,'R')!==false) |
|
1055 | - $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
1056 | - if(strpos($border,'B')!==false) |
|
1057 | - $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
1058 | - } |
|
1059 | - if($txt!=='') |
|
1050 | + if (strpos($border, 'L') !== false) |
|
1051 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, $x * $k, ($this->h - ($y + $h)) * $k); |
|
1052 | + if (strpos($border, 'T') !== false) |
|
1053 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - $y) * $k); |
|
1054 | + if (strpos($border, 'R') !== false) |
|
1055 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', ($x + $w) * $k, ($this->h - $y) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k); |
|
1056 | + if (strpos($border, 'B') !== false) |
|
1057 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ', $x * $k, ($this->h - ($y + $h)) * $k, ($x + $w) * $k, ($this->h - ($y + $h)) * $k); |
|
1058 | + } |
|
1059 | + if ($txt !== '') |
|
1060 | 1060 | { |
1061 | - if(!isset($this->CurrentFont)) |
|
1061 | + if (!isset($this->CurrentFont)) |
|
1062 | 1062 | $this->Error('No font has been set'); |
1063 | - if($align=='R') |
|
1064 | - $dx = $w-$this->cMargin-$this->getStringWidth($txt); |
|
1065 | - elseif($align=='C') |
|
1066 | - $dx = ($w-$this->getStringWidth($txt))/2; |
|
1063 | + if ($align == 'R') |
|
1064 | + $dx = $w - $this->cMargin - $this->getStringWidth($txt); |
|
1065 | + elseif ($align == 'C') |
|
1066 | + $dx = ($w - $this->getStringWidth($txt)) / 2; |
|
1067 | 1067 | else |
1068 | 1068 | $dx = $this->cMargin; |
1069 | - if($this->ColorFlag) |
|
1070 | - $s .= 'q '.$this->TextColor.' '; |
|
1071 | - $s .= sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$this->escape($txt)); |
|
1072 | - if($this->underline) |
|
1073 | - $s .= ' '.$this->doUnderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); |
|
1074 | - if($this->ColorFlag) |
|
1069 | + if ($this->ColorFlag) |
|
1070 | + $s .= 'q ' . $this->TextColor . ' '; |
|
1071 | + $s .= sprintf('BT %.2F %.2F Td (%s) Tj ET', ($this->x + $dx) * $k, ($this->h - ($this->y + .5 * $h + .3 * $this->FontSize)) * $k, $this->escape($txt)); |
|
1072 | + if ($this->underline) |
|
1073 | + $s .= ' ' . $this->doUnderline($this->x + $dx, $this->y + .5 * $h + .3 * $this->FontSize, $txt); |
|
1074 | + if ($this->ColorFlag) |
|
1075 | 1075 | $s .= ' Q'; |
1076 | - if($link) |
|
1077 | - $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->getStringWidth($txt),$this->FontSize,$link); |
|
1076 | + if ($link) |
|
1077 | + $this->Link($this->x + $dx, $this->y + .5 * $h - .5 * $this->FontSize, $this->getStringWidth($txt), $this->FontSize, $link); |
|
1078 | 1078 | } |
1079 | - if($s) |
|
1079 | + if ($s) |
|
1080 | 1080 | $this->out($s); |
1081 | 1081 | $this->lasth = $h; |
1082 | - if($ln>0) |
|
1082 | + if ($ln > 0) |
|
1083 | 1083 | { |
1084 | 1084 | // Go to next line |
1085 | 1085 | $this->y += $h; |
1086 | - if($ln==1) |
|
1086 | + if ($ln == 1) |
|
1087 | 1087 | $this->x = $this->lMargin; |
1088 | 1088 | } |
1089 | 1089 | else |
@@ -1118,24 +1118,24 @@ discard block |
||
1118 | 1118 | * If set to true, current FillColor is used for the background. <br/> |
1119 | 1119 | * Default value: false. |
1120 | 1120 | */ |
1121 | - public function MultiCell(float $w, float $h, string $txt, $border=0, string $align='J', bool $fill=false) : void |
|
1121 | + public function MultiCell(float $w, float $h, string $txt, $border = 0, string $align = 'J', bool $fill = false) : void |
|
1122 | 1122 | { |
1123 | 1123 | // Output text with automatic or explicit line breaks |
1124 | - if(!isset($this->CurrentFont)) |
|
1124 | + if (!isset($this->CurrentFont)) |
|
1125 | 1125 | $this->Error('No font has been set'); |
1126 | 1126 | $cw = &$this->CurrentFont['cw']; |
1127 | - if($w==0) |
|
1128 | - $w = $this->w-$this->rMargin-$this->x; |
|
1129 | - $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; |
|
1130 | - $s = str_replace("\r",'',$txt); |
|
1127 | + if ($w == 0) |
|
1128 | + $w = $this->w - $this->rMargin - $this->x; |
|
1129 | + $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; |
|
1130 | + $s = str_replace("\r", '', $txt); |
|
1131 | 1131 | $nb = strlen($s); |
1132 | - if($nb>0 && $s[$nb-1]=="\n") |
|
1132 | + if ($nb > 0 && $s[$nb - 1] == "\n") |
|
1133 | 1133 | $nb--; |
1134 | 1134 | $b = 0; |
1135 | 1135 | $b2 = ''; |
1136 | - if($border) |
|
1136 | + if ($border) |
|
1137 | 1137 | { |
1138 | - if($border==1) |
|
1138 | + if ($border == 1) |
|
1139 | 1139 | { |
1140 | 1140 | $border = 'LTRB'; |
1141 | 1141 | $b = 'LRT'; |
@@ -1144,11 +1144,11 @@ discard block |
||
1144 | 1144 | else |
1145 | 1145 | { |
1146 | 1146 | $b2 = ''; |
1147 | - if(strpos($border,'L')!==false) |
|
1147 | + if (strpos($border, 'L') !== false) |
|
1148 | 1148 | $b2 .= 'L'; |
1149 | - if(strpos($border,'R')!==false) |
|
1149 | + if (strpos($border, 'R') !== false) |
|
1150 | 1150 | $b2 .= 'R'; |
1151 | - $b = (strpos($border,'T')!==false) ? $b2.'T' : $b2; |
|
1151 | + $b = (strpos($border, 'T') !== false) ? $b2 . 'T' : $b2; |
|
1152 | 1152 | } |
1153 | 1153 | } |
1154 | 1154 | $sep = -1; |
@@ -1158,80 +1158,80 @@ discard block |
||
1158 | 1158 | $ns = 0; |
1159 | 1159 | $nl = 1; |
1160 | 1160 | $ls = 0; |
1161 | - while($i<$nb) |
|
1161 | + while ($i < $nb) |
|
1162 | 1162 | { |
1163 | 1163 | // Get next character |
1164 | 1164 | $c = $s[$i]; |
1165 | - if($c=="\n") |
|
1165 | + if ($c == "\n") |
|
1166 | 1166 | { |
1167 | 1167 | // Explicit line break |
1168 | - if($this->ws>0) |
|
1168 | + if ($this->ws > 0) |
|
1169 | 1169 | { |
1170 | 1170 | $this->ws = 0; |
1171 | 1171 | $this->out('0 Tw'); |
1172 | 1172 | } |
1173 | - $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
|
1173 | + $this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill); |
|
1174 | 1174 | $i++; |
1175 | 1175 | $sep = -1; |
1176 | 1176 | $j = $i; |
1177 | 1177 | $l = 0; |
1178 | 1178 | $ns = 0; |
1179 | 1179 | $nl++; |
1180 | - if($border && $nl==2) |
|
1180 | + if ($border && $nl == 2) |
|
1181 | 1181 | $b = $b2; |
1182 | 1182 | continue; |
1183 | 1183 | } |
1184 | - if($c==' ') |
|
1184 | + if ($c == ' ') |
|
1185 | 1185 | { |
1186 | 1186 | $sep = $i; |
1187 | 1187 | $ls = $l; |
1188 | 1188 | $ns++; |
1189 | 1189 | } |
1190 | 1190 | $l += $cw[$c]; |
1191 | - if($l>$wmax) |
|
1191 | + if ($l > $wmax) |
|
1192 | 1192 | { |
1193 | 1193 | // Automatic line break |
1194 | - if($sep==-1) |
|
1194 | + if ($sep == -1) |
|
1195 | 1195 | { |
1196 | - if($i==$j) |
|
1196 | + if ($i == $j) |
|
1197 | 1197 | $i++; |
1198 | - if($this->ws>0) |
|
1198 | + if ($this->ws > 0) |
|
1199 | 1199 | { |
1200 | 1200 | $this->ws = 0; |
1201 | 1201 | $this->out('0 Tw'); |
1202 | 1202 | } |
1203 | - $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
|
1203 | + $this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill); |
|
1204 | 1204 | } |
1205 | 1205 | else |
1206 | 1206 | { |
1207 | - if($align=='J') |
|
1207 | + if ($align == 'J') |
|
1208 | 1208 | { |
1209 | - $this->ws = ($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0; |
|
1210 | - $this->out(sprintf('%.3F Tw',$this->ws*$this->k)); |
|
1209 | + $this->ws = ($ns > 1) ? ($wmax - $ls) / 1000 * $this->FontSize / ($ns - 1) : 0; |
|
1210 | + $this->out(sprintf('%.3F Tw', $this->ws * $this->k)); |
|
1211 | 1211 | } |
1212 | - $this->Cell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill); |
|
1213 | - $i = $sep+1; |
|
1212 | + $this->Cell($w, $h, substr($s, $j, $sep - $j), $b, 2, $align, $fill); |
|
1213 | + $i = $sep + 1; |
|
1214 | 1214 | } |
1215 | 1215 | $sep = -1; |
1216 | 1216 | $j = $i; |
1217 | 1217 | $l = 0; |
1218 | 1218 | $ns = 0; |
1219 | 1219 | $nl++; |
1220 | - if($border && $nl==2) |
|
1220 | + if ($border && $nl == 2) |
|
1221 | 1221 | $b = $b2; |
1222 | 1222 | } |
1223 | 1223 | else |
1224 | 1224 | $i++; |
1225 | 1225 | } |
1226 | 1226 | // Last chunk |
1227 | - if($this->ws>0) |
|
1227 | + if ($this->ws > 0) |
|
1228 | 1228 | { |
1229 | 1229 | $this->ws = 0; |
1230 | 1230 | $this->out('0 Tw'); |
1231 | 1231 | } |
1232 | - if($border && strpos($border,'B')!==false) |
|
1232 | + if ($border && strpos($border, 'B') !== false) |
|
1233 | 1233 | $b .= 'B'; |
1234 | - $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
|
1234 | + $this->Cell($w, $h, substr($s, $j, $i - $j), $b, 2, $align, $fill); |
|
1235 | 1235 | $this->x = $this->lMargin; |
1236 | 1236 | } |
1237 | 1237 | |
@@ -1245,78 +1245,78 @@ discard block |
||
1245 | 1245 | * @param string $txt String to print. |
1246 | 1246 | * @param string|int $link URL or identifier for internal link created by AddLink(). |
1247 | 1247 | */ |
1248 | - public function Write(float $h, string $txt, $link='') : void |
|
1248 | + public function Write(float $h, string $txt, $link = '') : void |
|
1249 | 1249 | { |
1250 | 1250 | // Output text in flowing mode |
1251 | - if(!isset($this->CurrentFont)) |
|
1251 | + if (!isset($this->CurrentFont)) |
|
1252 | 1252 | $this->Error('No font has been set'); |
1253 | 1253 | $cw = &$this->CurrentFont['cw']; |
1254 | - $w = $this->w-$this->rMargin-$this->x; |
|
1255 | - $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; |
|
1256 | - $s = str_replace("\r",'',$txt); |
|
1254 | + $w = $this->w - $this->rMargin - $this->x; |
|
1255 | + $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; |
|
1256 | + $s = str_replace("\r", '', $txt); |
|
1257 | 1257 | $nb = strlen($s); |
1258 | 1258 | $sep = -1; |
1259 | 1259 | $i = 0; |
1260 | 1260 | $j = 0; |
1261 | 1261 | $l = 0; |
1262 | 1262 | $nl = 1; |
1263 | - while($i<$nb) |
|
1263 | + while ($i < $nb) |
|
1264 | 1264 | { |
1265 | 1265 | // Get next character |
1266 | 1266 | $c = $s[$i]; |
1267 | - if($c=="\n") |
|
1267 | + if ($c == "\n") |
|
1268 | 1268 | { |
1269 | 1269 | // Explicit line break |
1270 | - $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',false,$link); |
|
1270 | + $this->Cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', false, $link); |
|
1271 | 1271 | $i++; |
1272 | 1272 | $sep = -1; |
1273 | 1273 | $j = $i; |
1274 | 1274 | $l = 0; |
1275 | - if($nl==1) |
|
1275 | + if ($nl == 1) |
|
1276 | 1276 | { |
1277 | 1277 | $this->x = $this->lMargin; |
1278 | - $w = $this->w-$this->rMargin-$this->x; |
|
1279 | - $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; |
|
1278 | + $w = $this->w - $this->rMargin - $this->x; |
|
1279 | + $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; |
|
1280 | 1280 | } |
1281 | 1281 | $nl++; |
1282 | 1282 | continue; |
1283 | 1283 | } |
1284 | - if($c==' ') |
|
1284 | + if ($c == ' ') |
|
1285 | 1285 | $sep = $i; |
1286 | 1286 | $l += $cw[$c]; |
1287 | - if($l>$wmax) |
|
1287 | + if ($l > $wmax) |
|
1288 | 1288 | { |
1289 | 1289 | // Automatic line break |
1290 | - if($sep==-1) |
|
1290 | + if ($sep == -1) |
|
1291 | 1291 | { |
1292 | - if($this->x>$this->lMargin) |
|
1292 | + if ($this->x > $this->lMargin) |
|
1293 | 1293 | { |
1294 | 1294 | // Move to next line |
1295 | 1295 | $this->x = $this->lMargin; |
1296 | 1296 | $this->y += $h; |
1297 | - $w = $this->w-$this->rMargin-$this->x; |
|
1298 | - $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; |
|
1297 | + $w = $this->w - $this->rMargin - $this->x; |
|
1298 | + $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; |
|
1299 | 1299 | $i++; |
1300 | 1300 | $nl++; |
1301 | 1301 | continue; |
1302 | 1302 | } |
1303 | - if($i==$j) |
|
1303 | + if ($i == $j) |
|
1304 | 1304 | $i++; |
1305 | - $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',false,$link); |
|
1305 | + $this->Cell($w, $h, substr($s, $j, $i - $j), 0, 2, '', false, $link); |
|
1306 | 1306 | } |
1307 | 1307 | else |
1308 | 1308 | { |
1309 | - $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',false,$link); |
|
1310 | - $i = $sep+1; |
|
1309 | + $this->Cell($w, $h, substr($s, $j, $sep - $j), 0, 2, '', false, $link); |
|
1310 | + $i = $sep + 1; |
|
1311 | 1311 | } |
1312 | 1312 | $sep = -1; |
1313 | 1313 | $j = $i; |
1314 | 1314 | $l = 0; |
1315 | - if($nl==1) |
|
1315 | + if ($nl == 1) |
|
1316 | 1316 | { |
1317 | 1317 | $this->x = $this->lMargin; |
1318 | - $w = $this->w-$this->rMargin-$this->x; |
|
1319 | - $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; |
|
1318 | + $w = $this->w - $this->rMargin - $this->x; |
|
1319 | + $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; |
|
1320 | 1320 | } |
1321 | 1321 | $nl++; |
1322 | 1322 | } |
@@ -1324,8 +1324,8 @@ discard block |
||
1324 | 1324 | $i++; |
1325 | 1325 | } |
1326 | 1326 | // Last chunk |
1327 | - if($i!=$j) |
|
1328 | - $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',false,$link); |
|
1327 | + if ($i != $j) |
|
1328 | + $this->Cell($l / 1000 * $this->FontSize, $h, substr($s, $j), 0, 0, '', false, $link); |
|
1329 | 1329 | } |
1330 | 1330 | |
1331 | 1331 | /** |
@@ -1335,11 +1335,11 @@ discard block |
||
1335 | 1335 | * @param float $h The height of the break. <br/> |
1336 | 1336 | * By default, the value equals the height of the last printed cell. |
1337 | 1337 | */ |
1338 | - public function Ln(float $h=null) : void |
|
1338 | + public function Ln(float $h = null) : void |
|
1339 | 1339 | { |
1340 | 1340 | // Line feed; default value is the last cell height |
1341 | 1341 | $this->x = $this->lMargin; |
1342 | - if($h===null) |
|
1342 | + if ($h === null) |
|
1343 | 1343 | $this->y += $this->lasth; |
1344 | 1344 | else |
1345 | 1345 | $this->y += $h; |
@@ -1391,7 +1391,7 @@ discard block |
||
1391 | 1391 | * If not specified, the type is inferred from the file extension. <br/> |
1392 | 1392 | * @param string|int $link URL or identifier for internal link created by AddLink(). |
1393 | 1393 | */ |
1394 | - public function Image(string $file, ?float $x=null, ?float $y=null, float $w=0, float $h=0, string $type='', $link='') : void |
|
1394 | + public function Image(string $file, ?float $x = null, ?float $y = null, float $w = 0, float $h = 0, string $type = '', $link = '') : void |
|
1395 | 1395 | { |
1396 | 1396 | // Put an image on the page |
1397 | 1397 | if ($file == '') { |
@@ -1409,7 +1409,7 @@ discard block |
||
1409 | 1409 | $type = substr($file, $pos + 1); |
1410 | 1410 | } |
1411 | 1411 | $type = strtolower($type); |
1412 | - if($type=='jpeg') { |
|
1412 | + if ($type == 'jpeg') { |
|
1413 | 1413 | $type = 'jpg'; |
1414 | 1414 | } |
1415 | 1415 | $mtd = 'parse' . ucfirst($type); |
@@ -1459,7 +1459,7 @@ discard block |
||
1459 | 1459 | } |
1460 | 1460 | $this->out(sprintf('q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q', $w * $this->k, $h * $this->k, $x * $this->k, ($this->h - ($y + $h)) * $this->k, $info['i'])); |
1461 | 1461 | if ($link) { |
1462 | - $this->Link($x,$y,$w,$h,$link); |
|
1462 | + $this->Link($x, $y, $w, $h, $link); |
|
1463 | 1463 | } |
1464 | 1464 | } |
1465 | 1465 | |
@@ -1471,7 +1471,7 @@ discard block |
||
1471 | 1471 | * @param int $level |
1472 | 1472 | * @param int $y |
1473 | 1473 | */ |
1474 | - public function Bookmark(string $txt, bool $isUTF8=false, int $level=0, int $y=0) : void |
|
1474 | + public function Bookmark(string $txt, bool $isUTF8 = false, int $level = 0, int $y = 0) : void |
|
1475 | 1475 | { |
1476 | 1476 | if (!$isUTF8) { |
1477 | 1477 | $txt = utf8_encode($txt); |
@@ -1520,10 +1520,10 @@ discard block |
||
1520 | 1520 | public function SetX(float $x) : void |
1521 | 1521 | { |
1522 | 1522 | // Set x position |
1523 | - if($x>=0) |
|
1523 | + if ($x >= 0) |
|
1524 | 1524 | $this->x = $x; |
1525 | 1525 | else |
1526 | - $this->x = $this->w+$x; |
|
1526 | + $this->x = $this->w + $x; |
|
1527 | 1527 | } |
1528 | 1528 | |
1529 | 1529 | /** |
@@ -1542,14 +1542,14 @@ discard block |
||
1542 | 1542 | * @param float $y |
1543 | 1543 | * @param bool $resetX |
1544 | 1544 | */ |
1545 | - public function SetY(float $y, bool $resetX=true) : void |
|
1545 | + public function SetY(float $y, bool $resetX = true) : void |
|
1546 | 1546 | { |
1547 | 1547 | // Set y position and optionally reset x |
1548 | - if($y>=0) |
|
1548 | + if ($y >= 0) |
|
1549 | 1549 | $this->y = $y; |
1550 | 1550 | else |
1551 | - $this->y = $this->h+$y; |
|
1552 | - if($resetX) |
|
1551 | + $this->y = $this->h + $y; |
|
1552 | + if ($resetX) |
|
1553 | 1553 | $this->x = $this->lMargin; |
1554 | 1554 | } |
1555 | 1555 | |
@@ -1563,7 +1563,7 @@ discard block |
||
1563 | 1563 | { |
1564 | 1564 | // Set x and y positions |
1565 | 1565 | $this->setX($x); |
1566 | - $this->setY($y,false); |
|
1566 | + $this->setY($y, false); |
|
1567 | 1567 | } |
1568 | 1568 | |
1569 | 1569 | /** |
@@ -1584,31 +1584,31 @@ discard block |
||
1584 | 1584 | * The default value is false. <br/> |
1585 | 1585 | * @return string |
1586 | 1586 | */ |
1587 | - public function Output(string $dest='', string $name='', bool $isUTF8=false) : string |
|
1587 | + public function Output(string $dest = '', string $name = '', bool $isUTF8 = false) : string |
|
1588 | 1588 | { |
1589 | 1589 | // Output PDF to some destination |
1590 | 1590 | $this->Close(); |
1591 | - if(strlen($name)==1 && strlen($dest)!=1) |
|
1591 | + if (strlen($name) == 1 && strlen($dest) != 1) |
|
1592 | 1592 | { |
1593 | 1593 | // Fix parameter order |
1594 | 1594 | $tmp = $dest; |
1595 | 1595 | $dest = $name; |
1596 | 1596 | $name = $tmp; |
1597 | 1597 | } |
1598 | - if($dest=='') |
|
1598 | + if ($dest == '') |
|
1599 | 1599 | $dest = 'I'; |
1600 | - if($name=='') |
|
1600 | + if ($name == '') |
|
1601 | 1601 | $name = 'doc.pdf'; |
1602 | - switch(strtoupper($dest)) |
|
1602 | + switch (strtoupper($dest)) |
|
1603 | 1603 | { |
1604 | 1604 | case 'I': |
1605 | 1605 | // Send to standard output |
1606 | 1606 | $this->checkOutput(); |
1607 | - if(PHP_SAPI!='cli') |
|
1607 | + if (PHP_SAPI != 'cli') |
|
1608 | 1608 | { |
1609 | 1609 | // We send to a browser |
1610 | 1610 | header('Content-Type: application/pdf; charset=UTF-8'); |
1611 | - header('Content-Disposition: inline; '.$this->httpEncode('filename',$name,$isUTF8)); |
|
1611 | + header('Content-Disposition: inline; ' . $this->httpEncode('filename', $name, $isUTF8)); |
|
1612 | 1612 | header('Cache-Control: private, max-age=0, must-revalidate'); |
1613 | 1613 | header('Pragma: public'); |
1614 | 1614 | } |
@@ -1618,21 +1618,21 @@ discard block |
||
1618 | 1618 | // Download file |
1619 | 1619 | $this->checkOutput(); |
1620 | 1620 | header('Content-Type: application/x-download'); |
1621 | - header('Content-Disposition: attachment; '.$this->httpEncode('filename',$name,$isUTF8)); |
|
1621 | + header('Content-Disposition: attachment; ' . $this->httpEncode('filename', $name, $isUTF8)); |
|
1622 | 1622 | header('Cache-Control: private, max-age=0, must-revalidate'); |
1623 | 1623 | header('Pragma: public'); |
1624 | 1624 | echo $this->buffer; |
1625 | 1625 | break; |
1626 | 1626 | case 'F': |
1627 | 1627 | // Save to local file |
1628 | - if(!file_put_contents($name,$this->buffer)) |
|
1629 | - $this->Error('Unable to create output file: '.$name); |
|
1628 | + if (!file_put_contents($name, $this->buffer)) |
|
1629 | + $this->Error('Unable to create output file: ' . $name); |
|
1630 | 1630 | break; |
1631 | 1631 | case 'S': |
1632 | 1632 | // Return as a string |
1633 | 1633 | return $this->buffer; |
1634 | 1634 | default: |
1635 | - $this->Error('Incorrect output destination: '.$dest); |
|
1635 | + $this->Error('Incorrect output destination: ' . $dest); |
|
1636 | 1636 | } |
1637 | 1637 | return ''; |
1638 | 1638 | } |
@@ -1761,7 +1761,7 @@ discard block |
||
1761 | 1761 | $this->CurOrientation = $orientation; |
1762 | 1762 | $this->CurPageSize = $size; |
1763 | 1763 | } |
1764 | - if($orientation != $this->DefOrientation || $size[0] != $this->DefPageSize[0] || $size[1] != $this->DefPageSize[1]) { |
|
1764 | + if ($orientation != $this->DefOrientation || $size[0] != $this->DefPageSize[0] || $size[1] != $this->DefPageSize[1]) { |
|
1765 | 1765 | $this->PageInfo[$this->page]['size'] = array($this->wPt, $this->hPt); |
1766 | 1766 | } |
1767 | 1767 | if ($rotation != 0) { |
@@ -1896,7 +1896,7 @@ discard block |
||
1896 | 1896 | strpos($s, ')') !== false || |
1897 | 1897 | strpos($s, '\\') !== false || |
1898 | 1898 | strpos($s, "\r") !== false) { |
1899 | - $s = str_replace(array('\\','(',')',"\r"), array('\\\\','\\(','\\)','\\r'), $s); |
|
1899 | + $s = str_replace(array('\\', '(', ')', "\r"), array('\\\\', '\\(', '\\)', '\\r'), $s); |
|
1900 | 1900 | } |
1901 | 1901 | return $s; |
1902 | 1902 | } |
@@ -1927,7 +1927,7 @@ discard block |
||
1927 | 1927 | // Underline text |
1928 | 1928 | $up = $this->CurrentFont['up']; |
1929 | 1929 | $ut = $this->CurrentFont['ut']; |
1930 | - $w = $this->getStringWidth($txt) + $this->ws * substr_count($txt,' '); |
|
1930 | + $w = $this->getStringWidth($txt) + $this->ws * substr_count($txt, ' '); |
|
1931 | 1931 | return sprintf('%.2F %.2F %.2F %.2F re f', $x * $this->k, ($this->h - ($y - $up / 1000 * $this->FontSize)) * $this->k, $w * $this->k, -$ut / 1000 * $this->FontSizePt); |
1932 | 1932 | } |
1933 | 1933 | |
@@ -2056,7 +2056,7 @@ discard block |
||
2056 | 2056 | $trns = array($pos); |
2057 | 2057 | } |
2058 | 2058 | } |
2059 | - $this->readStream($f,4); |
|
2059 | + $this->readStream($f, 4); |
|
2060 | 2060 | } elseif ($type == 'IDAT') { |
2061 | 2061 | // Read image data block |
2062 | 2062 | $data .= $this->readStream($f, $n); |
@@ -2094,7 +2094,7 @@ discard block |
||
2094 | 2094 | $alpha = ''; |
2095 | 2095 | if ($ct == 4) { |
2096 | 2096 | // Gray image |
2097 | - $len = 2*$w; |
|
2097 | + $len = 2 * $w; |
|
2098 | 2098 | for ($i = 0; $i < $h; $i++) { |
2099 | 2099 | $pos = (1 + $len) * $i; |
2100 | 2100 | $color .= $data[$pos]; |
@@ -2251,7 +2251,7 @@ discard block |
||
2251 | 2251 | * Begin a new object. |
2252 | 2252 | * @param int $n |
2253 | 2253 | */ |
2254 | - protected function newObject(?int $n=null) : void |
|
2254 | + protected function newObject(?int $n = null) : void |
|
2255 | 2255 | { |
2256 | 2256 | // Begin a new object |
2257 | 2257 | if ($n === null) { |
@@ -2336,7 +2336,7 @@ discard block |
||
2336 | 2336 | $this->put(sprintf('/MediaBox [0 0 %.2F %.2F]', $this->PageInfo[$n]['size'][0], $this->PageInfo[$n]['size'][1])); |
2337 | 2337 | } |
2338 | 2338 | if (isset($this->PageInfo[$n]['rotation'])) { |
2339 | - $this->put('/Rotate '.$this->PageInfo[$n]['rotation']); |
|
2339 | + $this->put('/Rotate ' . $this->PageInfo[$n]['rotation']); |
|
2340 | 2340 | } |
2341 | 2341 | $this->put('/Resources 2 0 R'); |
2342 | 2342 | if (isset($this->PageLinks[$n])) { |
@@ -2352,12 +2352,12 @@ discard block |
||
2352 | 2352 | if (isset($this->PageInfo[$l[0]]['size'])) { |
2353 | 2353 | $h = $this->PageInfo[$l[0]]['size'][1]; |
2354 | 2354 | } else { |
2355 | - $h = ($this->DefOrientation=='P') ? $this->DefPageSize[1] * $this->k : $this->DefPageSize[0] * $this->k; |
|
2355 | + $h = ($this->DefOrientation == 'P') ? $this->DefPageSize[1] * $this->k : $this->DefPageSize[0] * $this->k; |
|
2356 | 2356 | } |
2357 | 2357 | $annots .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>', $this->PageInfo[$l[0]]['n'], $h - $l[1] * $this->k); |
2358 | 2358 | } |
2359 | 2359 | } |
2360 | - $this->put($annots.']'); |
|
2360 | + $this->put($annots . ']'); |
|
2361 | 2361 | } |
2362 | 2362 | if ($this->WithAlpha) { |
2363 | 2363 | $this->put('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>'); |
@@ -2394,7 +2394,7 @@ discard block |
||
2394 | 2394 | } |
2395 | 2395 | $this->put('/Length1 ' . $info['length1']); |
2396 | 2396 | if (isset($info['length2'])) { |
2397 | - $this->put('/Length2 '.$info['length2'].' /Length3 0'); |
|
2397 | + $this->put('/Length2 ' . $info['length2'] . ' /Length3 0'); |
|
2398 | 2398 | } |
2399 | 2399 | $this->put('>>'); |
2400 | 2400 | $this->putStream($font); |
@@ -2431,7 +2431,7 @@ discard block |
||
2431 | 2431 | if ($font['subsetted']) { |
2432 | 2432 | $name = 'AAAAAA+' . $name; |
2433 | 2433 | } |
2434 | - if ($type=='Core') { |
|
2434 | + if ($type == 'Core') { |
|
2435 | 2435 | // Core font |
2436 | 2436 | $this->newObject(); |
2437 | 2437 | $this->put('<</Type /Font'); |
@@ -2549,7 +2549,7 @@ discard block |
||
2549 | 2549 | */ |
2550 | 2550 | protected function putImages() : void |
2551 | 2551 | { |
2552 | - foreach(array_keys($this->images) as $file) { |
|
2552 | + foreach (array_keys($this->images) as $file) { |
|
2553 | 2553 | $this->putImage($this->images[$file]); |
2554 | 2554 | unset($this->images[$file]['data']); |
2555 | 2555 | unset($this->images[$file]['smask']); |
@@ -2572,7 +2572,7 @@ discard block |
||
2572 | 2572 | $this->put('/ColorSpace [/Indexed /DeviceRGB ' . (strlen($info['pal']) / 3 - 1) . ' ' . ($this->n + 1) . ' 0 R]'); |
2573 | 2573 | } else { |
2574 | 2574 | $this->put('/ColorSpace /' . $info['cs']); |
2575 | - if($info['cs']=='DeviceCMYK') { |
|
2575 | + if ($info['cs'] == 'DeviceCMYK') { |
|
2576 | 2576 | $this->put('/Decode [1 0 1 0 1 0 1 0]'); |
2577 | 2577 | } |
2578 | 2578 | } |
@@ -2583,7 +2583,7 @@ discard block |
||
2583 | 2583 | if (isset($info['dp'])) { |
2584 | 2584 | $this->put('/DecodeParms <<' . $info['dp'] . '>>'); |
2585 | 2585 | } |
2586 | - if (isset($info['trns']) && is_array($info['trns'])) { |
|
2586 | + if (isset($info['trns']) && is_array($info['trns'])) { |
|
2587 | 2587 | $trns = ''; |
2588 | 2588 | $cnt = count($info['trns']); |
2589 | 2589 | for ($i = 0; $i < $cnt; $i++) { |
@@ -2592,7 +2592,7 @@ discard block |
||
2592 | 2592 | $this->put('/Mask [' . $trns . ']'); |
2593 | 2593 | } |
2594 | 2594 | if (isset($info['smask'])) { |
2595 | - $this->put('/SMask ' . ($this->n+1) . ' 0 R'); |
|
2595 | + $this->put('/SMask ' . ($this->n + 1) . ' 0 R'); |
|
2596 | 2596 | } |
2597 | 2597 | $this->put('/Length ' . strlen($info['data']) . '>>'); |
2598 | 2598 | $this->putStream($info['data']); |
@@ -2673,13 +2673,13 @@ discard block |
||
2673 | 2673 | protected function putBookmarks() : void |
2674 | 2674 | { |
2675 | 2675 | $nb = count($this->outlines); |
2676 | - if( $nb==0 ) { |
|
2676 | + if ($nb == 0) { |
|
2677 | 2677 | return; |
2678 | 2678 | } |
2679 | 2679 | $lru = array(); |
2680 | 2680 | $level = 0; |
2681 | 2681 | foreach ($this->outlines as $i => $o) { |
2682 | - if ($o['l']>0) { |
|
2682 | + if ($o['l'] > 0) { |
|
2683 | 2683 | $parent = $lru[$o['l'] - 1]; |
2684 | 2684 | // Set parent and last pointers |
2685 | 2685 | $this->outlines[$i]['parent'] = $parent; |
@@ -2701,7 +2701,7 @@ discard block |
||
2701 | 2701 | $level = $o['l']; |
2702 | 2702 | } |
2703 | 2703 | // Outline items |
2704 | - $n = $this->n+1; |
|
2704 | + $n = $this->n + 1; |
|
2705 | 2705 | foreach ($this->outlines as $i=>$o) { |
2706 | 2706 | $this->newObject(); |
2707 | 2707 | $this->put('<</Title ' . $this->textString($o['t'])); |
@@ -2726,7 +2726,7 @@ discard block |
||
2726 | 2726 | $this->newObject(); |
2727 | 2727 | $this->outlineRoot = $this->n; |
2728 | 2728 | $this->put('<</Type /Outlines /First ' . $n . ' 0 R'); |
2729 | - $this->put('/Last ' . ($n+$lru[0]) . ' 0 R>>'); |
|
2729 | + $this->put('/Last ' . ($n + $lru[0]) . ' 0 R>>'); |
|
2730 | 2730 | $this->put('endobj'); |
2731 | 2731 | } |
2732 | 2732 | |
@@ -2760,24 +2760,24 @@ discard block |
||
2760 | 2760 | $n = $this->PageInfo[1]['n']; |
2761 | 2761 | $this->put('/Type /Catalog'); |
2762 | 2762 | $this->put('/Pages 1 0 R'); |
2763 | - if($this->ZoomMode=='fullpage') { |
|
2763 | + if ($this->ZoomMode == 'fullpage') { |
|
2764 | 2764 | $this->put('/OpenAction [' . $n . ' 0 R /Fit]'); |
2765 | - } elseif ($this->ZoomMode=='fullwidth') { |
|
2765 | + } elseif ($this->ZoomMode == 'fullwidth') { |
|
2766 | 2766 | $this->put('/OpenAction [' . $n . ' 0 R /FitH null]'); |
2767 | - } elseif($this->ZoomMode=='real') { |
|
2767 | + } elseif ($this->ZoomMode == 'real') { |
|
2768 | 2768 | $this->put('/OpenAction [' . $n . ' 0 R /XYZ null null 1]'); |
2769 | - } elseif(!is_string($this->ZoomMode)) { |
|
2769 | + } elseif (!is_string($this->ZoomMode)) { |
|
2770 | 2770 | $this->put('/OpenAction [' . $n . ' 0 R /XYZ null null ' . sprintf('%.2F', $this->ZoomMode / 100) . ']'); |
2771 | 2771 | } |
2772 | - if($this->LayoutMode=='single') { |
|
2772 | + if ($this->LayoutMode == 'single') { |
|
2773 | 2773 | $this->put('/PageLayout /SinglePage'); |
2774 | - } elseif($this->LayoutMode=='continuous') { |
|
2774 | + } elseif ($this->LayoutMode == 'continuous') { |
|
2775 | 2775 | $this->put('/PageLayout /OneColumn'); |
2776 | - } elseif($this->LayoutMode=='two') { |
|
2776 | + } elseif ($this->LayoutMode == 'two') { |
|
2777 | 2777 | $this->put('/PageLayout /TwoColumnLeft'); |
2778 | 2778 | } |
2779 | 2779 | if (count($this->outlines) > 0) { |
2780 | - $this->put('/Outlines ' . $this->outlineRoot.' 0 R'); |
|
2780 | + $this->put('/Outlines ' . $this->outlineRoot . ' 0 R'); |
|
2781 | 2781 | $this->put('/PageMode /UseOutlines'); |
2782 | 2782 | } |
2783 | 2783 |
@@ -259,8 +259,9 @@ discard block |
||
259 | 259 | // Set left, top and right margins |
260 | 260 | $this->lMargin = $left; |
261 | 261 | $this->tMargin = $top; |
262 | - if($right===null) |
|
263 | - $right = $left; |
|
262 | + if($right===null) { |
|
263 | + $right = $left; |
|
264 | + } |
|
264 | 265 | $this->rMargin = $right; |
265 | 266 | } |
266 | 267 | |
@@ -274,8 +275,9 @@ discard block |
||
274 | 275 | { |
275 | 276 | // Set left margin |
276 | 277 | $this->lMargin = $margin; |
277 | - if($this->page>0 && $this->x<$margin) |
|
278 | - $this->x = $margin; |
|
278 | + if($this->page>0 && $this->x<$margin) { |
|
279 | + $this->x = $margin; |
|
280 | + } |
|
279 | 281 | } |
280 | 282 | |
281 | 283 | /** |
@@ -347,14 +349,16 @@ discard block |
||
347 | 349 | public function SetDisplayMode($zoom, string $layout='default') : void |
348 | 350 | { |
349 | 351 | // Set display mode in viewer |
350 | - if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) |
|
351 | - $this->ZoomMode = $zoom; |
|
352 | - else |
|
353 | - $this->Error('Incorrect zoom display mode: '.$zoom); |
|
354 | - if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') |
|
355 | - $this->LayoutMode = $layout; |
|
356 | - else |
|
357 | - $this->Error('Incorrect layout display mode: '.$layout); |
|
352 | + if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) { |
|
353 | + $this->ZoomMode = $zoom; |
|
354 | + } else { |
|
355 | + $this->Error('Incorrect zoom display mode: '.$zoom); |
|
356 | + } |
|
357 | + if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') { |
|
358 | + $this->LayoutMode = $layout; |
|
359 | + } else { |
|
360 | + $this->Error('Incorrect layout display mode: '.$layout); |
|
361 | + } |
|
358 | 362 | } |
359 | 363 | |
360 | 364 | /** |
@@ -369,10 +373,11 @@ discard block |
||
369 | 373 | public function SetCompression(bool $compress) : void |
370 | 374 | { |
371 | 375 | // Set page compression |
372 | - if(function_exists('gzcompress')) |
|
373 | - $this->compress = $compress; |
|
374 | - else |
|
375 | - $this->compress = false; |
|
376 | + if(function_exists('gzcompress')) { |
|
377 | + $this->compress = $compress; |
|
378 | + } else { |
|
379 | + $this->compress = false; |
|
380 | + } |
|
376 | 381 | } |
377 | 382 | |
378 | 383 | /** |
@@ -463,10 +468,12 @@ discard block |
||
463 | 468 | public function Close() : void |
464 | 469 | { |
465 | 470 | // Terminate document |
466 | - if($this->state==3) |
|
467 | - return; |
|
468 | - if($this->page==0) |
|
469 | - $this->addPage(); |
|
471 | + if($this->state==3) { |
|
472 | + return; |
|
473 | + } |
|
474 | + if($this->page==0) { |
|
475 | + $this->addPage(); |
|
476 | + } |
|
470 | 477 | // Page footer |
471 | 478 | $this->InFooter = true; |
472 | 479 | $this->Footer(); |
@@ -682,8 +689,9 @@ discard block |
||
682 | 689 | $cw = &$this->CurrentFont['cw']; |
683 | 690 | $w = 0; |
684 | 691 | $l = strlen($s); |
685 | - for($i=0;$i<$l;$i++) |
|
686 | - $w += $cw[$s[$i]]; |
|
692 | + for($i=0;$i<$l;$i++) { |
|
693 | + $w += $cw[$s[$i]]; |
|
694 | + } |
|
687 | 695 | return $w*$this->FontSize/1000; |
688 | 696 | } |
689 | 697 | |
@@ -697,8 +705,9 @@ discard block |
||
697 | 705 | { |
698 | 706 | // Set line width |
699 | 707 | $this->LineWidth = $width; |
700 | - if($this->page>0) |
|
701 | - $this->out(sprintf('%.2F w',$width*$this->k)); |
|
708 | + if($this->page>0) { |
|
709 | + $this->out(sprintf('%.2F w',$width*$this->k)); |
|
710 | + } |
|
702 | 711 | } |
703 | 712 | |
704 | 713 | /** |
@@ -734,12 +743,13 @@ discard block |
||
734 | 743 | public function Rect(float $x, float $y, float $w, float $h, string $style='') : void |
735 | 744 | { |
736 | 745 | // Draw a rectangle |
737 | - if($style=='F') |
|
738 | - $op = 'f'; |
|
739 | - elseif($style=='FD' || $style=='DF') |
|
740 | - $op = 'B'; |
|
741 | - else |
|
742 | - $op = 'S'; |
|
746 | + if($style=='F') { |
|
747 | + $op = 'f'; |
|
748 | + } elseif($style=='FD' || $style=='DF') { |
|
749 | + $op = 'B'; |
|
750 | + } else { |
|
751 | + $op = 'S'; |
|
752 | + } |
|
743 | 753 | $this->out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op)); |
744 | 754 | } |
745 | 755 | |
@@ -764,23 +774,27 @@ discard block |
||
764 | 774 | { |
765 | 775 | // Add a TrueType, OpenType or Type1 font |
766 | 776 | $family = strtolower($family); |
767 | - if($file=='') |
|
768 | - $file = str_replace(' ','',$family).strtolower($style).'.php'; |
|
777 | + if($file=='') { |
|
778 | + $file = str_replace(' ','',$family).strtolower($style).'.php'; |
|
779 | + } |
|
769 | 780 | $style = strtoupper($style); |
770 | - if($style=='IB') |
|
771 | - $style = 'BI'; |
|
781 | + if($style=='IB') { |
|
782 | + $style = 'BI'; |
|
783 | + } |
|
772 | 784 | $fontkey = $family.$style; |
773 | - if(isset($this->fonts[$fontkey])) |
|
774 | - return; |
|
785 | + if(isset($this->fonts[$fontkey])) { |
|
786 | + return; |
|
787 | + } |
|
775 | 788 | $info = $this->loadFont($file); |
776 | 789 | $info['i'] = count($this->fonts)+1; |
777 | 790 | if(!empty($info['file'])) |
778 | 791 | { |
779 | 792 | // Embedded font |
780 | - if($info['type']=='TrueType') |
|
781 | - $this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']); |
|
782 | - else |
|
783 | - $this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']); |
|
793 | + if($info['type']=='TrueType') { |
|
794 | + $this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']); |
|
795 | + } else { |
|
796 | + $this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']); |
|
797 | + } |
|
784 | 798 | } |
785 | 799 | $this->fonts[$fontkey] = $info; |
786 | 800 | } |
@@ -823,42 +837,49 @@ discard block |
||
823 | 837 | public function SetFont(string $family, string $style='', float $size=0) : void |
824 | 838 | { |
825 | 839 | // Select a font; size given in points |
826 | - if($family=='') |
|
827 | - $family = $this->FontFamily; |
|
828 | - else |
|
829 | - $family = strtolower($family); |
|
840 | + if($family=='') { |
|
841 | + $family = $this->FontFamily; |
|
842 | + } else { |
|
843 | + $family = strtolower($family); |
|
844 | + } |
|
830 | 845 | $style = strtoupper($style); |
831 | 846 | if(strpos($style,'U')!==false) |
832 | 847 | { |
833 | 848 | $this->underline = true; |
834 | 849 | $style = str_replace('U','',$style); |
850 | + } else { |
|
851 | + $this->underline = false; |
|
852 | + } |
|
853 | + if($style=='IB') { |
|
854 | + $style = 'BI'; |
|
855 | + } |
|
856 | + if($size==0) { |
|
857 | + $size = $this->FontSizePt; |
|
835 | 858 | } |
836 | - else |
|
837 | - $this->underline = false; |
|
838 | - if($style=='IB') |
|
839 | - $style = 'BI'; |
|
840 | - if($size==0) |
|
841 | - $size = $this->FontSizePt; |
|
842 | 859 | // Test if font is already selected |
843 | - if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) |
|
844 | - return; |
|
860 | + if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) { |
|
861 | + return; |
|
862 | + } |
|
845 | 863 | // Test if font is already loaded |
846 | 864 | $fontkey = $family.$style; |
847 | 865 | if(!isset($this->fonts[$fontkey])) |
848 | 866 | { |
849 | 867 | // Test if one of the core fonts |
850 | - if($family=='arial') |
|
851 | - $family = 'helvetica'; |
|
868 | + if($family=='arial') { |
|
869 | + $family = 'helvetica'; |
|
870 | + } |
|
852 | 871 | if(in_array($family,$this->CoreFonts)) |
853 | 872 | { |
854 | - if($family=='symbol' || $family=='zapfdingbats') |
|
855 | - $style = ''; |
|
873 | + if($family=='symbol' || $family=='zapfdingbats') { |
|
874 | + $style = ''; |
|
875 | + } |
|
856 | 876 | $fontkey = $family.$style; |
857 | - if(!isset($this->fonts[$fontkey])) |
|
858 | - $this->addFont($family,$style); |
|
877 | + if(!isset($this->fonts[$fontkey])) { |
|
878 | + $this->addFont($family,$style); |
|
879 | + } |
|
880 | + } else { |
|
881 | + $this->Error('Undefined font: '.$family.' '.$style); |
|
859 | 882 | } |
860 | - else |
|
861 | - $this->Error('Undefined font: '.$family.' '.$style); |
|
862 | 883 | } |
863 | 884 | // Select it |
864 | 885 | $this->FontFamily = $family; |
@@ -866,8 +887,9 @@ discard block |
||
866 | 887 | $this->FontSizePt = $size; |
867 | 888 | $this->FontSize = $size/$this->k; |
868 | 889 | $this->CurrentFont = &$this->fonts[$fontkey]; |
869 | - if($this->page>0) |
|
870 | - $this->out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
890 | + if($this->page>0) { |
|
891 | + $this->out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
892 | + } |
|
871 | 893 | } |
872 | 894 | |
873 | 895 | /** |
@@ -877,12 +899,14 @@ discard block |
||
877 | 899 | public function SetFontSize(float $size) : void |
878 | 900 | { |
879 | 901 | // Set font size in points |
880 | - if($this->FontSizePt==$size) |
|
881 | - return; |
|
902 | + if($this->FontSizePt==$size) { |
|
903 | + return; |
|
904 | + } |
|
882 | 905 | $this->FontSizePt = $size; |
883 | 906 | $this->FontSize = $size/$this->k; |
884 | - if($this->page>0) |
|
885 | - $this->out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
907 | + if($this->page>0) { |
|
908 | + $this->out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
909 | + } |
|
886 | 910 | } |
887 | 911 | |
888 | 912 | /** |
@@ -909,10 +933,12 @@ discard block |
||
909 | 933 | public function SetLink(int $link, float $y=0, int $page=-1) : void |
910 | 934 | { |
911 | 935 | // Set destination of internal link |
912 | - if($y==-1) |
|
913 | - $y = $this->y; |
|
914 | - if($page==-1) |
|
915 | - $page = $this->page; |
|
936 | + if($y==-1) { |
|
937 | + $y = $this->y; |
|
938 | + } |
|
939 | + if($page==-1) { |
|
940 | + $page = $this->page; |
|
941 | + } |
|
916 | 942 | $this->links[$link] = array($page, $y); |
917 | 943 | } |
918 | 944 | |
@@ -946,13 +972,16 @@ discard block |
||
946 | 972 | public function Text(float $x, float $y, string $txt) : void |
947 | 973 | { |
948 | 974 | // Output a string |
949 | - if(!isset($this->CurrentFont)) |
|
950 | - $this->Error('No font has been set'); |
|
975 | + if(!isset($this->CurrentFont)) { |
|
976 | + $this->Error('No font has been set'); |
|
977 | + } |
|
951 | 978 | $s = sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->escape($txt)); |
952 | - if($this->underline && $txt!='') |
|
953 | - $s .= ' '.$this->doUnderline($x,$y,$txt); |
|
954 | - if($this->ColorFlag) |
|
955 | - $s = 'q '.$this->TextColor.' '.$s.' Q'; |
|
979 | + if($this->underline && $txt!='') { |
|
980 | + $s .= ' '.$this->doUnderline($x,$y,$txt); |
|
981 | + } |
|
982 | + if($this->ColorFlag) { |
|
983 | + $s = 'q '.$this->TextColor.' '.$s.' Q'; |
|
984 | + } |
|
956 | 985 | $this->out($s); |
957 | 986 | } |
958 | 987 | |
@@ -1032,62 +1061,76 @@ discard block |
||
1032 | 1061 | $this->out(sprintf('%.3F Tw',$ws*$k)); |
1033 | 1062 | } |
1034 | 1063 | } |
1035 | - if($w==0) |
|
1036 | - $w = $this->w-$this->rMargin-$this->x; |
|
1064 | + if($w==0) { |
|
1065 | + $w = $this->w-$this->rMargin-$this->x; |
|
1066 | + } |
|
1037 | 1067 | $s = ''; |
1038 | 1068 | if($fill || $border==1) |
1039 | 1069 | { |
1040 | - if($fill) |
|
1041 | - $op = ($border==1) ? 'B' : 'f'; |
|
1042 | - else |
|
1043 | - $op = 'S'; |
|
1070 | + if($fill) { |
|
1071 | + $op = ($border==1) ? 'B' : 'f'; |
|
1072 | + } else { |
|
1073 | + $op = 'S'; |
|
1074 | + } |
|
1044 | 1075 | $s = sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op); |
1045 | 1076 | } |
1046 | 1077 | if(is_string($border)) |
1047 | 1078 | { |
1048 | 1079 | $x = $this->x; |
1049 | 1080 | $y = $this->y; |
1050 | - if(strpos($border,'L')!==false) |
|
1051 | - $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); |
|
1052 | - if(strpos($border,'T')!==false) |
|
1053 | - $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); |
|
1054 | - if(strpos($border,'R')!==false) |
|
1055 | - $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
1056 | - if(strpos($border,'B')!==false) |
|
1057 | - $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
1081 | + if(strpos($border,'L')!==false) { |
|
1082 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); |
|
1083 | + } |
|
1084 | + if(strpos($border,'T')!==false) { |
|
1085 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); |
|
1086 | + } |
|
1087 | + if(strpos($border,'R')!==false) { |
|
1088 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
1089 | + } |
|
1090 | + if(strpos($border,'B')!==false) { |
|
1091 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
1092 | + } |
|
1058 | 1093 | } |
1059 | 1094 | if($txt!=='') |
1060 | 1095 | { |
1061 | - if(!isset($this->CurrentFont)) |
|
1062 | - $this->Error('No font has been set'); |
|
1063 | - if($align=='R') |
|
1064 | - $dx = $w-$this->cMargin-$this->getStringWidth($txt); |
|
1065 | - elseif($align=='C') |
|
1066 | - $dx = ($w-$this->getStringWidth($txt))/2; |
|
1067 | - else |
|
1068 | - $dx = $this->cMargin; |
|
1069 | - if($this->ColorFlag) |
|
1070 | - $s .= 'q '.$this->TextColor.' '; |
|
1096 | + if(!isset($this->CurrentFont)) { |
|
1097 | + $this->Error('No font has been set'); |
|
1098 | + } |
|
1099 | + if($align=='R') { |
|
1100 | + $dx = $w-$this->cMargin-$this->getStringWidth($txt); |
|
1101 | + } elseif($align=='C') { |
|
1102 | + $dx = ($w-$this->getStringWidth($txt))/2; |
|
1103 | + } else { |
|
1104 | + $dx = $this->cMargin; |
|
1105 | + } |
|
1106 | + if($this->ColorFlag) { |
|
1107 | + $s .= 'q '.$this->TextColor.' '; |
|
1108 | + } |
|
1071 | 1109 | $s .= sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$this->escape($txt)); |
1072 | - if($this->underline) |
|
1073 | - $s .= ' '.$this->doUnderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); |
|
1074 | - if($this->ColorFlag) |
|
1075 | - $s .= ' Q'; |
|
1076 | - if($link) |
|
1077 | - $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->getStringWidth($txt),$this->FontSize,$link); |
|
1078 | - } |
|
1079 | - if($s) |
|
1080 | - $this->out($s); |
|
1110 | + if($this->underline) { |
|
1111 | + $s .= ' '.$this->doUnderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); |
|
1112 | + } |
|
1113 | + if($this->ColorFlag) { |
|
1114 | + $s .= ' Q'; |
|
1115 | + } |
|
1116 | + if($link) { |
|
1117 | + $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->getStringWidth($txt),$this->FontSize,$link); |
|
1118 | + } |
|
1119 | + } |
|
1120 | + if($s) { |
|
1121 | + $this->out($s); |
|
1122 | + } |
|
1081 | 1123 | $this->lasth = $h; |
1082 | 1124 | if($ln>0) |
1083 | 1125 | { |
1084 | 1126 | // Go to next line |
1085 | 1127 | $this->y += $h; |
1086 | - if($ln==1) |
|
1087 | - $this->x = $this->lMargin; |
|
1128 | + if($ln==1) { |
|
1129 | + $this->x = $this->lMargin; |
|
1130 | + } |
|
1131 | + } else { |
|
1132 | + $this->x += $w; |
|
1088 | 1133 | } |
1089 | - else |
|
1090 | - $this->x += $w; |
|
1091 | 1134 | } |
1092 | 1135 | |
1093 | 1136 | /** |
@@ -1121,16 +1164,19 @@ discard block |
||
1121 | 1164 | public function MultiCell(float $w, float $h, string $txt, $border=0, string $align='J', bool $fill=false) : void |
1122 | 1165 | { |
1123 | 1166 | // Output text with automatic or explicit line breaks |
1124 | - if(!isset($this->CurrentFont)) |
|
1125 | - $this->Error('No font has been set'); |
|
1167 | + if(!isset($this->CurrentFont)) { |
|
1168 | + $this->Error('No font has been set'); |
|
1169 | + } |
|
1126 | 1170 | $cw = &$this->CurrentFont['cw']; |
1127 | - if($w==0) |
|
1128 | - $w = $this->w-$this->rMargin-$this->x; |
|
1171 | + if($w==0) { |
|
1172 | + $w = $this->w-$this->rMargin-$this->x; |
|
1173 | + } |
|
1129 | 1174 | $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; |
1130 | 1175 | $s = str_replace("\r",'',$txt); |
1131 | 1176 | $nb = strlen($s); |
1132 | - if($nb>0 && $s[$nb-1]=="\n") |
|
1133 | - $nb--; |
|
1177 | + if($nb>0 && $s[$nb-1]=="\n") { |
|
1178 | + $nb--; |
|
1179 | + } |
|
1134 | 1180 | $b = 0; |
1135 | 1181 | $b2 = ''; |
1136 | 1182 | if($border) |
@@ -1140,14 +1186,15 @@ discard block |
||
1140 | 1186 | $border = 'LTRB'; |
1141 | 1187 | $b = 'LRT'; |
1142 | 1188 | $b2 = 'LR'; |
1143 | - } |
|
1144 | - else |
|
1189 | + } else |
|
1145 | 1190 | { |
1146 | 1191 | $b2 = ''; |
1147 | - if(strpos($border,'L')!==false) |
|
1148 | - $b2 .= 'L'; |
|
1149 | - if(strpos($border,'R')!==false) |
|
1150 | - $b2 .= 'R'; |
|
1192 | + if(strpos($border,'L')!==false) { |
|
1193 | + $b2 .= 'L'; |
|
1194 | + } |
|
1195 | + if(strpos($border,'R')!==false) { |
|
1196 | + $b2 .= 'R'; |
|
1197 | + } |
|
1151 | 1198 | $b = (strpos($border,'T')!==false) ? $b2.'T' : $b2; |
1152 | 1199 | } |
1153 | 1200 | } |
@@ -1177,8 +1224,9 @@ discard block |
||
1177 | 1224 | $l = 0; |
1178 | 1225 | $ns = 0; |
1179 | 1226 | $nl++; |
1180 | - if($border && $nl==2) |
|
1181 | - $b = $b2; |
|
1227 | + if($border && $nl==2) { |
|
1228 | + $b = $b2; |
|
1229 | + } |
|
1182 | 1230 | continue; |
1183 | 1231 | } |
1184 | 1232 | if($c==' ') |
@@ -1193,16 +1241,16 @@ discard block |
||
1193 | 1241 | // Automatic line break |
1194 | 1242 | if($sep==-1) |
1195 | 1243 | { |
1196 | - if($i==$j) |
|
1197 | - $i++; |
|
1244 | + if($i==$j) { |
|
1245 | + $i++; |
|
1246 | + } |
|
1198 | 1247 | if($this->ws>0) |
1199 | 1248 | { |
1200 | 1249 | $this->ws = 0; |
1201 | 1250 | $this->out('0 Tw'); |
1202 | 1251 | } |
1203 | 1252 | $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
1204 | - } |
|
1205 | - else |
|
1253 | + } else |
|
1206 | 1254 | { |
1207 | 1255 | if($align=='J') |
1208 | 1256 | { |
@@ -1217,11 +1265,12 @@ discard block |
||
1217 | 1265 | $l = 0; |
1218 | 1266 | $ns = 0; |
1219 | 1267 | $nl++; |
1220 | - if($border && $nl==2) |
|
1221 | - $b = $b2; |
|
1268 | + if($border && $nl==2) { |
|
1269 | + $b = $b2; |
|
1270 | + } |
|
1271 | + } else { |
|
1272 | + $i++; |
|
1222 | 1273 | } |
1223 | - else |
|
1224 | - $i++; |
|
1225 | 1274 | } |
1226 | 1275 | // Last chunk |
1227 | 1276 | if($this->ws>0) |
@@ -1229,8 +1278,9 @@ discard block |
||
1229 | 1278 | $this->ws = 0; |
1230 | 1279 | $this->out('0 Tw'); |
1231 | 1280 | } |
1232 | - if($border && strpos($border,'B')!==false) |
|
1233 | - $b .= 'B'; |
|
1281 | + if($border && strpos($border,'B')!==false) { |
|
1282 | + $b .= 'B'; |
|
1283 | + } |
|
1234 | 1284 | $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
1235 | 1285 | $this->x = $this->lMargin; |
1236 | 1286 | } |
@@ -1248,8 +1298,9 @@ discard block |
||
1248 | 1298 | public function Write(float $h, string $txt, $link='') : void |
1249 | 1299 | { |
1250 | 1300 | // Output text in flowing mode |
1251 | - if(!isset($this->CurrentFont)) |
|
1252 | - $this->Error('No font has been set'); |
|
1301 | + if(!isset($this->CurrentFont)) { |
|
1302 | + $this->Error('No font has been set'); |
|
1303 | + } |
|
1253 | 1304 | $cw = &$this->CurrentFont['cw']; |
1254 | 1305 | $w = $this->w-$this->rMargin-$this->x; |
1255 | 1306 | $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; |
@@ -1281,8 +1332,9 @@ discard block |
||
1281 | 1332 | $nl++; |
1282 | 1333 | continue; |
1283 | 1334 | } |
1284 | - if($c==' ') |
|
1285 | - $sep = $i; |
|
1335 | + if($c==' ') { |
|
1336 | + $sep = $i; |
|
1337 | + } |
|
1286 | 1338 | $l += $cw[$c]; |
1287 | 1339 | if($l>$wmax) |
1288 | 1340 | { |
@@ -1300,11 +1352,11 @@ discard block |
||
1300 | 1352 | $nl++; |
1301 | 1353 | continue; |
1302 | 1354 | } |
1303 | - if($i==$j) |
|
1304 | - $i++; |
|
1355 | + if($i==$j) { |
|
1356 | + $i++; |
|
1357 | + } |
|
1305 | 1358 | $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',false,$link); |
1306 | - } |
|
1307 | - else |
|
1359 | + } else |
|
1308 | 1360 | { |
1309 | 1361 | $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',false,$link); |
1310 | 1362 | $i = $sep+1; |
@@ -1319,13 +1371,14 @@ discard block |
||
1319 | 1371 | $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; |
1320 | 1372 | } |
1321 | 1373 | $nl++; |
1374 | + } else { |
|
1375 | + $i++; |
|
1322 | 1376 | } |
1323 | - else |
|
1324 | - $i++; |
|
1325 | 1377 | } |
1326 | 1378 | // Last chunk |
1327 | - if($i!=$j) |
|
1328 | - $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',false,$link); |
|
1379 | + if($i!=$j) { |
|
1380 | + $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',false,$link); |
|
1381 | + } |
|
1329 | 1382 | } |
1330 | 1383 | |
1331 | 1384 | /** |
@@ -1339,10 +1392,11 @@ discard block |
||
1339 | 1392 | { |
1340 | 1393 | // Line feed; default value is the last cell height |
1341 | 1394 | $this->x = $this->lMargin; |
1342 | - if($h===null) |
|
1343 | - $this->y += $this->lasth; |
|
1344 | - else |
|
1345 | - $this->y += $h; |
|
1395 | + if($h===null) { |
|
1396 | + $this->y += $this->lasth; |
|
1397 | + } else { |
|
1398 | + $this->y += $h; |
|
1399 | + } |
|
1346 | 1400 | } |
1347 | 1401 | |
1348 | 1402 | /** |
@@ -1520,10 +1574,11 @@ discard block |
||
1520 | 1574 | public function SetX(float $x) : void |
1521 | 1575 | { |
1522 | 1576 | // Set x position |
1523 | - if($x>=0) |
|
1524 | - $this->x = $x; |
|
1525 | - else |
|
1526 | - $this->x = $this->w+$x; |
|
1577 | + if($x>=0) { |
|
1578 | + $this->x = $x; |
|
1579 | + } else { |
|
1580 | + $this->x = $this->w+$x; |
|
1581 | + } |
|
1527 | 1582 | } |
1528 | 1583 | |
1529 | 1584 | /** |
@@ -1545,12 +1600,14 @@ discard block |
||
1545 | 1600 | public function SetY(float $y, bool $resetX=true) : void |
1546 | 1601 | { |
1547 | 1602 | // Set y position and optionally reset x |
1548 | - if($y>=0) |
|
1549 | - $this->y = $y; |
|
1550 | - else |
|
1551 | - $this->y = $this->h+$y; |
|
1552 | - if($resetX) |
|
1553 | - $this->x = $this->lMargin; |
|
1603 | + if($y>=0) { |
|
1604 | + $this->y = $y; |
|
1605 | + } else { |
|
1606 | + $this->y = $this->h+$y; |
|
1607 | + } |
|
1608 | + if($resetX) { |
|
1609 | + $this->x = $this->lMargin; |
|
1610 | + } |
|
1554 | 1611 | } |
1555 | 1612 | |
1556 | 1613 | /** |
@@ -1595,10 +1652,12 @@ discard block |
||
1595 | 1652 | $dest = $name; |
1596 | 1653 | $name = $tmp; |
1597 | 1654 | } |
1598 | - if($dest=='') |
|
1599 | - $dest = 'I'; |
|
1600 | - if($name=='') |
|
1601 | - $name = 'doc.pdf'; |
|
1655 | + if($dest=='') { |
|
1656 | + $dest = 'I'; |
|
1657 | + } |
|
1658 | + if($name=='') { |
|
1659 | + $name = 'doc.pdf'; |
|
1660 | + } |
|
1602 | 1661 | switch(strtoupper($dest)) |
1603 | 1662 | { |
1604 | 1663 | case 'I': |
@@ -1625,8 +1684,9 @@ discard block |
||
1625 | 1684 | break; |
1626 | 1685 | case 'F': |
1627 | 1686 | // Save to local file |
1628 | - if(!file_put_contents($name,$this->buffer)) |
|
1629 | - $this->Error('Unable to create output file: '.$name); |
|
1687 | + if(!file_put_contents($name,$this->buffer)) { |
|
1688 | + $this->Error('Unable to create output file: '.$name); |
|
1689 | + } |
|
1630 | 1690 | break; |
1631 | 1691 | case 'S': |
1632 | 1692 | // Return as a string |
@@ -2688,9 +2748,9 @@ discard block |
||
2688 | 2748 | // Level increasing: set first pointer |
2689 | 2749 | $this->outlines[$parent]['first'] = $i; |
2690 | 2750 | } |
2751 | + } else { |
|
2752 | + $this->outlines[$i]['parent'] = $nb; |
|
2691 | 2753 | } |
2692 | - else |
|
2693 | - $this->outlines[$i]['parent'] = $nb; |
|
2694 | 2754 | if ($o['l'] <= $level && $i > 0) { |
2695 | 2755 | // Set prev and next pointers |
2696 | 2756 | $prev = $lru[$o['l']]; |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * define table columns |
23 | 23 | * @param string $orientation |
24 | 24 | */ |
25 | - public function __construct(string $orientation='P') |
|
25 | + public function __construct(string $orientation = 'P') |
|
26 | 26 | { |
27 | 27 | // first call parent constructor for general initialization |
28 | 28 | parent::__construct($orientation); |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | $this->SetPageFooter("Page: {PN}/{NP}\tAuthor: S.Kien\t{D} {T}"); |
47 | 47 | |
48 | 48 | // now we define the columns of our report |
49 | - $this->AddCol('Row', 10, 'R', XPDF::COL_ROW_NR, XPDF::FLAG_TOTALS_TEXT); |
|
50 | - $this->AddCol('Date', 35, 'C', 'date', XPDF::FLAG_DATE); |
|
51 | - $this->AddCol('Text', -1, 'L', 'text'); |
|
52 | - $this->AddCol('Grp.', 12, 'C', self::MY_GRP_COL); |
|
53 | - $this->AddCol('Weight', 20, 'R', 'weight', XPDF::FLAG_TOTALS_CALC | XPDF::FLAG_NUMBER); |
|
54 | - $iImgCol = $this->AddCol(-1, 8, 'C', self::MY_IMAGE_COL, XPDF::FLAG_IMAGE | XPDF::FLAG_TOTALS_EMPTY); |
|
55 | - $this->AddCol('Price', 25, 'R', 'price', XPDF::FLAG_TOTALS_CALC | XPDF::FLAG_CUR_SYMBOL); |
|
56 | - $this->AddCol('Cost per kg', 25, 'R', self::MY_CALC_COL, XPDF::FLAG_TOTALS_EMPTY); |
|
49 | + $this->AddCol('Row', 10, 'R', XPDF::COL_ROW_NR, XPDF::FLAG_TOTALS_TEXT); |
|
50 | + $this->AddCol('Date', 35, 'C', 'date', XPDF::FLAG_DATE); |
|
51 | + $this->AddCol('Text', -1, 'L', 'text'); |
|
52 | + $this->AddCol('Grp.', 12, 'C', self::MY_GRP_COL); |
|
53 | + $this->AddCol('Weight', 20, 'R', 'weight', XPDF::FLAG_TOTALS_CALC | XPDF::FLAG_NUMBER); |
|
54 | + $iImgCol = $this->AddCol(-1, 8, 'C', self::MY_IMAGE_COL, XPDF::FLAG_IMAGE | XPDF::FLAG_TOTALS_EMPTY); |
|
55 | + $this->AddCol('Price', 25, 'R', 'price', XPDF::FLAG_TOTALS_CALC | XPDF::FLAG_CUR_SYMBOL); |
|
56 | + $this->AddCol('Cost per kg', 25, 'R', self::MY_CALC_COL, XPDF::FLAG_TOTALS_EMPTY); |
|
57 | 57 | |
58 | 58 | // enable the totals/pagetotals and carry-over functionality |
59 | 59 | $this->EnableTotals(XPDF::TOTALS | XPDF::PAGE_TOTALS | XPDF::CARRY_OVER); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | $this->SetNumberFormat(1, '', ' kg'); |
68 | 68 | |
69 | 69 | // and set meassuring for the image col |
70 | - $this->SetColImageInfo($iImgCol, 1.5, 2.5, 3 ); |
|
70 | + $this->SetColImageInfo($iImgCol, 1.5, 2.5, 3); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | $strCol = ''; |
89 | 89 | switch ($iCol) { |
90 | 90 | case self::MY_GRP_COL: |
91 | - $aValues = array( '', 'Grp. A', 'Grp. B', 'Grp. C', 'Grp. D'); |
|
91 | + $aValues = array('', 'Grp. A', 'Grp. B', 'Grp. C', 'Grp. D'); |
|
92 | 92 | if ($row['grp_id'] > 0 && $row['grp_id'] <= 4) { |
93 | 93 | $strCol = $aValues[$row['grp_id']]; |
94 | 94 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | case self::MY_CALC_COL: |
110 | 110 | $fltPricePerKg = 0.0; |
111 | 111 | if (floatval($row['weight']) != 0) { |
112 | - $fltPricePerKg = floatval($row['price']) / floatval($row['weight']);; |
|
112 | + $fltPricePerKg = floatval($row['price']) / floatval($row['weight']); ; |
|
113 | 113 | } |
114 | 114 | $strCol = $this->formatCurrency($fltPricePerKg, true); |
115 | 115 | break; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | // for grouping |
140 | 140 | $date = strtotime($row['date']); |
141 | 141 | $strMonth = date('Y-m', $date); |
142 | - if ( $this->strMonth != $strMonth) { |
|
142 | + if ($this->strMonth != $strMonth) { |
|
143 | 143 | // first row we have no subtotals... |
144 | 144 | if ($this->strMonth != '') { |
145 | 145 | $this->EndGroup(); |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | class XPDF extends FPDF |
31 | 31 | { |
32 | 32 | /** predifined Col-ID for automated row number */ |
33 | - const COL_ROW_NR = 1000; |
|
33 | + const COL_ROW_NR = 1000; |
|
34 | 34 | |
35 | 35 | /** Bottom margin for trigger of the auto pagebreak */ |
36 | - const BOTTOM_MARGIN = 12; |
|
36 | + const BOTTOM_MARGIN = 12; |
|
37 | 37 | |
38 | 38 | /** totals info */ |
39 | 39 | const FLAG_TOTALS = 0x0007; |
@@ -161,11 +161,11 @@ discard block |
||
161 | 161 | /** @var int index of last totals col */ |
162 | 162 | protected int $iMaxColTotals = -1; |
163 | 163 | /** @var array calculated totals */ |
164 | - protected array $aTotals = Array(); |
|
164 | + protected array $aTotals = Array(); |
|
165 | 165 | /** @var array calculated subtotals */ |
166 | - protected array $aSubTotals = Array(); |
|
166 | + protected array $aSubTotals = Array(); |
|
167 | 167 | /** @var array colspan of the totals */ |
168 | - protected array $aTotalsColSpan = Array(); |
|
168 | + protected array $aTotalsColSpan = Array(); |
|
169 | 169 | /** @var int current rownumber */ |
170 | 170 | protected int $iRow; |
171 | 171 | /** @var float lineheight in mm */ |
@@ -197,11 +197,11 @@ discard block |
||
197 | 197 | * @param string|array $size |
198 | 198 | * @see FPDF::__construct() |
199 | 199 | */ |
200 | - public function __construct(string $orientation='P', string $unit='mm', $size='A4') |
|
200 | + public function __construct(string $orientation = 'P', string $unit = 'mm', $size = 'A4') |
|
201 | 201 | { |
202 | 202 | parent::__construct($orientation, $unit, $size); |
203 | 203 | |
204 | - $this->SetDisplayMode('fullpage','single'); |
|
204 | + $this->SetDisplayMode('fullpage', 'single'); |
|
205 | 205 | $this->SetAutoPageBreak(true, self::BOTTOM_MARGIN); |
206 | 206 | $this->AliasNbPages('{NP}'); |
207 | 207 | $this->SetLocale("en_US.utf8, en_US"); |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | * @param string $strKeywords |
227 | 227 | * @param bool $isUTF8 Indicates if the strings encoded in ISO-8859-1 (false) or UTF-8 (true). (Default: false) |
228 | 228 | */ |
229 | - public function SetInfo(string $strTitle, string $strSubject, string $strAuthor, string $strKeywords='', bool $isUTF8=false) : void |
|
229 | + public function SetInfo(string $strTitle, string $strSubject, string $strAuthor, string $strKeywords = '', bool $isUTF8 = false) : void |
|
230 | 230 | { |
231 | 231 | $this->SetTitle($strTitle, $isUTF8); |
232 | 232 | $this->SetSubject($strSubject, $isUTF8); |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | * @see XPDF:SetSubject() |
293 | 293 | * @see XPDF:SetLogo() |
294 | 294 | */ |
295 | - public function SetPageHeader(string $strTitle, string $strHeaderSubject='', string $strLogo='') : void |
|
295 | + public function SetPageHeader(string $strTitle, string $strHeaderSubject = '', string $strLogo = '') : void |
|
296 | 296 | { |
297 | 297 | $this->strPageTitle = $strTitle; |
298 | 298 | if (strlen($strLogo) > 0) { |
@@ -365,11 +365,11 @@ discard block |
||
365 | 365 | public function InitGrid(string $strFilename = '') : void |
366 | 366 | { |
367 | 367 | $this->fontHeader = new XPDFFont('Arial', 'B', 12); |
368 | - $this->fontSubject = new XPDFFont('Arial', 'I', 8); |
|
369 | - $this->fontFooter = new XPDFFont('Arial', 'I', 8); |
|
370 | - $this->fontColHeader= new XPDFFont('Arial', 'B', 10); |
|
371 | - $this->fontSubHeader= new XPDFFont('Arial', 'B', 10); |
|
372 | - $this->fontRows = new XPDFFont('Arial', '', 10); |
|
368 | + $this->fontSubject = new XPDFFont('Arial', 'I', 8); |
|
369 | + $this->fontFooter = new XPDFFont('Arial', 'I', 8); |
|
370 | + $this->fontColHeader = new XPDFFont('Arial', 'B', 10); |
|
371 | + $this->fontSubHeader = new XPDFFont('Arial', 'B', 10); |
|
372 | + $this->fontRows = new XPDFFont('Arial', '', 10); |
|
373 | 373 | |
374 | 374 | $this->fltLineHeight = 8.0; |
375 | 375 | |
@@ -401,27 +401,27 @@ discard block |
||
401 | 401 | if ($jsonData) { |
402 | 402 | if (property_exists($jsonData, 'fontHeader')) { |
403 | 403 | $oFont = $jsonData->fontHeader; |
404 | - $this->fontHeader = new XPDFFont($oFont->name, $oFont->style, $oFont->size); |
|
404 | + $this->fontHeader = new XPDFFont($oFont->name, $oFont->style, $oFont->size); |
|
405 | 405 | } |
406 | 406 | if (property_exists($jsonData, 'fontSubject')) { |
407 | 407 | $oFont = $jsonData->fontSubject; |
408 | - $this->fontSubject = new XPDFFont($oFont->name, $oFont->style, $oFont->size); |
|
408 | + $this->fontSubject = new XPDFFont($oFont->name, $oFont->style, $oFont->size); |
|
409 | 409 | } |
410 | 410 | if (property_exists($jsonData, 'fontFooter')) { |
411 | 411 | $oFont = $jsonData->fontFooter; |
412 | - $this->fontFooter = new XPDFFont($oFont->name, $oFont->style, $oFont->size); |
|
412 | + $this->fontFooter = new XPDFFont($oFont->name, $oFont->style, $oFont->size); |
|
413 | 413 | } |
414 | 414 | if (property_exists($jsonData, 'fontColHeader')) { |
415 | 415 | $oFont = $jsonData->fontColHeader; |
416 | - $this->fontColHeader= new XPDFFont($oFont->name, $oFont->style, $oFont->size); |
|
416 | + $this->fontColHeader = new XPDFFont($oFont->name, $oFont->style, $oFont->size); |
|
417 | 417 | } |
418 | 418 | if (property_exists($jsonData, 'fontSubHeader')) { |
419 | 419 | $oFont = $jsonData->fontSubHeader; |
420 | - $this->fontSubHeader= new XPDFFont($oFont->name, $oFont->style, $oFont->size); |
|
420 | + $this->fontSubHeader = new XPDFFont($oFont->name, $oFont->style, $oFont->size); |
|
421 | 421 | } |
422 | 422 | if (property_exists($jsonData, 'fontRows')) { |
423 | 423 | $oFont = $jsonData->fontRows; |
424 | - $this->fontRows = new XPDFFont($oFont->name, $oFont->style, $oFont->size); |
|
424 | + $this->fontRows = new XPDFFont($oFont->name, $oFont->style, $oFont->size); |
|
425 | 425 | } |
426 | 426 | |
427 | 427 | $this->fltLineHeight = $this->property($jsonData, 'dblLineHeight', $this->fltLineHeight); |
@@ -445,9 +445,9 @@ discard block |
||
445 | 445 | $this->bStripped = $this->property($jsonData, 'bStripped', $this->bStripped); |
446 | 446 | $this->border = $this->property($jsonData, 'border', $this->border); |
447 | 447 | |
448 | - $this->bCalcTotals = $this->property($jsonData, 'bCalcTotals', $this->bCalcTotals); |
|
449 | - $this->bPageTotals = $this->property($jsonData, 'bPageTotals', $this->bPageTotals); |
|
450 | - $this->bCarryOver = $this->property($jsonData, 'bCarryOver', $this->bCarryOver); |
|
448 | + $this->bCalcTotals = $this->property($jsonData, 'bCalcTotals', $this->bCalcTotals); |
|
449 | + $this->bPageTotals = $this->property($jsonData, 'bPageTotals', $this->bPageTotals); |
|
450 | + $this->bCarryOver = $this->property($jsonData, 'bCarryOver', $this->bCarryOver); |
|
451 | 451 | |
452 | 452 | $this->strTotals = $this->property($jsonData, 'strTotals', $this->strTotals); |
453 | 453 | $this->strPageTotals = $this->property($jsonData, 'strPageTotals', $this->strPageTotals); |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | * @param string $strSuffix |
517 | 517 | * @see XPDF::InitGrid() |
518 | 518 | */ |
519 | - public function SetNumberFormat(int $iDecimals, string $strPrefix='', string $strSuffix='') : void |
|
519 | + public function SetNumberFormat(int $iDecimals, string $strPrefix = '', string $strSuffix = '') : void |
|
520 | 520 | { |
521 | 521 | $this->iNumberDecimals = $iDecimals; |
522 | 522 | $this->strNumberPrefix = $strPrefix; |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | */ |
573 | 573 | public function SetColHeaderFont(string $strFontname, string $strStyle, int $iSize) : void |
574 | 574 | { |
575 | - $this->fontColHeader= new XPDFFont($strFontname, $strStyle, $iSize); |
|
575 | + $this->fontColHeader = new XPDFFont($strFontname, $strStyle, $iSize); |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | /** |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | */ |
586 | 586 | public function SetSubHeaderFont(string $strFontname, string $strStyle, int $iSize) : void |
587 | 587 | { |
588 | - $this->fontSubHeader= new XPDFFont($strFontname, $strStyle, $iSize); |
|
588 | + $this->fontSubHeader = new XPDFFont($strFontname, $strStyle, $iSize); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | /** |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | */ |
599 | 599 | public function SetRowFont(string $strFontname, string $strStyle, int $iSize) : void |
600 | 600 | { |
601 | - $this->fontRows = new XPDFFont($strFontname, $strStyle, $iSize); |
|
601 | + $this->fontRows = new XPDFFont($strFontname, $strStyle, $iSize); |
|
602 | 602 | $this->SelectFont($this->fontRows); |
603 | 603 | } |
604 | 604 | |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | * @param string $strFillColor |
649 | 649 | * @param bool $bStripped |
650 | 650 | */ |
651 | - public function SetRowColors(string $strTextColor, string $strDrawColor, string $strFillColor, bool $bStripped=true) : void |
|
651 | + public function SetRowColors(string $strTextColor, string $strDrawColor, string $strFillColor, bool $bStripped = true) : void |
|
652 | 652 | { |
653 | 653 | $this->strRowTextColor = $strTextColor; |
654 | 654 | $this->strRowDrawColor = $strDrawColor; |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | * @see XPDF::InitGrid() |
680 | 680 | * @param int $iTotals combination of |
681 | 681 | */ |
682 | - public function EnableTotals(int $iTotals=self::TOTALS) : void |
|
682 | + public function EnableTotals(int $iTotals = self::TOTALS) : void |
|
683 | 683 | { |
684 | 684 | $this->bCalcTotals = ($iTotals & self::TOTALS) != 0; |
685 | 685 | $this->bPageTotals = ($iTotals & self::PAGE_TOTALS) != 0; |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | * @param string $strPageTotals |
702 | 702 | * @param string $strCarryOver |
703 | 703 | */ |
704 | - public function SetTotalsText(string $strTotals, string $strPageTotals='', string $strCarryOver='') : void |
|
704 | + public function SetTotalsText(string $strTotals, string $strPageTotals = '', string $strCarryOver = '') : void |
|
705 | 705 | { |
706 | 706 | $this->strTotals = $strTotals; |
707 | 707 | if (strlen($strPageTotals) > 0) { |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | * @param int $wFlags Flags to define behaviour for column |
723 | 723 | * @return int Index of the inserted col |
724 | 724 | */ |
725 | - public function AddCol(string $strColHeader, float $fltWidth, string $strAlign, string $strField, int $wFlags=0) : int |
|
725 | + public function AddCol(string $strColHeader, float $fltWidth, string $strAlign, string $strField, int $wFlags = 0) : int |
|
726 | 726 | { |
727 | 727 | $this->iMaxCol++; |
728 | 728 | $this->aColWidth[$this->iMaxCol] = $fltWidth; |
@@ -825,11 +825,11 @@ discard block |
||
825 | 825 | * @param string $strTotals |
826 | 826 | * @param string $strHeader |
827 | 827 | */ |
828 | - public function StartGroup(string $strTotals, ?string $strHeader=null) : void |
|
828 | + public function StartGroup(string $strTotals, ?string $strHeader = null) : void |
|
829 | 829 | { |
830 | 830 | $this->strSubTotals = $strTotals; |
831 | 831 | $iCount = count($this->aSubTotals); |
832 | - for ($i=0; $i < $iCount; $i++) { |
|
832 | + for ($i = 0; $i < $iCount; $i++) { |
|
833 | 833 | $this->aSubTotals[$i] = 0.0; |
834 | 834 | } |
835 | 835 | if ($strHeader) { |
@@ -863,7 +863,7 @@ discard block |
||
863 | 863 | */ |
864 | 864 | public function SelectTextColor(string $strColor) : void |
865 | 865 | { |
866 | - $r=0; $g=0; $b=0; |
|
866 | + $r = 0; $g = 0; $b = 0; |
|
867 | 867 | $this->getRGB($strColor, $r, $g, $b); |
868 | 868 | $this->SetTextColor($r, $g, $b); |
869 | 869 | } |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | */ |
875 | 875 | public function SelectDrawColor(string $strColor) : void |
876 | 876 | { |
877 | - $r=0; $g=0; $b=0; |
|
877 | + $r = 0; $g = 0; $b = 0; |
|
878 | 878 | $this->getRGB($strColor, $r, $g, $b); |
879 | 879 | $this->SetDrawColor($r, $g, $b); |
880 | 880 | } |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | */ |
886 | 886 | public function SelectFillColor(string $strColor) : void |
887 | 887 | { |
888 | - $r=0; $g=0; $b=0; |
|
888 | + $r = 0; $g = 0; $b = 0; |
|
889 | 889 | $this->getRGB($strColor, $r, $g, $b); |
890 | 890 | $this->SetFillColor($r, $g, $b); |
891 | 891 | } |
@@ -1109,7 +1109,7 @@ discard block |
||
1109 | 1109 | $bFill = $this->bStripped && (($this->iRow % 2) == 0); |
1110 | 1110 | |
1111 | 1111 | // calc totals if enabled |
1112 | - if ($this->bCalcTotals && ($wFlags & self::FLAG_TOTALS_CALC) != 0) { |
|
1112 | + if ($this->bCalcTotals && ($wFlags & self::FLAG_TOTALS_CALC) != 0) { |
|
1113 | 1113 | if (is_numeric($row[$field]) || is_float($row[$field])) { |
1114 | 1114 | $this->aTotals[$i] += $row[$field]; |
1115 | 1115 | $this->aSubTotals[$i] += $row[$field]; |
@@ -1134,7 +1134,7 @@ discard block |
||
1134 | 1134 | $link = ''; |
1135 | 1135 | if (($wFlags & self::FLAG_INT_LINK) != 0) { |
1136 | 1136 | $link = $this->InternalLink($i, $row); |
1137 | - $this->SetFont('','U'); |
|
1137 | + $this->SetFont('', 'U'); |
|
1138 | 1138 | $this->SelectTextColor($this->strLinkTextColor); |
1139 | 1139 | } |
1140 | 1140 | |
@@ -1148,7 +1148,7 @@ discard block |
||
1148 | 1148 | if (isset($this->aImgInfo[$i])) { |
1149 | 1149 | $fltTop += $this->aImgInfo[$i]['fltTop']; |
1150 | 1150 | $fltLeft += $this->aImgInfo[$i]['fltLeft']; |
1151 | - if ($this->aImgInfo[$i]['fltHeight'] > 0 ) { |
|
1151 | + if ($this->aImgInfo[$i]['fltHeight'] > 0) { |
|
1152 | 1152 | $fltHeight = $this->aImgInfo[$i]['fltHeight']; |
1153 | 1153 | } |
1154 | 1154 | if ($this->aImgInfo[$i]['fltWidth'] > 0) { |
@@ -1352,8 +1352,8 @@ discard block |
||
1352 | 1352 | */ |
1353 | 1353 | protected function Col(int $iCol, array $row, /** @scrutinizer ignore-unused */ bool &$bFill) : string |
1354 | 1354 | { |
1355 | - $strCol =''; |
|
1356 | - switch($iCol) { |
|
1355 | + $strCol = ''; |
|
1356 | + switch ($iCol) { |
|
1357 | 1357 | case self::COL_ROW_NR: |
1358 | 1358 | $strCol = $this->iRow; |
1359 | 1359 | break; |
@@ -1383,14 +1383,14 @@ discard block |
||
1383 | 1383 | protected function getRGB(string $strColor, int &$r, int &$g, int &$b) : void |
1384 | 1384 | { |
1385 | 1385 | if ($strColor[0] == '#') { |
1386 | - if (strlen( $strColor ) == 7) { |
|
1387 | - $r = intval( substr( $strColor, 1, 2 ), 16); |
|
1388 | - $g = intval( substr( $strColor, 3, 2 ), 16); |
|
1389 | - $b = intval( substr( $strColor, 5, 2 ), 16); |
|
1390 | - } elseif (strlen( $strColor ) == 4) { |
|
1391 | - $r = intval( substr( $strColor, 1, 1 ), 16); |
|
1392 | - $g = intval( substr( $strColor, 2, 1 ), 16); |
|
1393 | - $b = intval( substr( $strColor, 3, 1 ), 16); |
|
1386 | + if (strlen($strColor) == 7) { |
|
1387 | + $r = intval(substr($strColor, 1, 2), 16); |
|
1388 | + $g = intval(substr($strColor, 3, 2), 16); |
|
1389 | + $b = intval(substr($strColor, 5, 2), 16); |
|
1390 | + } elseif (strlen($strColor) == 4) { |
|
1391 | + $r = intval(substr($strColor, 1, 1), 16); |
|
1392 | + $g = intval(substr($strColor, 2, 1), 16); |
|
1393 | + $b = intval(substr($strColor, 3, 1), 16); |
|
1394 | 1394 | $r = $r + (16 * $r); |
1395 | 1395 | $g = $g + (16 * $g); |
1396 | 1396 | $b = $b + (16 * $b); |
@@ -1429,12 +1429,12 @@ discard block |
||
1429 | 1429 | // Restore line width |
1430 | 1430 | if ($this->LineWidth != $a['lw']) { |
1431 | 1431 | $this->LineWidth = $a['lw']; |
1432 | - $this->out(sprintf( '%.2F w', $a['lw'] * $this->k )); |
|
1432 | + $this->out(sprintf('%.2F w', $a['lw'] * $this->k)); |
|
1433 | 1433 | } |
1434 | 1434 | // Restore font |
1435 | 1435 | if (($a['family'] != $this->FontFamily) || |
1436 | - $a['style'] != $this->FontStyle || |
|
1437 | - $a['size'] != $this->FontSizePt) { |
|
1436 | + $a['style'] != $this->FontStyle || |
|
1437 | + $a['size'] != $this->FontSizePt) { |
|
1438 | 1438 | $this->SetFont($a['family'], $a['style'], $a['size']); |
1439 | 1439 | } |
1440 | 1440 | $this->underline = $a['ul']; |
@@ -1442,11 +1442,11 @@ discard block |
||
1442 | 1442 | // Restore colors |
1443 | 1443 | if ($this->DrawColor != $a['dc']) { |
1444 | 1444 | $this->DrawColor = $a['dc']; |
1445 | - $this->out( $a['dc']); |
|
1445 | + $this->out($a['dc']); |
|
1446 | 1446 | } |
1447 | 1447 | if ($this->FillColor != $a['fc']) { |
1448 | 1448 | $this->FillColor = $a['fc']; |
1449 | - $this->out( $a['fc']); |
|
1449 | + $this->out($a['fc']); |
|
1450 | 1450 | } |
1451 | 1451 | $this->TextColor = $a['tc']; |
1452 | 1452 | $this->ColorFlag = $a['cf']; |
@@ -1460,7 +1460,7 @@ discard block |
||
1460 | 1460 | * @param mixed $default |
1461 | 1461 | * @return mixed |
1462 | 1462 | */ |
1463 | - protected function property(\stdClass $obj, string $strName, $default='') |
|
1463 | + protected function property(\stdClass $obj, string $strName, $default = '') |
|
1464 | 1464 | { |
1465 | 1465 | $value = $default; |
1466 | 1466 | if (property_exists($obj, $strName)) { |
@@ -1479,7 +1479,7 @@ discard block |
||
1479 | 1479 | if ($this->strCharset != 'UTF-8') { |
1480 | 1480 | $strText = iconv('UTF-8', $this->strCharset, $strText); |
1481 | 1481 | } |
1482 | - return html_entity_decode( $strText, ENT_QUOTES, 'UTF-8'); |
|
1482 | + return html_entity_decode($strText, ENT_QUOTES, 'UTF-8'); |
|
1483 | 1483 | } |
1484 | 1484 | |
1485 | 1485 | /** |
@@ -1554,7 +1554,7 @@ discard block |
||
1554 | 1554 | * @param bool $bSymbol |
1555 | 1555 | * @return string |
1556 | 1556 | */ |
1557 | - protected function formatCurrency(float $fltValue, bool $bSymbol=true) : string |
|
1557 | + protected function formatCurrency(float $fltValue, bool $bSymbol = true) : string |
|
1558 | 1558 | { |
1559 | 1559 | if (!$this->bInvalidLocale) { |
1560 | 1560 | $li = localeconv(); |