Passed
Branch main (96fc75)
by Stefan
07:41
created
SKien/XFPDF/XPDF.php 1 patch
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1627,9 +1627,9 @@
 block discarded – undo
1627 1627
                     // Level increasing: set first pointer
1628 1628
                     $this->outlines[$parent]['first'] = $i;
1629 1629
                 }
1630
+            } else {
1631
+                            $this->outlines[$i]['parent'] = $nb;
1630 1632
             }
1631
-            else
1632
-                $this->outlines[$i]['parent'] = $nb;
1633 1633
             if ($o['l'] <= $level && $i > 0) {
1634 1634
                 // Set prev and next pointers
1635 1635
                 $prev = $lru[$o['l']];
Please login to merge, or discard this patch.
OPlathey/FPDF/font/courierb.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,8 +3,9 @@
 block discarded – undo
3 3
 $name = 'Courier-Bold';
4 4
 $up = -100;
5 5
 $ut = 50;
6
-for($i=0;$i<=255;$i++)
6
+for($i=0;$i<=255;$i++) {
7 7
 	$cw[chr($i)] = 600;
8
+}
8 9
 $enc = 'cp1252';
9 10
 $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96));
10 11
 ?>
Please login to merge, or discard this patch.
OPlathey/FPDF/font/courierbi.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,8 +3,9 @@
 block discarded – undo
3 3
 $name = 'Courier-BoldOblique';
4 4
 $up = -100;
5 5
 $ut = 50;
6
-for($i=0;$i<=255;$i++)
6
+for($i=0;$i<=255;$i++) {
7 7
 	$cw[chr($i)] = 600;
8
+}
8 9
 $enc = 'cp1252';
9 10
 $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96));
10 11
 ?>
Please login to merge, or discard this patch.
OPlathey/FPDF/font/courier.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,8 +3,9 @@
 block discarded – undo
3 3
 $name = 'Courier';
4 4
 $up = -100;
5 5
 $ut = 50;
6
-for($i=0;$i<=255;$i++)
6
+for($i=0;$i<=255;$i++) {
7 7
 	$cw[chr($i)] = 600;
8
+}
8 9
 $enc = 'cp1252';
9 10
 $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96));
10 11
 ?>
Please login to merge, or discard this patch.
OPlathey/FPDF/font/courieri.php 1 patch
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3,8 +3,9 @@
 block discarded – undo
3 3
 $name = 'Courier-Oblique';
4 4
 $up = -100;
5 5
 $ut = 50;
6
-for($i=0;$i<=255;$i++)
6
+for($i=0;$i<=255;$i++) {
7 7
 	$cw[chr($i)] = 600;
8
+}
8 9
 $enc = 'cp1252';
9 10
 $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96));
10 11
 ?>
Please login to merge, or discard this patch.
OPlathey/FPDF/FPDF.php 1 patch
Braces   +603 added lines, -462 removed lines patch added patch discarded remove patch
@@ -207,26 +207,28 @@  discard block
 block discarded – undo
207 207
     	if(defined('FPDF_FONTPATH'))
208 208
     	{
209 209
     		$this->fontpath = FPDF_FONTPATH;
210
-    		if(substr($this->fontpath,-1)!='/' && substr($this->fontpath,-1)!='\\')
211
-    			$this->fontpath .= '/';
210
+    		if(substr($this->fontpath,-1)!='/' && substr($this->fontpath,-1)!='\\') {
211
+    		    			$this->fontpath .= '/';
212
+    		}
213
+    	} elseif(is_dir(dirname(__FILE__).'/font')) {
214
+    	    		$this->fontpath = dirname(__FILE__).'/font/';
215
+    	} else {
216
+    	    		$this->fontpath = '';
212 217
     	}
213
-    	elseif(is_dir(dirname(__FILE__).'/font'))
214
-    		$this->fontpath = dirname(__FILE__).'/font/';
215
-    	else
216
-    		$this->fontpath = '';
217 218
     	// Core fonts
218 219
     	$this->CoreFonts = array('courier', 'helvetica', 'times', 'symbol', 'zapfdingbats');
219 220
     	// Scale factor
220
-    	if($unit=='pt')
221
-    		$this->k = 1;
222
-    	elseif($unit=='mm')
223
-    		$this->k = 72/25.4;
224
-    	elseif($unit=='cm')
225
-    		$this->k = 72/2.54;
226
-    	elseif($unit=='in')
227
-    		$this->k = 72;
228
-    	else
229
-    		$this->Error('Incorrect unit: '.$unit);
221
+    	if($unit=='pt') {
222
+    	    		$this->k = 1;
223
+    	} elseif($unit=='mm') {
224
+    	    		$this->k = 72/25.4;
225
+    	} elseif($unit=='cm') {
226
+    	    		$this->k = 72/2.54;
227
+    	} elseif($unit=='in') {
228
+    	    		$this->k = 72;
229
+    	} else {
230
+    	    		$this->Error('Incorrect unit: '.$unit);
231
+    	}
230 232
     	// Page sizes
231 233
     	$this->StdPageSizes = array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28),
232 234
     		'letter'=>array(612,792), 'legal'=>array(612,1008));
@@ -240,15 +242,14 @@  discard block
 block discarded – undo
240 242
     		$this->DefOrientation = 'P';
241 243
     		$this->w = $size[0];
242 244
     		$this->h = $size[1];
243
-    	}
244
-    	elseif($orientation=='l' || $orientation=='landscape')
245
+    	} elseif($orientation=='l' || $orientation=='landscape')
245 246
     	{
246 247
     		$this->DefOrientation = 'L';
247 248
     		$this->w = $size[1];
248 249
     		$this->h = $size[0];
250
+    	} else {
251
+    	    		$this->Error('Incorrect orientation: '.$orientation);
249 252
     	}
250
-    	else
251
-    		$this->Error('Incorrect orientation: '.$orientation);
252 253
     	$this->CurOrientation = $this->DefOrientation;
253 254
     	$this->wPt = $this->w*$this->k;
254 255
     	$this->hPt = $this->h*$this->k;
@@ -283,8 +284,9 @@  discard block
 block discarded – undo
283 284
     	// Set left, top and right margins
284 285
     	$this->lMargin = $left;
285 286
     	$this->tMargin = $top;
286
-    	if($right===null)
287
-    		$right = $left;
287
+    	if($right===null) {
288
+    	    		$right = $left;
289
+    	}
288 290
     	$this->rMargin = $right;
289 291
     }
290 292
 
@@ -298,8 +300,9 @@  discard block
 block discarded – undo
298 300
     {
299 301
     	// Set left margin
300 302
     	$this->lMargin = $margin;
301
-    	if($this->page>0 && $this->x<$margin)
302
-    		$this->x = $margin;
303
+    	if($this->page>0 && $this->x<$margin) {
304
+    	    		$this->x = $margin;
305
+    	}
303 306
     }
304 307
 
305 308
     /**
@@ -371,14 +374,16 @@  discard block
 block discarded – undo
371 374
     public function SetDisplayMode($zoom, string $layout='default') : void
372 375
     {
373 376
     	// Set display mode in viewer
374
-    	if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom))
375
-    		$this->ZoomMode = $zoom;
376
-    	else
377
-    		$this->Error('Incorrect zoom display mode: '.$zoom);
378
-    	if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default')
379
-    		$this->LayoutMode = $layout;
380
-    	else
381
-    		$this->Error('Incorrect layout display mode: '.$layout);
377
+    	if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) {
378
+    	    		$this->ZoomMode = $zoom;
379
+    	} else {
380
+    	    		$this->Error('Incorrect zoom display mode: '.$zoom);
381
+    	}
382
+    	if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') {
383
+    	    		$this->LayoutMode = $layout;
384
+    	} else {
385
+    	    		$this->Error('Incorrect layout display mode: '.$layout);
386
+    	}
382 387
     }
383 388
 
384 389
     /**
@@ -393,10 +398,11 @@  discard block
 block discarded – undo
393 398
     public function SetCompression(bool $compress) : void
394 399
     {
395 400
     	// Set page compression
396
-    	if(function_exists('gzcompress'))
397
-    		$this->compress = $compress;
398
-    	else
399
-    		$this->compress = false;
401
+    	if(function_exists('gzcompress')) {
402
+    	    		$this->compress = $compress;
403
+    	} else {
404
+    	    		$this->compress = false;
405
+    	}
400 406
     }
401 407
 
402 408
     /**
@@ -487,10 +493,12 @@  discard block
 block discarded – undo
487 493
     public function Close() : void
488 494
     {
489 495
     	// Terminate document
490
-    	if($this->state==3)
491
-    		return;
492
-    	if($this->page==0)
493
-    		$this->addPage();
496
+    	if($this->state==3) {
497
+    	    		return;
498
+    	}
499
+    	if($this->page==0) {
500
+    	    		$this->addPage();
501
+    	}
494 502
     	// Page footer
495 503
     	$this->InFooter = true;
496 504
     	$this->Footer();
@@ -532,8 +540,9 @@  discard block
 block discarded – undo
532 540
     public function AddPage(string $orientation='', $size='', int $rotation=0) : void
533 541
     {
534 542
     	// Start a new page
535
-    	if($this->state==3)
536
-    		$this->Error('The document is closed');
543
+    	if($this->state==3) {
544
+    	    		$this->Error('The document is closed');
545
+    	}
537 546
     	$family = $this->FontFamily;
538 547
     	$style = $this->FontStyle.($this->underline ? 'U' : '');
539 548
     	$fontsize = $this->FontSizePt;
@@ -559,15 +568,18 @@  discard block
 block discarded – undo
559 568
     	$this->LineWidth = $lw;
560 569
     	$this->_out(sprintf('%.2F w',$lw*$this->k));
561 570
     	// Set font
562
-    	if($family)
563
-    		$this->setFont($family,$style,$fontsize);
571
+    	if($family) {
572
+    	    		$this->setFont($family,$style,$fontsize);
573
+    	}
564 574
     	// Set colors
565 575
     	$this->DrawColor = $dc;
566
-    	if($dc!='0 G')
567
-    		$this->_out($dc);
576
+    	if($dc!='0 G') {
577
+    	    		$this->_out($dc);
578
+    	}
568 579
     	$this->FillColor = $fc;
569
-    	if($fc!='0 g')
570
-    		$this->_out($fc);
580
+    	if($fc!='0 g') {
581
+    	    		$this->_out($fc);
582
+    	}
571 583
     	$this->TextColor = $tc;
572 584
     	$this->ColorFlag = $cf;
573 585
     	// Page header
@@ -581,8 +593,9 @@  discard block
 block discarded – undo
581 593
     		$this->_out(sprintf('%.2F w',$lw*$this->k));
582 594
     	}
583 595
     	// Restore font
584
-    	if($family)
585
-    		$this->setFont($family,$style,$fontsize);
596
+    	if($family) {
597
+    	    		$this->setFont($family,$style,$fontsize);
598
+    	}
586 599
     	// Restore colors
587 600
     	if($this->DrawColor!=$dc)
588 601
     	{
@@ -641,12 +654,14 @@  discard block
 block discarded – undo
641 654
     public function SetDrawColor(int $r, ?int $g=null, ?int $b=null) : void
642 655
     {
643 656
     	// Set color for all stroking operations
644
-    	if(($r==0 && $g==0 && $b==0) || $g===null)
645
-    		$this->DrawColor = sprintf('%.3F G',$r/255);
646
-    	else
647
-    		$this->DrawColor = sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255);
648
-    	if($this->page>0)
649
-    		$this->_out($this->DrawColor);
657
+    	if(($r==0 && $g==0 && $b==0) || $g===null) {
658
+    	    		$this->DrawColor = sprintf('%.3F G',$r/255);
659
+    	} else {
660
+    	    		$this->DrawColor = sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255);
661
+    	}
662
+    	if($this->page>0) {
663
+    	    		$this->_out($this->DrawColor);
664
+    	}
650 665
     }
651 666
     
652 667
     /**
@@ -660,13 +675,15 @@  discard block
 block discarded – undo
660 675
     public function SetFillColor(int $r, ?int $g=null, ?int $b=null) : void
661 676
     {
662 677
     	// Set color for all filling operations
663
-    	if(($r==0 && $g==0 && $b==0) || $g===null)
664
-    		$this->FillColor = sprintf('%.3F g',$r/255);
665
-    	else
666
-    		$this->FillColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
678
+    	if(($r==0 && $g==0 && $b==0) || $g===null) {
679
+    	    		$this->FillColor = sprintf('%.3F g',$r/255);
680
+    	} else {
681
+    	    		$this->FillColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
682
+    	}
667 683
     	$this->ColorFlag = ($this->FillColor!=$this->TextColor);
668
-    	if($this->page>0)
669
-    		$this->_out($this->FillColor);
684
+    	if($this->page>0) {
685
+    	    		$this->_out($this->FillColor);
686
+    	}
670 687
     }
671 688
     
672 689
     /**
@@ -680,10 +697,11 @@  discard block
 block discarded – undo
680 697
     public function SetTextColor(int $r, ?int $g=null, ?int $b=null) : void
681 698
     {
682 699
     	// Set color for text
683
-    	if(($r==0 && $g==0 && $b==0) || $g===null)
684
-    		$this->TextColor = sprintf('%.3F g',$r/255);
685
-    	else
686
-    		$this->TextColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
700
+    	if(($r==0 && $g==0 && $b==0) || $g===null) {
701
+    	    		$this->TextColor = sprintf('%.3F g',$r/255);
702
+    	} else {
703
+    	    		$this->TextColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255);
704
+    	}
687 705
     	$this->ColorFlag = ($this->FillColor!=$this->TextColor);
688 706
     }
689 707
     
@@ -700,8 +718,9 @@  discard block
 block discarded – undo
700 718
     	$cw = &$this->CurrentFont['cw'];
701 719
     	$w = 0;
702 720
     	$l = strlen($s);
703
-    	for($i=0;$i<$l;$i++)
704
-    		$w += $cw[$s[$i]];
721
+    	for($i=0;$i<$l;$i++) {
722
+    	    		$w += $cw[$s[$i]];
723
+    	}
705 724
     	return $w*$this->FontSize/1000;
706 725
     }
707 726
     
@@ -715,8 +734,9 @@  discard block
 block discarded – undo
715 734
     {
716 735
     	// Set line width
717 736
     	$this->LineWidth = $width;
718
-    	if($this->page>0)
719
-    		$this->_out(sprintf('%.2F w',$width*$this->k));
737
+    	if($this->page>0) {
738
+    	    		$this->_out(sprintf('%.2F w',$width*$this->k));
739
+    	}
720 740
     }
721 741
     
722 742
     /**
@@ -752,12 +772,13 @@  discard block
 block discarded – undo
752 772
     public function Rect(float $x, float $y, float $w, float $h, string $style='') : void
753 773
     {
754 774
     	// Draw a rectangle
755
-    	if($style=='F')
756
-    		$op = 'f';
757
-    	elseif($style=='FD' || $style=='DF')
758
-    		$op = 'B';
759
-    	else
760
-    		$op = 'S';
775
+    	if($style=='F') {
776
+    	    		$op = 'f';
777
+    	} elseif($style=='FD' || $style=='DF') {
778
+    	    		$op = 'B';
779
+    	} else {
780
+    	    		$op = 'S';
781
+    	}
761 782
     	$this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op));
762 783
     }
763 784
     
@@ -782,23 +803,27 @@  discard block
 block discarded – undo
782 803
     {
783 804
     	// Add a TrueType, OpenType or Type1 font
784 805
     	$family = strtolower($family);
785
-    	if($file=='')
786
-    		$file = str_replace(' ','',$family).strtolower($style).'.php';
806
+    	if($file=='') {
807
+    	    		$file = str_replace(' ','',$family).strtolower($style).'.php';
808
+    	}
787 809
     	$style = strtoupper($style);
788
-    	if($style=='IB')
789
-    		$style = 'BI';
810
+    	if($style=='IB') {
811
+    	    		$style = 'BI';
812
+    	}
790 813
     	$fontkey = $family.$style;
791
-    	if(isset($this->fonts[$fontkey]))
792
-    		return;
814
+    	if(isset($this->fonts[$fontkey])) {
815
+    	    		return;
816
+    	}
793 817
     	$info = $this->_loadfont($file);
794 818
     	$info['i'] = count($this->fonts)+1;
795 819
     	if(!empty($info['file']))
796 820
     	{
797 821
     		// Embedded font
798
-    		if($info['type']=='TrueType')
799
-    			$this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']);
800
-    		else
801
-    			$this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']);
822
+    		if($info['type']=='TrueType') {
823
+    		    			$this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']);
824
+    		} else {
825
+    		    			$this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']);
826
+    		}
802 827
     	}
803 828
     	$this->fonts[$fontkey] = $info;
804 829
     }
@@ -841,42 +866,49 @@  discard block
 block discarded – undo
841 866
     public function SetFont(string $family, string $style='', float $size=0) : void
842 867
     {
843 868
     	// Select a font; size given in points
844
-    	if($family=='')
845
-    		$family = $this->FontFamily;
846
-    	else
847
-    		$family = strtolower($family);
869
+    	if($family=='') {
870
+    	    		$family = $this->FontFamily;
871
+    	} else {
872
+    	    		$family = strtolower($family);
873
+    	}
848 874
     	$style = strtoupper($style);
849 875
     	if(strpos($style,'U')!==false)
850 876
     	{
851 877
     		$this->underline = true;
852 878
     		$style = str_replace('U','',$style);
879
+    	} else {
880
+    	    		$this->underline = false;
881
+    	}
882
+    	if($style=='IB') {
883
+    	    		$style = 'BI';
884
+    	}
885
+    	if($size==0) {
886
+    	    		$size = $this->FontSizePt;
853 887
     	}
854
-    	else
855
-    		$this->underline = false;
856
-    	if($style=='IB')
857
-    		$style = 'BI';
858
-    	if($size==0)
859
-    		$size = $this->FontSizePt;
860 888
     	// Test if font is already selected
861
-    	if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size)
862
-    		return;
889
+    	if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) {
890
+    	    		return;
891
+    	}
863 892
     	// Test if font is already loaded
864 893
     	$fontkey = $family.$style;
865 894
     	if(!isset($this->fonts[$fontkey]))
866 895
     	{
867 896
     		// Test if one of the core fonts
868
-    		if($family=='arial')
869
-    			$family = 'helvetica';
897
+    		if($family=='arial') {
898
+    		    			$family = 'helvetica';
899
+    		}
870 900
     		if(in_array($family,$this->CoreFonts))
871 901
     		{
872
-    			if($family=='symbol' || $family=='zapfdingbats')
873
-    				$style = '';
902
+    			if($family=='symbol' || $family=='zapfdingbats') {
903
+    			    				$style = '';
904
+    			}
874 905
     			$fontkey = $family.$style;
875
-    			if(!isset($this->fonts[$fontkey]))
876
-    				$this->addFont($family,$style);
906
+    			if(!isset($this->fonts[$fontkey])) {
907
+    			    				$this->addFont($family,$style);
908
+    			}
909
+    		} else {
910
+    		    			$this->Error('Undefined font: '.$family.' '.$style);
877 911
     		}
878
-    		else
879
-    			$this->Error('Undefined font: '.$family.' '.$style);
880 912
     	}
881 913
     	// Select it
882 914
     	$this->FontFamily = $family;
@@ -884,8 +916,9 @@  discard block
 block discarded – undo
884 916
     	$this->FontSizePt = $size;
885 917
     	$this->FontSize = $size/$this->k;
886 918
     	$this->CurrentFont = &$this->fonts[$fontkey];
887
-    	if($this->page>0)
888
-    		$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
919
+    	if($this->page>0) {
920
+    	    		$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
921
+    	}
889 922
     }
890 923
     
891 924
     /**
@@ -895,12 +928,14 @@  discard block
 block discarded – undo
895 928
     public function SetFontSize(float $size) : void
896 929
     {
897 930
     	// Set font size in points
898
-    	if($this->FontSizePt==$size)
899
-    		return;
931
+    	if($this->FontSizePt==$size) {
932
+    	    		return;
933
+    	}
900 934
     	$this->FontSizePt = $size;
901 935
     	$this->FontSize = $size/$this->k;
902
-    	if($this->page>0)
903
-    		$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
936
+    	if($this->page>0) {
937
+    	    		$this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
938
+    	}
904 939
     }
905 940
     
906 941
     /**
@@ -927,10 +962,12 @@  discard block
 block discarded – undo
927 962
     public function SetLink(int $link, float $y=0, int $page=-1) : void
928 963
     {
929 964
     	// Set destination of internal link
930
-    	if($y==-1)
931
-    		$y = $this->y;
932
-    	if($page==-1)
933
-    		$page = $this->page;
965
+    	if($y==-1) {
966
+    	    		$y = $this->y;
967
+    	}
968
+    	if($page==-1) {
969
+    	    		$page = $this->page;
970
+    	}
934 971
     	$this->links[$link] = array($page, $y);
935 972
     }
936 973
     
@@ -964,13 +1001,16 @@  discard block
 block discarded – undo
964 1001
     public function Text(float $x, float $y, string $txt) : void
965 1002
     {
966 1003
     	// Output a string
967
-    	if(!isset($this->CurrentFont))
968
-    		$this->Error('No font has been set');
1004
+    	if(!isset($this->CurrentFont)) {
1005
+    	    		$this->Error('No font has been set');
1006
+    	}
969 1007
     	$s = sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt));
970
-    	if($this->underline && $txt!='')
971
-    		$s .= ' '.$this->_dounderline($x,$y,$txt);
972
-    	if($this->ColorFlag)
973
-    		$s = 'q '.$this->TextColor.' '.$s.' Q';
1008
+    	if($this->underline && $txt!='') {
1009
+    	    		$s .= ' '.$this->_dounderline($x,$y,$txt);
1010
+    	}
1011
+    	if($this->ColorFlag) {
1012
+    	    		$s = 'q '.$this->TextColor.' '.$s.' Q';
1013
+    	}
974 1014
     	$this->_out($s);
975 1015
     }
976 1016
     
@@ -1050,62 +1090,76 @@  discard block
 block discarded – undo
1050 1090
     			$this->_out(sprintf('%.3F Tw',$ws*$k));
1051 1091
     		}
1052 1092
     	}
1053
-    	if($w==0)
1054
-    		$w = $this->w-$this->rMargin-$this->x;
1093
+    	if($w==0) {
1094
+    	    		$w = $this->w-$this->rMargin-$this->x;
1095
+    	}
1055 1096
     	$s = '';
1056 1097
     	if($fill || $border==1)
1057 1098
     	{
1058
-    		if($fill)
1059
-    			$op = ($border==1) ? 'B' : 'f';
1060
-    		else
1061
-    			$op = 'S';
1099
+    		if($fill) {
1100
+    		    			$op = ($border==1) ? 'B' : 'f';
1101
+    		} else {
1102
+    		    			$op = 'S';
1103
+    		}
1062 1104
     		$s = sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op);
1063 1105
     	}
1064 1106
     	if(is_string($border))
1065 1107
     	{
1066 1108
     		$x = $this->x;
1067 1109
     		$y = $this->y;
1068
-    		if(strpos($border,'L')!==false)
1069
-    			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);
1070
-    		if(strpos($border,'T')!==false)
1071
-    			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);
1072
-    		if(strpos($border,'R')!==false)
1073
-    			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
1074
-    		if(strpos($border,'B')!==false)
1075
-    			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
1110
+    		if(strpos($border,'L')!==false) {
1111
+    		    			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);
1112
+    		}
1113
+    		if(strpos($border,'T')!==false) {
1114
+    		    			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);
1115
+    		}
1116
+    		if(strpos($border,'R')!==false) {
1117
+    		    			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
1118
+    		}
1119
+    		if(strpos($border,'B')!==false) {
1120
+    		    			$s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
1121
+    		}
1076 1122
     	}
1077 1123
     	if($txt!=='')
1078 1124
     	{
1079
-    		if(!isset($this->CurrentFont))
1080
-    			$this->Error('No font has been set');
1081
-    		if($align=='R')
1082
-    			$dx = $w-$this->cMargin-$this->getStringWidth($txt);
1083
-    		elseif($align=='C')
1084
-    			$dx = ($w-$this->getStringWidth($txt))/2;
1085
-    		else
1086
-    			$dx = $this->cMargin;
1087
-    		if($this->ColorFlag)
1088
-    			$s .= 'q '.$this->TextColor.' ';
1125
+    		if(!isset($this->CurrentFont)) {
1126
+    		    			$this->Error('No font has been set');
1127
+    		}
1128
+    		if($align=='R') {
1129
+    		    			$dx = $w-$this->cMargin-$this->getStringWidth($txt);
1130
+    		} elseif($align=='C') {
1131
+    		    			$dx = ($w-$this->getStringWidth($txt))/2;
1132
+    		} else {
1133
+    		    			$dx = $this->cMargin;
1134
+    		}
1135
+    		if($this->ColorFlag) {
1136
+    		    			$s .= 'q '.$this->TextColor.' ';
1137
+    		}
1089 1138
     		$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));
1090
-    		if($this->underline)
1091
-    			$s .= ' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt);
1092
-    		if($this->ColorFlag)
1093
-    			$s .= ' Q';
1094
-    		if($link)
1095
-    			$this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->getStringWidth($txt),$this->FontSize,$link);
1096
-    	}
1097
-    	if($s)
1098
-    		$this->_out($s);
1139
+    		if($this->underline) {
1140
+    		    			$s .= ' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt);
1141
+    		}
1142
+    		if($this->ColorFlag) {
1143
+    		    			$s .= ' Q';
1144
+    		}
1145
+    		if($link) {
1146
+    		    			$this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->getStringWidth($txt),$this->FontSize,$link);
1147
+    		}
1148
+    	}
1149
+    	if($s) {
1150
+    	    		$this->_out($s);
1151
+    	}
1099 1152
     	$this->lasth = $h;
1100 1153
     	if($ln>0)
1101 1154
     	{
1102 1155
     		// Go to next line
1103 1156
     		$this->y += $h;
1104
-    		if($ln==1)
1105
-    			$this->x = $this->lMargin;
1157
+    		if($ln==1) {
1158
+    		    			$this->x = $this->lMargin;
1159
+    		}
1160
+    	} else {
1161
+    	    		$this->x += $w;
1106 1162
     	}
1107
-    	else
1108
-    		$this->x += $w;
1109 1163
     }
1110 1164
     
1111 1165
     /**
@@ -1139,16 +1193,19 @@  discard block
 block discarded – undo
1139 1193
     public function MultiCell(float $w, float $h, string $txt, $border=0, string $align='J', bool $fill=false) : void
1140 1194
     {
1141 1195
     	// Output text with automatic or explicit line breaks
1142
-    	if(!isset($this->CurrentFont))
1143
-    		$this->Error('No font has been set');
1196
+    	if(!isset($this->CurrentFont)) {
1197
+    	    		$this->Error('No font has been set');
1198
+    	}
1144 1199
     	$cw = &$this->CurrentFont['cw'];
1145
-    	if($w==0)
1146
-    		$w = $this->w-$this->rMargin-$this->x;
1200
+    	if($w==0) {
1201
+    	    		$w = $this->w-$this->rMargin-$this->x;
1202
+    	}
1147 1203
     	$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
1148 1204
     	$s = str_replace("\r",'',$txt);
1149 1205
     	$nb = strlen($s);
1150
-    	if($nb>0 && $s[$nb-1]=="\n")
1151
-    		$nb--;
1206
+    	if($nb>0 && $s[$nb-1]=="\n") {
1207
+    	    		$nb--;
1208
+    	}
1152 1209
     	$b = 0;
1153 1210
     	$b2 = '';
1154 1211
     	if($border)
@@ -1158,14 +1215,15 @@  discard block
 block discarded – undo
1158 1215
     			$border = 'LTRB';
1159 1216
     			$b = 'LRT';
1160 1217
     			$b2 = 'LR';
1161
-    		}
1162
-    		else
1218
+    		} else
1163 1219
     		{
1164 1220
     			$b2 = '';
1165
-    			if(strpos($border,'L')!==false)
1166
-    				$b2 .= 'L';
1167
-    			if(strpos($border,'R')!==false)
1168
-    				$b2 .= 'R';
1221
+    			if(strpos($border,'L')!==false) {
1222
+    			    				$b2 .= 'L';
1223
+    			}
1224
+    			if(strpos($border,'R')!==false) {
1225
+    			    				$b2 .= 'R';
1226
+    			}
1169 1227
     			$b = (strpos($border,'T')!==false) ? $b2.'T' : $b2;
1170 1228
     		}
1171 1229
     	}
@@ -1195,8 +1253,9 @@  discard block
 block discarded – undo
1195 1253
     			$l = 0;
1196 1254
     			$ns = 0;
1197 1255
     			$nl++;
1198
-    			if($border && $nl==2)
1199
-    				$b = $b2;
1256
+    			if($border && $nl==2) {
1257
+    			    				$b = $b2;
1258
+    			}
1200 1259
     			continue;
1201 1260
     		}
1202 1261
     		if($c==' ')
@@ -1211,16 +1270,16 @@  discard block
 block discarded – undo
1211 1270
     			// Automatic line break
1212 1271
     			if($sep==-1)
1213 1272
     			{
1214
-    				if($i==$j)
1215
-    					$i++;
1273
+    				if($i==$j) {
1274
+    				    					$i++;
1275
+    				}
1216 1276
     				if($this->ws>0)
1217 1277
     				{
1218 1278
     					$this->ws = 0;
1219 1279
     					$this->_out('0 Tw');
1220 1280
     				}
1221 1281
     				$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
1222
-    			}
1223
-    			else
1282
+    			} else
1224 1283
     			{
1225 1284
     				if($align=='J')
1226 1285
     				{
@@ -1235,11 +1294,12 @@  discard block
 block discarded – undo
1235 1294
     			$l = 0;
1236 1295
     			$ns = 0;
1237 1296
     			$nl++;
1238
-    			if($border && $nl==2)
1239
-    				$b = $b2;
1297
+    			if($border && $nl==2) {
1298
+    			    				$b = $b2;
1299
+    			}
1300
+    		} else {
1301
+    		    			$i++;
1240 1302
     		}
1241
-    		else
1242
-    			$i++;
1243 1303
     	}
1244 1304
     	// Last chunk
1245 1305
     	if($this->ws>0)
@@ -1247,8 +1307,9 @@  discard block
 block discarded – undo
1247 1307
     		$this->ws = 0;
1248 1308
     		$this->_out('0 Tw');
1249 1309
     	}
1250
-    	if($border && strpos($border,'B')!==false)
1251
-    		$b .= 'B';
1310
+    	if($border && strpos($border,'B')!==false) {
1311
+    	    		$b .= 'B';
1312
+    	}
1252 1313
     	$this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill);
1253 1314
     	$this->x = $this->lMargin;
1254 1315
     }
@@ -1266,8 +1327,9 @@  discard block
 block discarded – undo
1266 1327
     public function Write(float $h, string $txt, $link='') : void
1267 1328
     {
1268 1329
     	// Output text in flowing mode
1269
-    	if(!isset($this->CurrentFont))
1270
-    		$this->Error('No font has been set');
1330
+    	if(!isset($this->CurrentFont)) {
1331
+    	    		$this->Error('No font has been set');
1332
+    	}
1271 1333
     	$cw = &$this->CurrentFont['cw'];
1272 1334
     	$w = $this->w-$this->rMargin-$this->x;
1273 1335
     	$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
@@ -1299,8 +1361,9 @@  discard block
 block discarded – undo
1299 1361
     			$nl++;
1300 1362
     			continue;
1301 1363
     		}
1302
-    		if($c==' ')
1303
-    			$sep = $i;
1364
+    		if($c==' ') {
1365
+    		    			$sep = $i;
1366
+    		}
1304 1367
     		$l += $cw[$c];
1305 1368
     		if($l>$wmax)
1306 1369
     		{
@@ -1318,11 +1381,11 @@  discard block
 block discarded – undo
1318 1381
     					$nl++;
1319 1382
     					continue;
1320 1383
     				}
1321
-    				if($i==$j)
1322
-    					$i++;
1384
+    				if($i==$j) {
1385
+    				    					$i++;
1386
+    				}
1323 1387
     				$this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',false,$link);
1324
-    			}
1325
-    			else
1388
+    			} else
1326 1389
     			{
1327 1390
     				$this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',false,$link);
1328 1391
     				$i = $sep+1;
@@ -1337,13 +1400,14 @@  discard block
 block discarded – undo
1337 1400
     				$wmax = ($w-2*$this->cMargin)*1000/$this->FontSize;
1338 1401
     			}
1339 1402
     			$nl++;
1403
+    		} else {
1404
+    		    			$i++;
1340 1405
     		}
1341
-    		else
1342
-    			$i++;
1343 1406
     	}
1344 1407
     	// Last chunk
1345
-    	if($i!=$j)
1346
-    		$this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',false,$link);
1408
+    	if($i!=$j) {
1409
+    	    		$this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',false,$link);
1410
+    	}
1347 1411
     }
1348 1412
     
1349 1413
     /**
@@ -1357,10 +1421,11 @@  discard block
 block discarded – undo
1357 1421
     {
1358 1422
     	// Line feed; default value is the last cell height
1359 1423
     	$this->x = $this->lMargin;
1360
-    	if($h===null)
1361
-    		$this->y += $this->lasth;
1362
-    	else
1363
-    		$this->y += $h;
1424
+    	if($h===null) {
1425
+    	    		$this->y += $this->lasth;
1426
+    	} else {
1427
+    	    		$this->y += $h;
1428
+    	}
1364 1429
     }
1365 1430
     
1366 1431
     /**
@@ -1412,30 +1477,34 @@  discard block
 block discarded – undo
1412 1477
     public function Image(string $file, ?float $x=null, ?float $y=null, float $w=0, float $h=0, string $type='', $link='') : void
1413 1478
     {
1414 1479
     	// Put an image on the page
1415
-    	if($file=='')
1416
-    		$this->Error('Image file name is empty');
1480
+    	if($file=='') {
1481
+    	    		$this->Error('Image file name is empty');
1482
+    	}
1417 1483
     	if(!isset($this->images[$file]))
1418 1484
     	{
1419 1485
     		// First use of this image, get info
1420 1486
     		if($type=='')
1421 1487
     		{
1422 1488
     			$pos = strrpos($file,'.');
1423
-    			if(!$pos)
1424
-    				$this->Error('Image file has no extension and no type was specified: '.$file);
1489
+    			if(!$pos) {
1490
+    			    				$this->Error('Image file has no extension and no type was specified: '.$file);
1491
+    			}
1425 1492
     			$type = substr($file,$pos+1);
1426 1493
     		}
1427 1494
     		$type = strtolower($type);
1428
-    		if($type=='jpeg')
1429
-    			$type = 'jpg';
1495
+    		if($type=='jpeg') {
1496
+    		    			$type = 'jpg';
1497
+    		}
1430 1498
     		$mtd = '_parse'.$type;
1431
-    		if(!method_exists($this,$mtd))
1432
-    			$this->Error('Unsupported image type: '.$type);
1499
+    		if(!method_exists($this,$mtd)) {
1500
+    		    			$this->Error('Unsupported image type: '.$type);
1501
+    		}
1433 1502
     		$info = $this->$mtd($file);
1434 1503
     		$info['i'] = count($this->images)+1;
1435 1504
     		$this->images[$file] = $info;
1505
+    	} else {
1506
+    	    		$info = $this->images[$file];
1436 1507
     	}
1437
-    	else
1438
-    		$info = $this->images[$file];
1439 1508
     
1440 1509
     	// Automatic width and height calculation if needed
1441 1510
     	if($w==0 && $h==0)
@@ -1444,14 +1513,18 @@  discard block
 block discarded – undo
1444 1513
     		$w = -96;
1445 1514
     		$h = -96;
1446 1515
     	}
1447
-    	if($w<0)
1448
-    		$w = -$info['w']*72/$w/$this->k;
1449
-    	if($h<0)
1450
-    		$h = -$info['h']*72/$h/$this->k;
1451
-    	if($w==0)
1452
-    		$w = $h*$info['w']/$info['h'];
1453
-    	if($h==0)
1454
-    		$h = $w*$info['h']/$info['w'];
1516
+    	if($w<0) {
1517
+    	    		$w = -$info['w']*72/$w/$this->k;
1518
+    	}
1519
+    	if($h<0) {
1520
+    	    		$h = -$info['h']*72/$h/$this->k;
1521
+    	}
1522
+    	if($w==0) {
1523
+    	    		$w = $h*$info['w']/$info['h'];
1524
+    	}
1525
+    	if($h==0) {
1526
+    	    		$h = $w*$info['h']/$info['w'];
1527
+    	}
1455 1528
     
1456 1529
     	// Flowing mode
1457 1530
     	if($y===null)
@@ -1467,11 +1540,13 @@  discard block
 block discarded – undo
1467 1540
     		$this->y += $h;
1468 1541
     	}
1469 1542
     
1470
-    	if($x===null)
1471
-    		$x = $this->x;
1543
+    	if($x===null) {
1544
+    	    		$x = $this->x;
1545
+    	}
1472 1546
     	$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']));
1473
-    	if($link)
1474
-    		$this->Link($x,$y,$w,$h,$link);
1547
+    	if($link) {
1548
+    	    		$this->Link($x,$y,$w,$h,$link);
1549
+    	}
1475 1550
     }
1476 1551
     
1477 1552
     /**
@@ -1512,10 +1587,11 @@  discard block
 block discarded – undo
1512 1587
     public function SetX(float $x) : void
1513 1588
     {
1514 1589
     	// Set x position
1515
-    	if($x>=0)
1516
-    		$this->x = $x;
1517
-    	else
1518
-    		$this->x = $this->w+$x;
1590
+    	if($x>=0) {
1591
+    	    		$this->x = $x;
1592
+    	} else {
1593
+    	    		$this->x = $this->w+$x;
1594
+    	}
1519 1595
     }
1520 1596
 
1521 1597
     /**
@@ -1537,12 +1613,14 @@  discard block
 block discarded – undo
1537 1613
     public function SetY(float $y, bool $resetX=true) : void
1538 1614
     {
1539 1615
     	// Set y position and optionally reset x
1540
-    	if($y>=0)
1541
-    		$this->y = $y;
1542
-    	else
1543
-    		$this->y = $this->h+$y;
1544
-    	if($resetX)
1545
-    		$this->x = $this->lMargin;
1616
+    	if($y>=0) {
1617
+    	    		$this->y = $y;
1618
+    	} else {
1619
+    	    		$this->y = $this->h+$y;
1620
+    	}
1621
+    	if($resetX) {
1622
+    	    		$this->x = $this->lMargin;
1623
+    	}
1546 1624
     }
1547 1625
     
1548 1626
     /**
@@ -1587,10 +1665,12 @@  discard block
 block discarded – undo
1587 1665
     		$dest = $name;
1588 1666
     		$name = $tmp;
1589 1667
     	}
1590
-    	if($dest=='')
1591
-    		$dest = 'I';
1592
-    	if($name=='')
1593
-    		$name = 'doc.pdf';
1668
+    	if($dest=='') {
1669
+    	    		$dest = 'I';
1670
+    	}
1671
+    	if($name=='') {
1672
+    	    		$name = 'doc.pdf';
1673
+    	}
1594 1674
     	switch(strtoupper($dest))
1595 1675
     	{
1596 1676
     		case 'I':
@@ -1617,8 +1697,9 @@  discard block
 block discarded – undo
1617 1697
     			break;
1618 1698
     		case 'F':
1619 1699
     			// Save to local file
1620
-    			if(!file_put_contents($name,$this->buffer))
1621
-    				$this->Error('Unable to create output file: '.$name);
1700
+    			if(!file_put_contents($name,$this->buffer)) {
1701
+    			    				$this->Error('Unable to create output file: '.$name);
1702
+    			}
1622 1703
     			break;
1623 1704
     		case 'S':
1624 1705
     			// Return as a string
@@ -1635,8 +1716,9 @@  discard block
 block discarded – undo
1635 1716
     protected function _dochecks() : void
1636 1717
     {
1637 1718
     	// Check mbstring overloading
1638
-    	if(ini_get('mbstring.func_overload') & 2)
1639
-    		$this->Error('mbstring overloading must be disabled');
1719
+    	if(ini_get('mbstring.func_overload') & 2) {
1720
+    	    		$this->Error('mbstring overloading must be disabled');
1721
+    	}
1640 1722
     }
1641 1723
 
1642 1724
     /**
@@ -1648,8 +1730,9 @@  discard block
 block discarded – undo
1648 1730
     	{
1649 1731
     	    $file = '';
1650 1732
     	    $line = 0;
1651
-    		if(headers_sent($file,$line))
1652
-    			$this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)");
1733
+    		if(headers_sent($file,$line)) {
1734
+    		    			$this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)");
1735
+    		}
1653 1736
     	}
1654 1737
     	if(ob_get_length())
1655 1738
     	{
@@ -1658,9 +1741,9 @@  discard block
 block discarded – undo
1658 1741
     		{
1659 1742
     			// It contains only a UTF-8 BOM and/or whitespace, let's clean it
1660 1743
     			ob_clean();
1744
+    		} else {
1745
+    		    			$this->Error("Some data has already been output, can't send PDF file");
1661 1746
     		}
1662
-    		else
1663
-    			$this->Error("Some data has already been output, can't send PDF file");
1664 1747
     	}
1665 1748
     }
1666 1749
     
@@ -1674,17 +1757,18 @@  discard block
 block discarded – undo
1674 1757
     	if(is_string($size))
1675 1758
     	{
1676 1759
     		$size = strtolower($size);
1677
-    		if(!isset($this->StdPageSizes[$size]))
1678
-    			$this->Error('Unknown page size: '.$size);
1760
+    		if(!isset($this->StdPageSizes[$size])) {
1761
+    		    			$this->Error('Unknown page size: '.$size);
1762
+    		}
1679 1763
     		$a = $this->StdPageSizes[$size];
1680 1764
     		return array($a[0]/$this->k, $a[1]/$this->k);
1681
-    	}
1682
-    	else
1765
+    	} else
1683 1766
     	{
1684
-    		if($size[0]>$size[1])
1685
-    			return array($size[1], $size[0]);
1686
-    		else
1687
-    			return $size;
1767
+    		if($size[0]>$size[1]) {
1768
+    		    			return array($size[1], $size[0]);
1769
+    		} else {
1770
+    		    			return $size;
1771
+    		}
1688 1772
     	}
1689 1773
     }
1690 1774
     
@@ -1703,14 +1787,16 @@  discard block
 block discarded – undo
1703 1787
     	$this->y = $this->tMargin;
1704 1788
     	$this->FontFamily = '';
1705 1789
     	// Check page size and orientation
1706
-    	if($orientation=='')
1707
-    		$orientation = $this->DefOrientation;
1708
-    	else
1709
-    		$orientation = strtoupper($orientation[0]);
1710
-    	if($size=='')
1711
-    		$size = $this->DefPageSize;
1712
-    	else
1713
-    		$size = $this->_getpagesize($size);
1790
+    	if($orientation=='') {
1791
+    	    		$orientation = $this->DefOrientation;
1792
+    	} else {
1793
+    	    		$orientation = strtoupper($orientation[0]);
1794
+    	}
1795
+    	if($size=='') {
1796
+    	    		$size = $this->DefPageSize;
1797
+    	} else {
1798
+    	    		$size = $this->_getpagesize($size);
1799
+    	}
1714 1800
     	if($orientation!=$this->CurOrientation || $size[0]!=$this->CurPageSize[0] || $size[1]!=$this->CurPageSize[1])
1715 1801
     	{
1716 1802
     		// New size or orientation
@@ -1718,8 +1804,7 @@  discard block
 block discarded – undo
1718 1804
     		{
1719 1805
     			$this->w = $size[0];
1720 1806
     			$this->h = $size[1];
1721
-    		}
1722
-    		else
1807
+    		} else
1723 1808
     		{
1724 1809
     			$this->w = $size[1];
1725 1810
     			$this->h = $size[0];
@@ -1730,12 +1815,14 @@  discard block
 block discarded – undo
1730 1815
     		$this->CurOrientation = $orientation;
1731 1816
     		$this->CurPageSize = $size;
1732 1817
     	}
1733
-    	if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1])
1734
-    		$this->PageInfo[$this->page]['size'] = array($this->wPt, $this->hPt);
1818
+    	if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1]) {
1819
+    	    		$this->PageInfo[$this->page]['size'] = array($this->wPt, $this->hPt);
1820
+    	}
1735 1821
     	if($rotation!=0)
1736 1822
     	{
1737
-    		if($rotation%90!=0)
1738
-    			$this->Error('Incorrect rotation value: '.$rotation);
1823
+    		if($rotation%90!=0) {
1824
+    		    			$this->Error('Incorrect rotation value: '.$rotation);
1825
+    		}
1739 1826
     		$this->CurRotation = $rotation;
1740 1827
     		$this->PageInfo[$this->page]['rotation'] = $rotation;
1741 1828
     	}
@@ -1790,8 +1877,9 @@  discard block
 block discarded – undo
1790 1877
     	$nb = strlen($s);
1791 1878
     	for($i=0;$i<$nb;$i++)
1792 1879
     	{
1793
-    		if(ord($s[$i])>127)
1794
-    			return false;
1880
+    		if(ord($s[$i])>127) {
1881
+    		    			return false;
1882
+    		}
1795 1883
     	}
1796 1884
     	return true;
1797 1885
     }
@@ -1805,14 +1893,17 @@  discard block
 block discarded – undo
1805 1893
     protected function _httpencode(string $param, string $value, bool $isUTF8) : string
1806 1894
     {
1807 1895
     	// Encode HTTP header field parameter
1808
-    	if($this->_isascii($value))
1809
-    		return $param.'="'.$value.'"';
1810
-    	if(!$isUTF8)
1811
-    		$value = utf8_encode($value);
1812
-    	if(strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')!==false)
1813
-    		return $param.'="'.rawurlencode($value).'"';
1814
-    	else
1815
-    		return $param."*=UTF-8''".rawurlencode($value);
1896
+    	if($this->_isascii($value)) {
1897
+    	    		return $param.'="'.$value.'"';
1898
+    	}
1899
+    	if(!$isUTF8) {
1900
+    	    		$value = utf8_encode($value);
1901
+    	}
1902
+    	if(strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')!==false) {
1903
+    	    		return $param.'="'.rawurlencode($value).'"';
1904
+    	} else {
1905
+    	    		return $param."*=UTF-8''".rawurlencode($value);
1906
+    	}
1816 1907
     }
1817 1908
     
1818 1909
     /**
@@ -1836,15 +1927,13 @@  discard block
 block discarded – undo
1836 1927
     			$c3 = ord($s[$i++]);
1837 1928
     			$res .= chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2));
1838 1929
     			$res .= chr((($c2 & 0x03)<<6) + ($c3 & 0x3F));
1839
-    		}
1840
-    		elseif($c1>=192)
1930
+    		} elseif($c1>=192)
1841 1931
     		{
1842 1932
     			// 2-byte character
1843 1933
     			$c2 = ord($s[$i++]);
1844 1934
     			$res .= chr(($c1 & 0x1C)>>2);
1845 1935
     			$res .= chr((($c1 & 0x03)<<6) + ($c2 & 0x3F));
1846
-    		}
1847
-    		else
1936
+    		} else
1848 1937
     		{
1849 1938
     			// Single-byte character
1850 1939
     			$res .= "\0".chr($c1);
@@ -1861,10 +1950,11 @@  discard block
 block discarded – undo
1861 1950
     protected function _escape(string $s) : string
1862 1951
     {
1863 1952
     	// Escape special characters
1864
-    	if(strpos($s,'(')!==false || strpos($s,')')!==false || strpos($s,'\\')!==false || strpos($s,"\r")!==false)
1865
-    		return str_replace(array('\\','(',')',"\r"), array('\\\\','\\(','\\)','\\r'), $s);
1866
-    	else
1867
-    		return $s;
1953
+    	if(strpos($s,'(')!==false || strpos($s,')')!==false || strpos($s,'\\')!==false || strpos($s,"\r")!==false) {
1954
+    	    		return str_replace(array('\\','(',')',"\r"), array('\\\\','\\(','\\)','\\r'), $s);
1955
+    	} else {
1956
+    	    		return $s;
1957
+    	}
1868 1958
     }
1869 1959
     
1870 1960
     /**
@@ -1875,8 +1965,9 @@  discard block
 block discarded – undo
1875 1965
     protected function _textstring(string $s) : string
1876 1966
     {
1877 1967
     	// Format a text string
1878
-    	if(!$this->_isascii($s))
1879
-    		$s = $this->_UTF8toUTF16($s);
1968
+    	if(!$this->_isascii($s)) {
1969
+    	    		$s = $this->_UTF8toUTF16($s);
1970
+    	}
1880 1971
     	return '('.$this->_escape($s).')';
1881 1972
     }
1882 1973
     
@@ -1905,16 +1996,19 @@  discard block
 block discarded – undo
1905 1996
     {
1906 1997
     	// Extract info from a JPEG file
1907 1998
     	$a = getimagesize($file);
1908
-    	if(!$a)
1909
-    		$this->Error('Missing or incorrect image file: '.$file);
1910
-    	if($a[2]!=2)
1911
-    		$this->Error('Not a JPEG file: '.$file);
1912
-    	if(!isset($a['channels']) || $a['channels']==3)
1913
-    		$colspace = 'DeviceRGB';
1914
-    	elseif($a['channels']==4)
1915
-    		$colspace = 'DeviceCMYK';
1916
-    	else
1917
-    		$colspace = 'DeviceGray';
1999
+    	if(!$a) {
2000
+    	    		$this->Error('Missing or incorrect image file: '.$file);
2001
+    	}
2002
+    	if($a[2]!=2) {
2003
+    	    		$this->Error('Not a JPEG file: '.$file);
2004
+    	}
2005
+    	if(!isset($a['channels']) || $a['channels']==3) {
2006
+    	    		$colspace = 'DeviceRGB';
2007
+    	} elseif($a['channels']==4) {
2008
+    	    		$colspace = 'DeviceCMYK';
2009
+    	} else {
2010
+    	    		$colspace = 'DeviceGray';
2011
+    	}
1918 2012
     	$bpc = isset($a['bits']) ? $a['bits'] : 8;
1919 2013
     	$data = file_get_contents($file);
1920 2014
     	return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data);
@@ -1929,8 +2023,9 @@  discard block
 block discarded – undo
1929 2023
     {
1930 2024
     	// Extract info from a PNG file
1931 2025
     	$f = fopen($file,'rb');
1932
-    	if(!$f)
1933
-    		$this->Error('Can\'t open image file: '.$file);
2026
+    	if(!$f) {
2027
+    	    		$this->Error('Can\'t open image file: '.$file);
2028
+    	}
1934 2029
     	$info = $this->_parsepngstream($f,$file);
1935 2030
     	fclose($f);
1936 2031
     	return $info;
@@ -1945,34 +2040,41 @@  discard block
 block discarded – undo
1945 2040
     protected function _parsepngstream($f, string $file) : array
1946 2041
     {
1947 2042
     	// Check signature
1948
-    	if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10))
1949
-    		$this->Error('Not a PNG file: '.$file);
2043
+    	if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) {
2044
+    	    		$this->Error('Not a PNG file: '.$file);
2045
+    	}
1950 2046
     
1951 2047
     	// Read header chunk
1952 2048
     	$this->_readstream($f,4);
1953
-    	if($this->_readstream($f,4)!='IHDR')
1954
-    		$this->Error('Incorrect PNG file: '.$file);
2049
+    	if($this->_readstream($f,4)!='IHDR') {
2050
+    	    		$this->Error('Incorrect PNG file: '.$file);
2051
+    	}
1955 2052
     	$w = $this->_readint($f);
1956 2053
     	$h = $this->_readint($f);
1957 2054
     	$bpc = ord($this->_readstream($f,1));
1958
-    	if($bpc>8)
1959
-    		$this->Error('16-bit depth not supported: '.$file);
2055
+    	if($bpc>8) {
2056
+    	    		$this->Error('16-bit depth not supported: '.$file);
2057
+    	}
1960 2058
     	$ct = ord($this->_readstream($f,1));
1961 2059
     	$colspace = '';
1962
-    	if($ct==0 || $ct==4)
1963
-    		$colspace = 'DeviceGray';
1964
-    	elseif($ct==2 || $ct==6)
1965
-    		$colspace = 'DeviceRGB';
1966
-    	elseif($ct==3)
1967
-    		$colspace = 'Indexed';
1968
-    	else
1969
-    		$this->Error('Unknown color type: '.$file);
1970
-    	if(ord($this->_readstream($f,1))!=0)
1971
-    		$this->Error('Unknown compression method: '.$file);
1972
-    	if(ord($this->_readstream($f,1))!=0)
1973
-    		$this->Error('Unknown filter method: '.$file);
1974
-    	if(ord($this->_readstream($f,1))!=0)
1975
-    		$this->Error('Interlacing not supported: '.$file);
2060
+    	if($ct==0 || $ct==4) {
2061
+    	    		$colspace = 'DeviceGray';
2062
+    	} elseif($ct==2 || $ct==6) {
2063
+    	    		$colspace = 'DeviceRGB';
2064
+    	} elseif($ct==3) {
2065
+    	    		$colspace = 'Indexed';
2066
+    	} else {
2067
+    	    		$this->Error('Unknown color type: '.$file);
2068
+    	}
2069
+    	if(ord($this->_readstream($f,1))!=0) {
2070
+    	    		$this->Error('Unknown compression method: '.$file);
2071
+    	}
2072
+    	if(ord($this->_readstream($f,1))!=0) {
2073
+    	    		$this->Error('Unknown filter method: '.$file);
2074
+    	}
2075
+    	if(ord($this->_readstream($f,1))!=0) {
2076
+    	    		$this->Error('Interlacing not supported: '.$file);
2077
+    	}
1976 2078
     	$this->_readstream($f,4);
1977 2079
     	$dp = '/Predictor 15 /Colors '.($colspace=='DeviceRGB' ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w;
1978 2080
     
@@ -1989,44 +2091,45 @@  discard block
 block discarded – undo
1989 2091
     			// Read palette
1990 2092
     			$pal = $this->_readstream($f,$n);
1991 2093
     			$this->_readstream($f,4);
1992
-    		}
1993
-    		elseif($type=='tRNS')
2094
+    		} elseif($type=='tRNS')
1994 2095
     		{
1995 2096
     			// Read transparency info
1996 2097
     			$t = $this->_readstream($f,$n);
1997
-    			if($ct==0)
1998
-    				$trns = array(ord(substr($t,1,1)));
1999
-    			elseif($ct==2)
2000
-    				$trns = array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1)));
2001
-    			else
2098
+    			if($ct==0) {
2099
+    			    				$trns = array(ord(substr($t,1,1)));
2100
+    			} elseif($ct==2) {
2101
+    			    				$trns = array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1)));
2102
+    			} else
2002 2103
     			{
2003 2104
     				$pos = strpos($t,chr(0));
2004
-    				if($pos!==false)
2005
-    					$trns = array($pos);
2105
+    				if($pos!==false) {
2106
+    				    					$trns = array($pos);
2107
+    				}
2006 2108
     			}
2007 2109
     			$this->_readstream($f,4);
2008
-    		}
2009
-    		elseif($type=='IDAT')
2110
+    		} elseif($type=='IDAT')
2010 2111
     		{
2011 2112
     			// Read image data block
2012 2113
     			$data .= $this->_readstream($f,$n);
2013 2114
     			$this->_readstream($f,4);
2115
+    		} elseif($type=='IEND') {
2116
+    		    			break;
2117
+    		} else {
2118
+    		    			$this->_readstream($f,$n+4);
2014 2119
     		}
2015
-    		elseif($type=='IEND')
2016
-    			break;
2017
-    		else
2018
-    			$this->_readstream($f,$n+4);
2019 2120
     	}
2020 2121
     	while($n);
2021 2122
     
2022
-    	if($colspace=='Indexed' && empty($pal))
2023
-    		$this->Error('Missing palette in '.$file);
2123
+    	if($colspace=='Indexed' && empty($pal)) {
2124
+    	    		$this->Error('Missing palette in '.$file);
2125
+    	}
2024 2126
     	$info = array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'dp'=>$dp, 'pal'=>$pal, 'trns'=>$trns);
2025 2127
     	if($ct>=4)
2026 2128
     	{
2027 2129
     		// Extract alpha channel
2028
-    		if(!function_exists('gzuncompress'))
2029
-    			$this->Error('Zlib not available, can\'t handle alpha channel: '.$file);
2130
+    		if(!function_exists('gzuncompress')) {
2131
+    		    			$this->Error('Zlib not available, can\'t handle alpha channel: '.$file);
2132
+    		}
2030 2133
     		$data = gzuncompress($data);
2031 2134
     		$color = '';
2032 2135
     		$alpha = '';
@@ -2043,8 +2146,7 @@  discard block
 block discarded – undo
2043 2146
     				$color .= preg_replace('/(.)./s','$1',$line);
2044 2147
     				$alpha .= preg_replace('/.(.)/s','$1',$line);
2045 2148
     			}
2046
-    		}
2047
-    		else
2149
+    		} else
2048 2150
     		{
2049 2151
     			// RGB image
2050 2152
     			$len = 4*$w;
@@ -2062,8 +2164,9 @@  discard block
 block discarded – undo
2062 2164
     		$data = gzcompress($color);
2063 2165
     		$info['smask'] = gzcompress($alpha);
2064 2166
     		$this->WithAlpha = true;
2065
-    		if($this->PDFVersion<'1.4')
2066
-    			$this->PDFVersion = '1.4';
2167
+    		if($this->PDFVersion<'1.4') {
2168
+    		    			$this->PDFVersion = '1.4';
2169
+    		}
2067 2170
     	}
2068 2171
     	$info['data'] = $data;
2069 2172
     	return $info;
@@ -2082,13 +2185,15 @@  discard block
 block discarded – undo
2082 2185
     	while($n>0 && !feof($f))
2083 2186
     	{
2084 2187
     		$s = fread($f,$n);
2085
-    		if($s===false)
2086
-    			$this->Error('Error while reading stream');
2188
+    		if($s===false) {
2189
+    		    			$this->Error('Error while reading stream');
2190
+    		}
2087 2191
     		$n -= strlen($s);
2088 2192
     		$res .= $s;
2089 2193
     	}
2090
-    	if($n>0)
2091
-    		$this->Error('Unexpected end of stream');
2194
+    	if($n>0) {
2195
+    	    		$this->Error('Unexpected end of stream');
2196
+    	}
2092 2197
     	return $res;
2093 2198
     }
2094 2199
     
@@ -2112,21 +2217,25 @@  discard block
 block discarded – undo
2112 2217
     protected function _parsegif(string $file) : array
2113 2218
     {
2114 2219
     	// Extract info from a GIF file (via PNG conversion)
2115
-    	if(!function_exists('imagepng'))
2116
-    		$this->Error('GD extension is required for GIF support');
2117
-    	if(!function_exists('imagecreatefromgif'))
2118
-    		$this->Error('GD has no GIF read support');
2220
+    	if(!function_exists('imagepng')) {
2221
+    	    		$this->Error('GD extension is required for GIF support');
2222
+    	}
2223
+    	if(!function_exists('imagecreatefromgif')) {
2224
+    	    		$this->Error('GD has no GIF read support');
2225
+    	}
2119 2226
     	$im = imagecreatefromgif($file);
2120
-    	if(!$im)
2121
-    		$this->Error('Missing or incorrect image file: '.$file);
2227
+    	if(!$im) {
2228
+    	    		$this->Error('Missing or incorrect image file: '.$file);
2229
+    	}
2122 2230
     	imageinterlace($im,0);
2123 2231
     	ob_start();
2124 2232
     	imagepng($im);
2125 2233
     	$data = ob_get_clean();
2126 2234
     	imagedestroy($im);
2127 2235
     	$f = fopen('php://temp','rb+');
2128
-    	if(!$f)
2129
-    		$this->Error('Unable to create memory stream');
2236
+    	if(!$f) {
2237
+    	    		$this->Error('Unable to create memory stream');
2238
+    	}
2130 2239
     	fwrite($f,$data);
2131 2240
     	rewind($f);
2132 2241
     	$info = $this->_parsepngstream($f,$file);
@@ -2141,14 +2250,15 @@  discard block
 block discarded – undo
2141 2250
     protected function _out(string $s) : void
2142 2251
     {
2143 2252
     	// Add a line to the document
2144
-    	if($this->state==2)
2145
-    		$this->pages[$this->page] .= $s."\n";
2146
-    	elseif($this->state==1)
2147
-    		$this->_put($s);
2148
-    	elseif($this->state==0)
2149
-    		$this->Error('No page has been added yet');
2150
-    	elseif($this->state==3)
2151
-    		$this->Error('The document is closed');
2253
+    	if($this->state==2) {
2254
+    	    		$this->pages[$this->page] .= $s."\n";
2255
+    	} elseif($this->state==1) {
2256
+    	    		$this->_put($s);
2257
+    	} elseif($this->state==0) {
2258
+    	    		$this->Error('No page has been added yet');
2259
+    	} elseif($this->state==3) {
2260
+    	    		$this->Error('The document is closed');
2261
+    	}
2152 2262
     }
2153 2263
     
2154 2264
     /**
@@ -2176,8 +2286,9 @@  discard block
 block discarded – undo
2176 2286
     protected function _newobj(?int $n=null) : void
2177 2287
     {
2178 2288
     	// Begin a new object
2179
-    	if($n===null)
2180
-    		$n = ++$this->n;
2289
+    	if($n===null) {
2290
+    	    		$n = ++$this->n;
2291
+    	}
2181 2292
     	$this->offsets[$n] = $this->_getoffset();
2182 2293
     	$this->_put($n.' 0 obj');
2183 2294
     }
@@ -2203,9 +2314,9 @@  discard block
 block discarded – undo
2203 2314
     	{
2204 2315
     		$entries = '/Filter /FlateDecode ';
2205 2316
     		$data = gzcompress($data);
2317
+    	} else {
2318
+    	    		$entries = '';
2206 2319
     	}
2207
-    	else
2208
-    		$entries = '';
2209 2320
     	$entries .= '/Length '.strlen($data);
2210 2321
     	$this->_newobj();
2211 2322
     	$this->_put('<<'.$entries.'>>');
@@ -2222,10 +2333,12 @@  discard block
 block discarded – undo
2222 2333
     	$this->_newobj();
2223 2334
     	$this->_put('<</Type /Page');
2224 2335
     	$this->_put('/Parent 1 0 R');
2225
-    	if(isset($this->PageInfo[$n]['size']))
2226
-    		$this->_put(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageInfo[$n]['size'][0],$this->PageInfo[$n]['size'][1]));
2227
-    	if(isset($this->PageInfo[$n]['rotation']))
2228
-    		$this->_put('/Rotate '.$this->PageInfo[$n]['rotation']);
2336
+    	if(isset($this->PageInfo[$n]['size'])) {
2337
+    	    		$this->_put(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageInfo[$n]['size'][0],$this->PageInfo[$n]['size'][1]));
2338
+    	}
2339
+    	if(isset($this->PageInfo[$n]['rotation'])) {
2340
+    	    		$this->_put('/Rotate '.$this->PageInfo[$n]['rotation']);
2341
+    	}
2229 2342
     	$this->_put('/Resources 2 0 R');
2230 2343
     	if(isset($this->PageLinks[$n]))
2231 2344
     	{
@@ -2235,27 +2348,30 @@  discard block
 block discarded – undo
2235 2348
     		{
2236 2349
     			$rect = sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]);
2237 2350
     			$annots .= '<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] ';
2238
-    			if(is_string($pl[4]))
2239
-    				$annots .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
2240
-    			else
2351
+    			if(is_string($pl[4])) {
2352
+    			    				$annots .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>';
2353
+    			} else
2241 2354
     			{
2242 2355
     				$l = $this->links[$pl[4]];
2243
-    				if(isset($this->PageInfo[$l[0]]['size']))
2244
-    					$h = $this->PageInfo[$l[0]]['size'][1];
2245
-    				else
2246
-    					$h = ($this->DefOrientation=='P') ? $this->DefPageSize[1]*$this->k : $this->DefPageSize[0]*$this->k;
2356
+    				if(isset($this->PageInfo[$l[0]]['size'])) {
2357
+    				    					$h = $this->PageInfo[$l[0]]['size'][1];
2358
+    				} else {
2359
+    				    					$h = ($this->DefOrientation=='P') ? $this->DefPageSize[1]*$this->k : $this->DefPageSize[0]*$this->k;
2360
+    				}
2247 2361
     				$annots .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',$this->PageInfo[$l[0]]['n'],$h-$l[1]*$this->k);
2248 2362
     			}
2249 2363
     		}
2250 2364
     		$this->_put($annots.']');
2251 2365
     	}
2252
-    	if($this->WithAlpha)
2253
-    		$this->_put('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>');
2366
+    	if($this->WithAlpha) {
2367
+    	    		$this->_put('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>');
2368
+    	}
2254 2369
     	$this->_put('/Contents '.($this->n+1).' 0 R>>');
2255 2370
     	$this->_put('endobj');
2256 2371
     	// Page content
2257
-    	if(!empty($this->AliasNbPages))
2258
-    		$this->pages[$n] = str_replace($this->AliasNbPages, strval($this->page), $this->pages[$n]);
2372
+    	if(!empty($this->AliasNbPages)) {
2373
+    	    		$this->pages[$n] = str_replace($this->AliasNbPages, strval($this->page), $this->pages[$n]);
2374
+    	}
2259 2375
     	$this->_putstreamobject($this->pages[$n]);
2260 2376
     }
2261 2377
     
@@ -2265,24 +2381,26 @@  discard block
 block discarded – undo
2265 2381
     protected function _putpages() : void
2266 2382
     {
2267 2383
     	$nb = $this->page;
2268
-    	for($n=1;$n<=$nb;$n++)
2269
-    		$this->PageInfo[$n]['n'] = $this->n+1+2*($n-1);
2270
-    	for($n=1;$n<=$nb;$n++)
2271
-    		$this->_putpage($n);
2384
+    	for($n=1;$n<=$nb;$n++) {
2385
+    	    		$this->PageInfo[$n]['n'] = $this->n+1+2*($n-1);
2386
+    	}
2387
+    	for($n=1;$n<=$nb;$n++) {
2388
+    	    		$this->_putpage($n);
2389
+    	}
2272 2390
     	// Pages root
2273 2391
     	$this->_newobj(1);
2274 2392
     	$this->_put('<</Type /Pages');
2275 2393
     	$kids = '/Kids [';
2276
-    	for($n=1;$n<=$nb;$n++)
2277
-    		$kids .= $this->PageInfo[$n]['n'].' 0 R ';
2394
+    	for($n=1;$n<=$nb;$n++) {
2395
+    	    		$kids .= $this->PageInfo[$n]['n'].' 0 R ';
2396
+    	}
2278 2397
     	$this->_put($kids.']');
2279 2398
     	$this->_put('/Count '.$nb);
2280 2399
     	if($this->DefOrientation=='P')
2281 2400
     	{
2282 2401
     		$w = $this->DefPageSize[0];
2283 2402
     		$h = $this->DefPageSize[1];
2284
-    	}
2285
-    	else
2403
+    	} else
2286 2404
     	{
2287 2405
     		$w = $this->DefPageSize[1];
2288 2406
     		$h = $this->DefPageSize[0];
@@ -2303,17 +2421,21 @@  discard block
 block discarded – undo
2303 2421
     		$this->_newobj();
2304 2422
     		$this->FontFiles[$file]['n'] = $this->n;
2305 2423
     		$font = file_get_contents($this->fontpath.$file,true);
2306
-    		if(!$font)
2307
-    			$this->Error('Font file not found: '.$file);
2424
+    		if(!$font) {
2425
+    		    			$this->Error('Font file not found: '.$file);
2426
+    		}
2308 2427
     		$compressed = (substr($file,-2)=='.z');
2309
-    		if(!$compressed && isset($info['length2']))
2310
-    			$font = substr($font,6,$info['length1']).substr($font,6+$info['length1']+6,$info['length2']);
2428
+    		if(!$compressed && isset($info['length2'])) {
2429
+    		    			$font = substr($font,6,$info['length1']).substr($font,6+$info['length1']+6,$info['length2']);
2430
+    		}
2311 2431
     		$this->_put('<</Length '.strlen($font));
2312
-    		if($compressed)
2313
-    			$this->_put('/Filter /FlateDecode');
2432
+    		if($compressed) {
2433
+    		    			$this->_put('/Filter /FlateDecode');
2434
+    		}
2314 2435
     		$this->_put('/Length1 '.$info['length1']);
2315
-    		if(isset($info['length2']))
2316
-    			$this->_put('/Length2 '.$info['length2'].' /Length3 0');
2436
+    		if(isset($info['length2'])) {
2437
+    		    			$this->_put('/Length2 '.$info['length2'].' /Length3 0');
2438
+    		}
2317 2439
     		$this->_put('>>');
2318 2440
     		$this->_putstream($font);
2319 2441
     		$this->_put('endobj');
@@ -2335,10 +2457,11 @@  discard block
 block discarded – undo
2335 2457
     		$cmapkey = '';
2336 2458
     		if(isset($font['uv']))
2337 2459
     		{
2338
-    			if(isset($font['enc']))
2339
-    				$cmapkey = $font['enc'];
2340
-    			else
2341
-    				$cmapkey = $font['name'];
2460
+    			if(isset($font['enc'])) {
2461
+    			    				$cmapkey = $font['enc'];
2462
+    			} else {
2463
+    			    				$cmapkey = $font['name'];
2464
+    			}
2342 2465
     			if(!isset($this->cmaps[$cmapkey]))
2343 2466
     			{
2344 2467
     				$cmap = $this->_tounicodecmap($font['uv']);
@@ -2350,8 +2473,9 @@  discard block
 block discarded – undo
2350 2473
     		$this->fonts[$k]['n'] = $this->n+1;
2351 2474
     		$type = $font['type'];
2352 2475
     		$name = $font['name'];
2353
-    		if($font['subsetted'])
2354
-    			$name = 'AAAAAA+'.$name;
2476
+    		if($font['subsetted']) {
2477
+    		    			$name = 'AAAAAA+'.$name;
2478
+    		}
2355 2479
     		if($type=='Core')
2356 2480
     		{
2357 2481
     			// Core font
@@ -2359,14 +2483,15 @@  discard block
 block discarded – undo
2359 2483
     			$this->_put('<</Type /Font');
2360 2484
     			$this->_put('/BaseFont /'.$name);
2361 2485
     			$this->_put('/Subtype /Type1');
2362
-    			if($name!='Symbol' && $name!='ZapfDingbats')
2363
-    				$this->_put('/Encoding /WinAnsiEncoding');
2364
-    			if(isset($font['uv']))
2365
-    				$this->_put('/ToUnicode '.$this->cmaps[$cmapkey].' 0 R');
2486
+    			if($name!='Symbol' && $name!='ZapfDingbats') {
2487
+    			    				$this->_put('/Encoding /WinAnsiEncoding');
2488
+    			}
2489
+    			if(isset($font['uv'])) {
2490
+    			    				$this->_put('/ToUnicode '.$this->cmaps[$cmapkey].' 0 R');
2491
+    			}
2366 2492
     			$this->_put('>>');
2367 2493
     			$this->_put('endobj');
2368
-    		}
2369
-    		elseif($type=='Type1' || $type=='TrueType')
2494
+    		} elseif($type=='Type1' || $type=='TrueType')
2370 2495
     		{
2371 2496
     			// Additional Type1 or TrueType/OpenType font
2372 2497
     			$this->_newobj();
@@ -2376,38 +2501,43 @@  discard block
 block discarded – undo
2376 2501
     			$this->_put('/FirstChar 32 /LastChar 255');
2377 2502
     			$this->_put('/Widths '.($this->n+1).' 0 R');
2378 2503
     			$this->_put('/FontDescriptor '.($this->n+2).' 0 R');
2379
-    			if(isset($font['diff']))
2380
-    				$this->_put('/Encoding '.$this->encodings[$font['enc']].' 0 R');
2381
-    			else
2382
-    				$this->_put('/Encoding /WinAnsiEncoding');
2383
-    			if(isset($font['uv']))
2384
-    				$this->_put('/ToUnicode '.$this->cmaps[$cmapkey].' 0 R');
2504
+    			if(isset($font['diff'])) {
2505
+    			    				$this->_put('/Encoding '.$this->encodings[$font['enc']].' 0 R');
2506
+    			} else {
2507
+    			    				$this->_put('/Encoding /WinAnsiEncoding');
2508
+    			}
2509
+    			if(isset($font['uv'])) {
2510
+    			    				$this->_put('/ToUnicode '.$this->cmaps[$cmapkey].' 0 R');
2511
+    			}
2385 2512
     			$this->_put('>>');
2386 2513
     			$this->_put('endobj');
2387 2514
     			// Widths
2388 2515
     			$this->_newobj();
2389 2516
     			$cw = &$font['cw'];
2390 2517
     			$s = '[';
2391
-    			for($i=32;$i<=255;$i++)
2392
-    				$s .= $cw[chr($i)].' ';
2518
+    			for($i=32;$i<=255;$i++) {
2519
+    			    				$s .= $cw[chr($i)].' ';
2520
+    			}
2393 2521
     			$this->_put($s.']');
2394 2522
     			$this->_put('endobj');
2395 2523
     			// Descriptor
2396 2524
     			$this->_newobj();
2397 2525
     			$s = '<</Type /FontDescriptor /FontName /'.$name;
2398
-    			foreach($font['desc'] as $k=>$v)
2399
-    				$s .= ' /'.$k.' '.$v;
2400
-    			if(!empty($font['file']))
2401
-    				$s .= ' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$font['file']]['n'].' 0 R';
2526
+    			foreach($font['desc'] as $k=>$v) {
2527
+    			    				$s .= ' /'.$k.' '.$v;
2528
+    			}
2529
+    			if(!empty($font['file'])) {
2530
+    			    				$s .= ' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$font['file']]['n'].' 0 R';
2531
+    			}
2402 2532
     			$this->_put($s.'>>');
2403 2533
     			$this->_put('endobj');
2404
-    		}
2405
-    		else
2534
+    		} else
2406 2535
     		{
2407 2536
     			// Allow for additional types
2408 2537
     			$mtd = '_put'.strtolower($type);
2409
-    			if(!method_exists($this,$mtd))
2410
-    				$this->Error('Unsupported font type: '.$type);
2538
+    			if(!method_exists($this,$mtd)) {
2539
+    			    				$this->Error('Unsupported font type: '.$type);
2540
+    			}
2411 2541
     			$this->$mtd($font);
2412 2542
     		}
2413 2543
     	}
@@ -2429,8 +2559,7 @@  discard block
 block discarded – undo
2429 2559
     		{
2430 2560
     			$ranges .= sprintf("<%02X> <%02X> <%04X>\n",$c,$c+$v[1]-1,$v[0]);
2431 2561
     			$nbr++;
2432
-    		}
2433
-    		else
2562
+    		} else
2434 2563
     		{
2435 2564
     			$chars .= sprintf("<%02X> <%04X>\n",$c,$v);
2436 2565
     			$nbc++;
@@ -2493,28 +2622,33 @@  discard block
 block discarded – undo
2493 2622
     	$this->_put('/Subtype /Image');
2494 2623
     	$this->_put('/Width '.$info['w']);
2495 2624
     	$this->_put('/Height '.$info['h']);
2496
-    	if($info['cs']=='Indexed')
2497
-    		$this->_put('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]');
2498
-    	else
2625
+    	if($info['cs']=='Indexed') {
2626
+    	    		$this->_put('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]');
2627
+    	} else
2499 2628
     	{
2500 2629
     		$this->_put('/ColorSpace /'.$info['cs']);
2501
-    		if($info['cs']=='DeviceCMYK')
2502
-    			$this->_put('/Decode [1 0 1 0 1 0 1 0]');
2630
+    		if($info['cs']=='DeviceCMYK') {
2631
+    		    			$this->_put('/Decode [1 0 1 0 1 0 1 0]');
2632
+    		}
2503 2633
     	}
2504 2634
     	$this->_put('/BitsPerComponent '.$info['bpc']);
2505
-    	if(isset($info['f']))
2506
-    		$this->_put('/Filter /'.$info['f']);
2507
-    	if(isset($info['dp']))
2508
-    		$this->_put('/DecodeParms <<'.$info['dp'].'>>');
2635
+    	if(isset($info['f'])) {
2636
+    	    		$this->_put('/Filter /'.$info['f']);
2637
+    	}
2638
+    	if(isset($info['dp'])) {
2639
+    	    		$this->_put('/DecodeParms <<'.$info['dp'].'>>');
2640
+    	}
2509 2641
     	if(isset($info['trns']) && is_array($info['trns']))
2510 2642
     	{
2511 2643
     		$trns = '';
2512
-    		for($i=0;$i<count($info['trns']);$i++)
2513
-    			$trns .= $info['trns'][$i].' '.$info['trns'][$i].' ';
2644
+    		for($i=0;$i<count($info['trns']);$i++) {
2645
+    		    			$trns .= $info['trns'][$i].' '.$info['trns'][$i].' ';
2646
+    		}
2514 2647
     		$this->_put('/Mask ['.$trns.']');
2515 2648
     	}
2516
-    	if(isset($info['smask']))
2517
-    		$this->_put('/SMask '.($this->n+1).' 0 R');
2649
+    	if(isset($info['smask'])) {
2650
+    	    		$this->_put('/SMask '.($this->n+1).' 0 R');
2651
+    	}
2518 2652
     	$this->_put('/Length '.strlen($info['data']).'>>');
2519 2653
     	$this->_putstream($info['data']);
2520 2654
     	$this->_put('endobj');
@@ -2526,8 +2660,9 @@  discard block
 block discarded – undo
2526 2660
     		$this->_putimage($smask);
2527 2661
     	}
2528 2662
     	// Palette
2529
-    	if($info['cs']=='Indexed')
2530
-    		$this->_putstreamobject($info['pal']);
2663
+    	if($info['cs']=='Indexed') {
2664
+    	    		$this->_putstreamobject($info['pal']);
2665
+    	}
2531 2666
     }
2532 2667
     
2533 2668
     /**
@@ -2535,8 +2670,9 @@  discard block
 block discarded – undo
2535 2670
      */
2536 2671
     protected function _putxobjectdict() : void
2537 2672
     {
2538
-    	foreach($this->images as $image)
2539
-    		$this->_put('/I'.$image['i'].' '.$image['n'].' 0 R');
2673
+    	foreach($this->images as $image) {
2674
+    	    		$this->_put('/I'.$image['i'].' '.$image['n'].' 0 R');
2675
+    	}
2540 2676
     }
2541 2677
     
2542 2678
     /**
@@ -2546,8 +2682,9 @@  discard block
 block discarded – undo
2546 2682
     {
2547 2683
     	$this->_put('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');
2548 2684
     	$this->_put('/Font <<');
2549
-    	foreach($this->fonts as $font)
2550
-    		$this->_put('/F'.$font['i'].' '.$font['n'].' 0 R');
2685
+    	foreach($this->fonts as $font) {
2686
+    	    		$this->_put('/F'.$font['i'].' '.$font['n'].' 0 R');
2687
+    	}
2551 2688
     	$this->_put('>>');
2552 2689
     	$this->_put('/XObject <<');
2553 2690
     	$this->_putxobjectdict();
@@ -2576,8 +2713,9 @@  discard block
 block discarded – undo
2576 2713
     {
2577 2714
     	$this->metadata['Producer'] = 'FPDF '.FPDF_VERSION;
2578 2715
     	$this->metadata['CreationDate'] = 'D:'.@date('YmdHis');
2579
-    	foreach($this->metadata as $key=>$value)
2580
-    		$this->_put('/'.$key.' '.$this->_textstring($value));
2716
+    	foreach($this->metadata as $key=>$value) {
2717
+    	    		$this->_put('/'.$key.' '.$this->_textstring($value));
2718
+    	}
2581 2719
     }
2582 2720
     
2583 2721
     /**
@@ -2588,20 +2726,22 @@  discard block
 block discarded – undo
2588 2726
     	$n = $this->PageInfo[1]['n'];
2589 2727
     	$this->_put('/Type /Catalog');
2590 2728
     	$this->_put('/Pages 1 0 R');
2591
-    	if($this->ZoomMode=='fullpage')
2592
-    		$this->_put('/OpenAction ['.$n.' 0 R /Fit]');
2593
-    	elseif($this->ZoomMode=='fullwidth')
2594
-    		$this->_put('/OpenAction ['.$n.' 0 R /FitH null]');
2595
-    	elseif($this->ZoomMode=='real')
2596
-    		$this->_put('/OpenAction ['.$n.' 0 R /XYZ null null 1]');
2597
-    	elseif(!is_string($this->ZoomMode))
2598
-    		$this->_put('/OpenAction ['.$n.' 0 R /XYZ null null '.sprintf('%.2F',$this->ZoomMode/100).']');
2599
-    	if($this->LayoutMode=='single')
2600
-    		$this->_put('/PageLayout /SinglePage');
2601
-    	elseif($this->LayoutMode=='continuous')
2602
-    		$this->_put('/PageLayout /OneColumn');
2603
-    	elseif($this->LayoutMode=='two')
2604
-    		$this->_put('/PageLayout /TwoColumnLeft');
2729
+    	if($this->ZoomMode=='fullpage') {
2730
+    	    		$this->_put('/OpenAction ['.$n.' 0 R /Fit]');
2731
+    	} elseif($this->ZoomMode=='fullwidth') {
2732
+    	    		$this->_put('/OpenAction ['.$n.' 0 R /FitH null]');
2733
+    	} elseif($this->ZoomMode=='real') {
2734
+    	    		$this->_put('/OpenAction ['.$n.' 0 R /XYZ null null 1]');
2735
+    	} elseif(!is_string($this->ZoomMode)) {
2736
+    	    		$this->_put('/OpenAction ['.$n.' 0 R /XYZ null null '.sprintf('%.2F',$this->ZoomMode/100).']');
2737
+    	}
2738
+    	if($this->LayoutMode=='single') {
2739
+    	    		$this->_put('/PageLayout /SinglePage');
2740
+    	} elseif($this->LayoutMode=='continuous') {
2741
+    	    		$this->_put('/PageLayout /OneColumn');
2742
+    	} elseif($this->LayoutMode=='two') {
2743
+    	    		$this->_put('/PageLayout /TwoColumnLeft');
2744
+    	}
2605 2745
     }
2606 2746
     
2607 2747
     /**
@@ -2647,8 +2787,9 @@  discard block
 block discarded – undo
2647 2787
     	$this->_put('xref');
2648 2788
     	$this->_put('0 '.($this->n+1));
2649 2789
     	$this->_put('0000000000 65535 f ');
2650
-    	for($i=1;$i<=$this->n;$i++)
2651
-    		$this->_put(sprintf('%010d 00000 n ',$this->offsets[$i]));
2790
+    	for($i=1;$i<=$this->n;$i++) {
2791
+    	    		$this->_put(sprintf('%010d 00000 n ',$this->offsets[$i]));
2792
+    	}
2652 2793
     	// Trailer
2653 2794
     	$this->_put('trailer');
2654 2795
     	$this->_put('<<');
Please login to merge, or discard this patch.