Passed
Push — 1.10.x ( a2cc02...b21e58 )
by Yannick
608:36 queued 565:17
created
main/inc/lib/phpdocx/pdf/include/list_bullet_renderer.cls.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -63,10 +63,10 @@  discard block
 block discarded – undo
63 63
 
64 64
     // Handle list-style-image
65 65
     // If list style image is requested but missing, fall back to predefined types
66
-    if ( $style->list_style_image !== "none" &&
67
-         strcmp($img = $frame->get_image_url(), DOMPDF_LIB_DIR . "/res/broken_image.png") != 0) {
66
+    if ($style->list_style_image !== "none" &&
67
+         strcmp($img = $frame->get_image_url(), DOMPDF_LIB_DIR."/res/broken_image.png") != 0) {
68 68
 
69
-      list($x,$y) = $frame->get_position();
69
+      list($x, $y) = $frame->get_position();
70 70
       
71 71
       //For expected size and aspect, instead of box size, use image natural size scaled to DPI.
72 72
       // Resample the bullet image to be consistent with 'auto' sized images
@@ -75,13 +75,13 @@  discard block
 block discarded – undo
75 75
       //$w = $frame->get_width();
76 76
       //$h = $frame->get_height();
77 77
       list($width, $height) = getimagesize($img);
78
-      $w = (((float)rtrim($width, "px")) * 72) / DOMPDF_DPI;
79
-      $h = (((float)rtrim($height, "px")) * 72) / DOMPDF_DPI;
78
+      $w = (((float) rtrim($width, "px")) * 72) / DOMPDF_DPI;
79
+      $h = (((float) rtrim($height, "px")) * 72) / DOMPDF_DPI;
80 80
       
81 81
       $x -= $w;
82
-      $y -= ($line_height - $font_size)/2; //Reverse hinting of list_bullet_positioner
82
+      $y -= ($line_height - $font_size) / 2; //Reverse hinting of list_bullet_positioner
83 83
 
84
-      $this->_canvas->image( $img, $frame->get_image_ext(), $x, $y, $w, $h);
84
+      $this->_canvas->image($img, $frame->get_image_ext(), $x, $y, $w, $h);
85 85
 
86 86
     } else {
87 87
 
@@ -96,19 +96,19 @@  discard block
 block discarded – undo
96 96
         $fill = true;
97 97
 
98 98
       case "circle":
99
-        list($x,$y) = $frame->get_position();
100
-        $r = ($font_size*(List_Bullet_Frame_Decorator::BULLET_SIZE /*-List_Bullet_Frame_Decorator::BULLET_THICKNESS*/ ))/2;
101
-        $x -= $font_size*(List_Bullet_Frame_Decorator::BULLET_SIZE/2);
102
-        $y += ($font_size*(1-List_Bullet_Frame_Decorator::BULLET_DESCENT))/2;
103
-        $o = $font_size*List_Bullet_Frame_Decorator::BULLET_THICKNESS;
99
+        list($x, $y) = $frame->get_position();
100
+        $r = ($font_size * (List_Bullet_Frame_Decorator::BULLET_SIZE /*-List_Bullet_Frame_Decorator::BULLET_THICKNESS*/)) / 2;
101
+        $x -= $font_size * (List_Bullet_Frame_Decorator::BULLET_SIZE / 2);
102
+        $y += ($font_size * (1 - List_Bullet_Frame_Decorator::BULLET_DESCENT)) / 2;
103
+        $o = $font_size * List_Bullet_Frame_Decorator::BULLET_THICKNESS;
104 104
         $this->_canvas->circle($x, $y, $r, $style->color, $o, null, $fill);
105 105
         break;
106 106
 
107 107
       case "square":
108 108
         list($x, $y) = $frame->get_position();
109
-        $w = $font_size*List_Bullet_Frame_Decorator::BULLET_SIZE;
109
+        $w = $font_size * List_Bullet_Frame_Decorator::BULLET_SIZE;
110 110
         $x -= $w;
111
-        $y += ($font_size*(1-List_Bullet_Frame_Decorator::BULLET_DESCENT-List_Bullet_Frame_Decorator::BULLET_SIZE))/2;
111
+        $y += ($font_size * (1 - List_Bullet_Frame_Decorator::BULLET_DESCENT - List_Bullet_Frame_Decorator::BULLET_SIZE)) / 2;
112 112
         $this->_canvas->filled_rectangle($x, $y, $w, $w, $style->color);
113 113
         break;
114 114
       
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/pdflib_adapter.cls.php 1 patch
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -185,25 +185,25 @@  discard block
 block discarded – undo
185 185
    * @param string $orientation The orientation of the document (either 'landscape' or 'portrait')
186 186
    */
187 187
   function __construct($paper = "letter", $orientation = "portrait") {
188
-    if ( is_array($paper) )
188
+    if (is_array($paper))
189 189
       $size = $paper;
190
-    else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) )
190
+    else if (isset(self::$PAPER_SIZES[mb_strtolower($paper)]))
191 191
       $size = self::$PAPER_SIZES[mb_strtolower($paper)];
192 192
     else
193 193
       $size = self::$PAPER_SIZES["letter"];
194 194
 
195
-    if ( mb_strtolower($orientation) === "landscape" ) {
195
+    if (mb_strtolower($orientation) === "landscape") {
196 196
       $a = $size[3];
197 197
       $size[3] = $size[2];
198 198
       $size[2] = $a;
199 199
     }
200 200
     $this->_width = $size[2] - $size[0];
201
-    $this->_height= $size[3] - $size[1];
201
+    $this->_height = $size[3] - $size[1];
202 202
 
203 203
     $this->_pdf = new PDFLib();
204 204
 
205
-	if ( defined("DOMPDF_PDFLIB_LICENSE") )
206
-      $this->_pdf->set_parameter( "license", DOMPDF_PDFLIB_LICENSE);
205
+	if (defined("DOMPDF_PDFLIB_LICENSE"))
206
+      $this->_pdf->set_parameter("license", DOMPDF_PDFLIB_LICENSE);
207 207
 
208 208
 	$this->_pdf->set_parameter("textformat", "utf8");
209 209
     $this->_pdf->set_parameter("fontwarning", "false");
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
     $this->_pdf->set_info("Creator", "DOMPDF Converter");
212 212
 
213 213
     // Silence pedantic warnings about missing TZ settings
214
-    if ( function_exists("date_default_timezone_get") ) {
214
+    if (function_exists("date_default_timezone_get")) {
215 215
       $tz = @date_default_timezone_get();
216 216
       date_default_timezone_set("UTC");
217 217
       $this->_pdf->set_info("Date", date("Y-m-d"));
@@ -220,11 +220,11 @@  discard block
 block discarded – undo
220 220
       $this->_pdf->set_info("Date", date("Y-m-d"));
221 221
     }
222 222
 
223
-    if ( self::$IN_MEMORY )
224
-      $this->_pdf->begin_document("","");
223
+    if (self::$IN_MEMORY)
224
+      $this->_pdf->begin_document("", "");
225 225
     else {
226 226
       $this->_file = tempnam(DOMPDF_TEMP_DIR, "libdompdf_pdf_").'.pdf';
227
-      $this->_pdf->begin_document($this->_file,"");
227
+      $this->_pdf->begin_document($this->_file, "");
228 228
     }
229 229
 
230 230
     $this->_pdf->begin_page_ext($this->_width, $this->_height, "");
@@ -243,29 +243,29 @@  discard block
 block discarded – undo
243 243
         $face = basename($file);
244 244
 
245 245
         // Prefer ttfs to afms
246
-        if ( file_exists($file.".ttf") ) {
246
+        if (file_exists($file.".ttf")) {
247 247
           $outline = "$file.ttf";
248 248
           $afm = null;
249 249
 
250
-        } else if ( file_exists($file .".TTF") ) {
250
+        } else if (file_exists($file.".TTF")) {
251 251
           $outline = "$file.TTF";
252 252
           $afm = null;
253 253
 
254
-        } else if ( file_exists($file . ".pfb") ) {
254
+        } else if (file_exists($file.".pfb")) {
255 255
           $outline = "$file.pfb";
256 256
 
257
-          if ( file_exists($file . ".afm") )
257
+          if (file_exists($file.".afm"))
258 258
             $afm = "$file.afm";
259 259
 
260
-        } else if ( file_exists($file . ".PFB") ) {
260
+        } else if (file_exists($file.".PFB")) {
261 261
           $outline = "$file.PFB";
262
-          if ( file_exists($file . ".AFM") )
262
+          if (file_exists($file.".AFM"))
263 263
             $afm = "$file.AFM";
264 264
         } else
265 265
           continue;
266 266
 
267 267
         $this->_pdf->set_parameter("FontOutline", "\{$face\}=\{$outline\}");
268
-        if ( !is_null($afm) )
268
+        if (!is_null($afm))
269 269
           $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}");
270 270
       }
271 271
     }
@@ -366,10 +366,10 @@  discard block
 block discarded – undo
366 366
    */
367 367
   function add_object($object, $where = 'all') {
368 368
 
369
-    if ( mb_strpos($where, "next") !== false ) {
369
+    if (mb_strpos($where, "next") !== false) {
370 370
       $this->_objs[$object]["start_page"]++;
371 371
       $where = str_replace("next", "", $where);
372
-      if ( $where == "" )
372
+      if ($where == "")
373 373
         $where = "add";
374 374
     }
375 375
 
@@ -386,18 +386,18 @@  discard block
 block discarded – undo
386 386
    */
387 387
   function stop_object($object) {
388 388
 
389
-    if ( !isset($this->_objs[$object]) )
389
+    if (!isset($this->_objs[$object]))
390 390
       return;
391 391
 
392 392
     $start = $this->_objs[$object]["start_page"];
393 393
     $where = $this->_objs[$object]["where"];
394 394
 
395 395
     // Place the object on this page if required
396
-    if ( $this->_page_number >= $start &&
396
+    if ($this->_page_number >= $start &&
397 397
          (($this->_page_number % 2 == 0 && $where === "even") ||
398 398
           ($this->_page_number % 2 == 1 && $where === "odd") ||
399
-          ($where === "all")) )
400
-      $this->_pdf->fit_image($object,0,0,"");
399
+          ($where === "all")))
400
+      $this->_pdf->fit_image($object, 0, 0, "");
401 401
 
402 402
     unset($this->_objs[$object]);
403 403
   }
@@ -407,16 +407,16 @@  discard block
 block discarded – undo
407 407
    */
408 408
   protected function _place_objects() {
409 409
 
410
-    foreach ( $this->_objs as $obj => $props ) {
410
+    foreach ($this->_objs as $obj => $props) {
411 411
       $start = $props["start_page"];
412 412
       $where = $props["where"];
413 413
 
414 414
       // Place the object on this page if required
415
-      if ( $this->_page_number >= $start &&
415
+      if ($this->_page_number >= $start &&
416 416
            (($this->_page_number % 2 == 0 && $where === "even") ||
417 417
             ($this->_page_number % 2 == 1 && $where === "odd") ||
418
-            ($where === "all")) ) {
419
-        $this->_pdf->fit_image($obj,0,0,"");
418
+            ($where === "all"))) {
419
+        $this->_pdf->fit_image($obj, 0, 0, "");
420 420
       }
421 421
     }
422 422
 
@@ -430,9 +430,9 @@  discard block
 block discarded – undo
430 430
 
431 431
   function get_page_count() { return $this->_page_count; }
432 432
 
433
-  function set_page_number($num) { $this->_page_number = (int)$num; }
433
+  function set_page_number($num) { $this->_page_number = (int) $num; }
434 434
 
435
-  function set_page_count($count) { $this->_page_count = (int)$count; }
435
+  function set_page_count($count) { $this->_page_count = (int) $count; }
436 436
 
437 437
 
438 438
   /**
@@ -445,15 +445,15 @@  discard block
 block discarded – undo
445 445
    */
446 446
   protected function _set_line_style($width, $cap, $join, $dash) {
447 447
 
448
-    if ( count($dash) == 1 )
448
+    if (count($dash) == 1)
449 449
       $dash[] = $dash[0];
450 450
 
451
-    if ( count($dash) > 1 )
452
-      $this->_pdf->setdashpattern("dasharray={" . join(" ", $dash) . "}");
451
+    if (count($dash) > 1)
452
+      $this->_pdf->setdashpattern("dasharray={".join(" ", $dash)."}");
453 453
     else
454
-      $this->_pdf->setdash(0,0);
454
+      $this->_pdf->setdash(0, 0);
455 455
 
456
-    switch ( $join ) {
456
+    switch ($join) {
457 457
     case "miter":
458 458
       $this->_pdf->setlinejoin(0);
459 459
       break;
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
       break;
471 471
     }
472 472
 
473
-    switch ( $cap ) {
473
+    switch ($cap) {
474 474
     case "butt":
475 475
       $this->_pdf->setlinecap(0);
476 476
       break;
@@ -497,12 +497,12 @@  discard block
 block discarded – undo
497 497
    * @param array $color array(r,g,b)
498 498
    */
499 499
   protected function _set_stroke_color($color) {
500
-    if($this->_last_stroke_color == $color)
500
+    if ($this->_last_stroke_color == $color)
501 501
     	return;
502 502
 
503 503
     $this->_last_stroke_color = $color;
504 504
 
505
-    list($r,$g,$b) = $color;
505
+    list($r, $g, $b) = $color;
506 506
     $this->_pdf->setcolor("stroke", "rgb", $r, $g, $b, 0);
507 507
   }
508 508
 
@@ -512,12 +512,12 @@  discard block
 block discarded – undo
512 512
    * @param array $color array(r,g,b)
513 513
    */
514 514
   protected function _set_fill_color($color) {
515
-    if($this->_last_fill_color == $color)
515
+    if ($this->_last_fill_color == $color)
516 516
     	return;
517 517
 
518 518
     $this->_last_fill_color = $color;
519 519
 
520
-    list($r,$g,$b) = $color;
520
+    list($r, $g, $b) = $color;
521 521
     $this->_pdf->setcolor("fill", "rgb", $r, $g, $b, 0);
522 522
   }
523 523
 
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
                           "symbol", "zapfdinbats");
538 538
 
539 539
     $test = strtolower(basename($font));
540
-    if ( in_array($test, $native_fonts) ) {
540
+    if (in_array($test, $native_fonts)) {
541 541
       $font = basename($font);
542 542
 
543 543
     } else {
@@ -545,20 +545,20 @@  discard block
 block discarded – undo
545 545
       $options .= " embedding=true";
546 546
     }
547 547
 
548
-    if ( is_null($encoding) ) {
548
+    if (is_null($encoding)) {
549 549
 
550 550
       // Unicode encoding is only available for the commerical
551 551
       // version of PDFlib and not PDFlib-Lite
552
-      if ( defined("DOMPDF_PDFLIB_LICENSE") )
552
+      if (defined("DOMPDF_PDFLIB_LICENSE"))
553 553
         $encoding = "unicode";
554 554
       else
555 555
         $encoding = "auto";
556 556
 
557 557
     }
558 558
 
559
-    $key = $font .":". $encoding .":". $options;
559
+    $key = $font.":".$encoding.":".$options;
560 560
 
561
-    if ( isset($this->_fonts[$key]) )
561
+    if (isset($this->_fonts[$key]))
562 562
       return $this->_fonts[$key];
563 563
 
564 564
     else {
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
     $y1 = $this->y($y1);
588 588
     $y2 = $this->y($y2);
589 589
 
590
-    $this->_pdf->moveto($x1,$y1);
590
+    $this->_pdf->moveto($x1, $y1);
591 591
     $this->_pdf->lineto($x2, $y2);
592 592
     $this->_pdf->stroke();
593 593
   }
@@ -622,20 +622,20 @@  discard block
 block discarded – undo
622 622
     $this->_set_fill_color($color);
623 623
     $this->_set_stroke_color($color);
624 624
 
625
-    if ( !$fill && isset($width) )
625
+    if (!$fill && isset($width))
626 626
       $this->_set_line_style($width, "square", "miter", $style);
627 627
 
628 628
     $y = $this->y(array_pop($points));
629 629
     $x = array_pop($points);
630
-    $this->_pdf->moveto($x,$y);
630
+    $this->_pdf->moveto($x, $y);
631 631
 
632 632
     while (count($points) > 1) {
633 633
       $y = $this->y(array_pop($points));
634 634
       $x = array_pop($points);
635
-      $this->_pdf->lineto($x,$y);
635
+      $this->_pdf->lineto($x, $y);
636 636
     }
637 637
 
638
-    if ( $fill )
638
+    if ($fill)
639 639
       $this->_pdf->fill();
640 640
     else
641 641
       $this->_pdf->closepath_stroke();
@@ -648,14 +648,14 @@  discard block
 block discarded – undo
648 648
     $this->_set_fill_color($color);
649 649
     $this->_set_stroke_color($color);
650 650
 
651
-    if ( !$fill && isset($width) )
651
+    if (!$fill && isset($width))
652 652
       $this->_set_line_style($width, "round", "round", $style);
653 653
 
654 654
     $y = $this->y($y);
655 655
 
656 656
     $this->_pdf->circle($x, $y, $r);
657 657
 
658
-    if ( $fill )
658
+    if ($fill)
659 659
       $this->_pdf->fill();
660 660
     else
661 661
       $this->_pdf->stroke();
@@ -665,15 +665,15 @@  discard block
 block discarded – undo
665 665
   //........................................................................
666 666
 
667 667
   function image($img_url, $img_type, $x, $y, $w, $h) {
668
-    $w = (int)$w;
669
-    $h = (int)$h;
668
+    $w = (int) $w;
669
+    $h = (int) $h;
670 670
 
671 671
     $img_type = strtolower($img_type);
672 672
 
673
-    if ( $img_type === "jpg" )
673
+    if ($img_type === "jpg")
674 674
       $img_type = "jpeg";
675 675
 
676
-    if ( isset($this->_imgs[$img_url]) )
676
+    if (isset($this->_imgs[$img_url]))
677 677
       $img = $this->_imgs[$img_url];
678 678
 
679 679
     else {
@@ -682,13 +682,13 @@  discard block
 block discarded – undo
682 682
     }
683 683
 
684 684
     $y = $this->y($y) - $h;
685
-    $this->_pdf->fit_image($img, $x, $y, 'boxsize={'. "$w $h" .'} fitmethod=entire');
685
+    $this->_pdf->fit_image($img, $x, $y, 'boxsize={'."$w $h".'} fitmethod=entire');
686 686
 
687 687
   }
688 688
 
689 689
   //........................................................................
690 690
 
691
-  function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) {
691
+  function text($x, $y, $text, $font, $size, $color = array(0, 0, 0), $adjust = 0, $angle = 0) {
692 692
     $fh = $this->_load_font($font);
693 693
 
694 694
     $this->_pdf->setfont($fh, $size);
@@ -696,8 +696,8 @@  discard block
 block discarded – undo
696 696
 
697 697
     $y = $this->y($y) - Font_Metrics::get_font_height($font, $size);
698 698
 
699
-    $adjust = (float)$adjust;
700
-    $angle = -(float)$angle;
699
+    $adjust = (float) $adjust;
700
+    $angle = -(float) $angle;
701 701
 
702 702
     $this->_pdf->fit_textline($text, $x, $y, "rotate=$angle wordspacing=$adjust");
703 703
 
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
    * @param string $anchorname The name of the named destination
718 718
    */
719 719
   function add_named_dest($anchorname) {
720
-    $this->_pdf->add_nameddest($anchorname,"");
720
+    $this->_pdf->add_nameddest($anchorname, "");
721 721
   }
722 722
 
723 723
   //........................................................................
@@ -734,21 +734,21 @@  discard block
 block discarded – undo
734 734
   function add_link($url, $x, $y, $width, $height) {
735 735
 
736 736
     $y = $this->y($y) - $height;
737
-    if ( strpos($url, '#') === 0 ) {
737
+    if (strpos($url, '#') === 0) {
738 738
       // Local link
739
-      $name = substr($url,1);
740
-      if ( $name )
741
-        $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} destname=". substr($url,1) . " linewidth=0");
739
+      $name = substr($url, 1);
740
+      if ($name)
741
+        $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} destname=".substr($url, 1)." linewidth=0");
742 742
     } else {
743 743
 
744 744
       list($proto, $host, $path, $file) = explode_url($url);
745 745
 
746
-      if ( $proto == "" || $proto === "file://" )
746
+      if ($proto == "" || $proto === "file://")
747 747
         return; // Local links are not allowed
748 748
       $url = build_url($proto, $host, $path, $file);
749
-      $url = '{' . rawurldecode($url) . '}';
749
+      $url = '{'.rawurldecode($url).'}';
750 750
       
751
-      $action = $this->_pdf->create_action("URI", "url=" . $url);
751
+      $action = $this->_pdf->create_action("URI", "url=".$url);
752 752
       $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} action={activate=$action} linewidth=0");
753 753
     }
754 754
   }
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
     $fh = $this->_load_font($font);
760 760
 
761 761
     // Determine the additional width due to extra spacing
762
-    $num_spaces = mb_substr_count($text," ");
762
+    $num_spaces = mb_substr_count($text, " ");
763 763
     $delta = $spacing * $num_spaces;
764 764
     return $this->_pdf->stringwidth($text, $fh, $size) + $delta;
765 765
   }
@@ -798,8 +798,8 @@  discard block
 block discarded – undo
798 798
    * @param float $adjust word spacing adjustment
799 799
    * @param float $angle angle to write the text at, measured CW starting from the x-axis
800 800
    */
801
-  function page_text($x, $y, $text, $font, $size, $color = array(0,0,0),
802
-                     $adjust = 0, $angle = 0,  $blend = "Normal", $opacity = 1.0) {
801
+  function page_text($x, $y, $text, $font, $size, $color = array(0, 0, 0),
802
+                     $adjust = 0, $angle = 0, $blend = "Normal", $opacity = 1.0) {
803 803
     $_t = "text";
804 804
     $this->_page_text[] = compact("_t", "x", "y", "text", "font", "size", "color", "adjust", "angle");
805 805
   }
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
    */
843 843
   protected function _add_page_text() {
844 844
 
845
-    if ( !count($this->_page_text) )
845
+    if (!count($this->_page_text))
846 846
       return;
847 847
 
848 848
     $this->_pdf->suspend_page("");
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
         switch ($_t) {
857 857
 
858 858
         case "text":
859
-          $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"),
859
+          $text = str_replace(array("{PAGE_NUM}", "{PAGE_COUNT}"),
860 860
                               array($p, $this->_page_count), $text);
861 861
           $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle);
862 862
           break;
@@ -883,14 +883,14 @@  discard block
 block discarded – undo
883 883
     // Add page text
884 884
     $this->_add_page_text();
885 885
 
886
-    if ( isset($options["compress"]) && $options["compress"] != 1 )
886
+    if (isset($options["compress"]) && $options["compress"] != 1)
887 887
       $this->_pdf->set_value("compress", 0);
888 888
     else
889 889
       $this->_pdf->set_value("compress", 6);
890 890
 
891 891
     $this->_close();
892 892
 
893
-    if ( self::$IN_MEMORY ) {
893
+    if (self::$IN_MEMORY) {
894 894
       $data = $this->_pdf->get_buffer();
895 895
       $size = strlen($data);
896 896
 
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
       $size = filesize($this->_file);
899 899
 
900 900
 
901
-    $filename = str_replace(array("\n","'"),"", $filename);
901
+    $filename = str_replace(array("\n", "'"), "", $filename);
902 902
     $attach = (isset($options["Attachment"]) && $options["Attachment"]) ? "attachment" : "inline";
903 903
 
904 904
     header("Cache-Control: private");
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
 
908 908
     //header("Content-length: " . $size);
909 909
 
910
-    if ( self::$IN_MEMORY )
910
+    if (self::$IN_MEMORY)
911 911
       echo $data;
912 912
 
913 913
     else {
@@ -915,11 +915,11 @@  discard block
 block discarded – undo
915 915
       // Chunked readfile()
916 916
       $chunk = (1 << 21); // 2 MB
917 917
       $fh = fopen($this->_file, "rb");
918
-      if ( !$fh )
919
-        throw new DOMPDF_Exception("Unable to load temporary PDF file: " . $this->_file);
918
+      if (!$fh)
919
+        throw new DOMPDF_Exception("Unable to load temporary PDF file: ".$this->_file);
920 920
 
921
-      while ( !feof($fh) )
922
-        echo fread($fh,$chunk);
921
+      while (!feof($fh))
922
+        echo fread($fh, $chunk);
923 923
       fclose($fh);
924 924
 
925 925
       //debugpng
@@ -942,14 +942,14 @@  discard block
 block discarded – undo
942 942
     // Add page text
943 943
     $this->_add_page_text();
944 944
 
945
-    if ( isset($options["compress"]) && $options["compress"] != 1 )
945
+    if (isset($options["compress"]) && $options["compress"] != 1)
946 946
       $this->_pdf->set_value("compress", 0);
947 947
     else
948 948
       $this->_pdf->set_value("compress", 6);
949 949
 
950 950
     $this->_close();
951 951
 
952
-    if ( self::$IN_MEMORY )
952
+    if (self::$IN_MEMORY)
953 953
       $data = $this->_pdf->get_buffer();
954 954
 
955 955
     else {
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/table_cell_frame_reflower.cls.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
     $cells = $cellmap->get_spanned_cells($this->_frame);
70 70
 
71 71
     $w = 0;
72
-    foreach ( $cells["columns"] as $i ) {
73
-      $col = $cellmap->get_column( $i );
72
+    foreach ($cells["columns"] as $i) {
73
+      $col = $cellmap->get_column($i);
74 74
       $w += $col["used-width"];
75 75
     }
76 76
 
@@ -110,15 +110,15 @@  discard block
 block discarded – undo
110 110
     $this->_frame->set_current_line($line_y);
111 111
     
112 112
     // Set the containing blocks and reflow each child
113
-    foreach ( $this->_frame->get_children() as $child ) {
113
+    foreach ($this->_frame->get_children() as $child) {
114 114
       
115
-      if ( $page->is_full() )
115
+      if ($page->is_full())
116 116
         break;
117 117
     
118 118
       $child->set_containing_block($content_x, $content_y, $cb_w, $h);
119 119
       $child->reflow();
120 120
 
121
-      $this->_frame->add_frame_to_line( $child );
121
+      $this->_frame->add_frame_to_line($child);
122 122
 
123 123
     }
124 124
 
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/functions.inc.php 1 patch
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -61,16 +61,16 @@  discard block
 block discarded – undo
61 61
  * @param bool $return
62 62
  *
63 63
  */
64
-if ( !function_exists("pre_r") ) {
64
+if (!function_exists("pre_r")) {
65 65
 function pre_r($mixed, $return = false) {
66 66
   if ($return)
67
-    return "<pre>" . print_r($mixed, true) . "</pre>";
67
+    return "<pre>".print_r($mixed, true)."</pre>";
68 68
 
69
-  if ( php_sapi_name() !== "cli")
69
+  if (php_sapi_name() !== "cli")
70 70
     echo ("<pre>");
71 71
   print_r($mixed);
72 72
 
73
-  if ( php_sapi_name() !== "cli")
73
+  if (php_sapi_name() !== "cli")
74 74
     echo("</pre>");
75 75
   else
76 76
     echo ("\n");
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
  *
88 88
  * @param mixed $mixed variable or expression to display.
89 89
  */
90
-if ( !function_exists("pre_var_dump") ) {
90
+if (!function_exists("pre_var_dump")) {
91 91
 function pre_var_dump($mixed) {
92
-  if ( php_sapi_name() !== "cli")
92
+  if (php_sapi_name() !== "cli")
93 93
     echo("<pre>");
94 94
   var_dump($mixed);
95
-  if ( php_sapi_name() !== "cli")
95
+  if (php_sapi_name() !== "cli")
96 96
     echo("</pre>");
97 97
 }
98 98
 }
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
  * is appended (o.k. also for Windows)
116 116
  */
117 117
 function build_url($protocol, $host, $base_path, $url) {
118
-  if ( mb_strlen($url) == 0 ) {
118
+  if (mb_strlen($url) == 0) {
119 119
     //return $protocol . $host . rtrim($base_path, "/\\") . "/";
120
-    return $protocol . $host . $base_path;
120
+    return $protocol.$host.$base_path;
121 121
   }
122 122
 
123 123
   // Is the url already fully qualified?
124
-  if ( mb_strpos($url, "://") !== false )
124
+  if (mb_strpos($url, "://") !== false)
125 125
     return $url;
126 126
 
127 127
   $ret = $protocol;
@@ -140,13 +140,13 @@  discard block
 block discarded – undo
140 140
   }
141 141
 
142 142
   //remote urls with backslash in html/css are not really correct, but lets be genereous
143
-  if ( $url[0] === '/' || $url[0] === '\\' ) {
143
+  if ($url[0] === '/' || $url[0] === '\\') {
144 144
     // Absolute path
145
-    $ret .= $host . $url;
145
+    $ret .= $host.$url;
146 146
   } else {
147 147
     // Relative path
148 148
     //$base_path = $base_path !== "" ? rtrim($base_path, "/\\") . "/" : "";
149
-    $ret .= $host . $base_path . $url;
149
+    $ret .= $host.$base_path.$url;
150 150
   }
151 151
 
152 152
   return $ret;
@@ -168,48 +168,48 @@  discard block
 block discarded – undo
168 168
 
169 169
   $arr = parse_url($url);
170 170
 
171
-  if ( isset($arr["scheme"]) &&
171
+  if (isset($arr["scheme"]) &&
172 172
        $arr["scheme"] !== "file" &&
173
-       mb_strlen($arr["scheme"]) > 1 ) // Exclude windows drive letters...
173
+       mb_strlen($arr["scheme"]) > 1) // Exclude windows drive letters...
174 174
     {
175
-    $protocol = $arr["scheme"] . "://";
175
+    $protocol = $arr["scheme"]."://";
176 176
 
177
-    if ( isset($arr["user"]) ) {
177
+    if (isset($arr["user"])) {
178 178
       $host .= $arr["user"];
179 179
 
180
-      if ( isset($arr["pass"]) )
181
-        $host .= "@" . $arr["pass"];
180
+      if (isset($arr["pass"]))
181
+        $host .= "@".$arr["pass"];
182 182
 
183 183
       $host .= ":";
184 184
     }
185 185
 
186
-    if ( isset($arr["host"]) )
186
+    if (isset($arr["host"]))
187 187
       $host .= $arr["host"];
188 188
 
189
-    if ( isset($arr["port"]) )
190
-      $host .= ":" . $arr["port"];
189
+    if (isset($arr["port"]))
190
+      $host .= ":".$arr["port"];
191 191
 
192
-    if ( isset($arr["path"]) && $arr["path"] !== "" ) {
192
+    if (isset($arr["path"]) && $arr["path"] !== "") {
193 193
       // Do we have a trailing slash?
194
-      if ( $arr["path"]{ mb_strlen($arr["path"]) - 1 } === "/" ) {
194
+      if ($arr["path"]{ mb_strlen($arr["path"]) - 1 } === "/") {
195 195
         $path = $arr["path"];
196 196
         $file = "";
197 197
       } else {
198
-        $path = dirname($arr["path"]) . "/";
198
+        $path = dirname($arr["path"])."/";
199 199
         $file = basename($arr["path"]);
200 200
       }
201 201
     }
202 202
 
203
-    if ( isset($arr["query"]) )
204
-      $file .= "?" . $arr["query"];
203
+    if (isset($arr["query"]))
204
+      $file .= "?".$arr["query"];
205 205
 
206
-    if ( isset($arr["fragment"]) )
207
-      $file .= "#" . $arr["fragment"];
206
+    if (isset($arr["fragment"]))
207
+      $file .= "#".$arr["fragment"];
208 208
 
209 209
   } else {
210 210
 
211 211
     $i = mb_strpos($url, "file://");
212
-    if ( $i !== false)
212
+    if ($i !== false)
213 213
       $url = mb_substr($url, $i + 7);
214 214
 
215 215
     $protocol = ""; // "file://"; ? why doesn't this work... It's because of
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
     $path = dirname($url);
222 222
 
223 223
     // Check that the path exists
224
-    if ( $path !== false ) {
224
+    if ($path !== false) {
225 225
       $path .= '/';
226 226
 
227 227
     } else {
@@ -230,10 +230,10 @@  discard block
 block discarded – undo
230 230
 
231 231
       $host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : php_uname("n");
232 232
 
233
-      if ( substr($arr["path"], 0, 1) === '/' ) {
233
+      if (substr($arr["path"], 0, 1) === '/') {
234 234
         $path = dirname($arr["path"]);
235 235
       } else {
236
-        $path = '/' . rtrim(dirname($_SERVER["SCRIPT_NAME"]), '/') . '/' . $arr["path"];
236
+        $path = '/'.rtrim(dirname($_SERVER["SCRIPT_NAME"]), '/').'/'.$arr["path"];
237 237
       }
238 238
     }
239 239
   }
@@ -262,13 +262,13 @@  discard block
 block discarded – undo
262 262
                        "dc", "dcc", "dccc", "cm");
263 263
   static $thou = array("", "m", "mm", "mmm");
264 264
 
265
-  if ( !is_numeric($num) )
265
+  if (!is_numeric($num))
266 266
     throw new DOMPDF_Exception("dec2roman() requires a numeric argument.");
267 267
 
268
-  if ( $num > 4000 || $num < 0 )
268
+  if ($num > 4000 || $num < 0)
269 269
     return "(out of range)";
270 270
 
271
-  $num = strrev((string)$num);
271
+  $num = strrev((string) $num);
272 272
 
273 273
   $ret = "";
274 274
   switch (mb_strlen($num)) {
@@ -304,8 +304,8 @@  discard block
 block discarded – undo
304 304
  * mb_string compatibility
305 305
  */
306 306
 
307
-if ( !function_exists("mb_convert_encoding") ) {
308
-  function mb_convert_encoding($data, $to_encoding, $from_encoding='UTF-8') {
307
+if (!function_exists("mb_convert_encoding")) {
308
+  function mb_convert_encoding($data, $to_encoding, $from_encoding = 'UTF-8') {
309 309
     if (str_replace('-', '', strtolower($to_encoding)) == 'utf8') {
310 310
       return utf8_encode($data);
311 311
     } else {
@@ -314,20 +314,20 @@  discard block
 block discarded – undo
314 314
   }
315 315
 }
316 316
 
317
-if ( !function_exists("mb_detect_encoding") ) {
318
-  function mb_detect_encoding($data, $encoding_list=array('iso-8859-1'), $strict=false) {
317
+if (!function_exists("mb_detect_encoding")) {
318
+  function mb_detect_encoding($data, $encoding_list = array('iso-8859-1'), $strict = false) {
319 319
     return 'iso-8859-1';
320 320
   }
321 321
 }
322 322
 
323
-if ( !function_exists("mb_detect_order") ) {
324
-  function mb_detect_order($encoding_list=array('iso-8859-1')) {
323
+if (!function_exists("mb_detect_order")) {
324
+  function mb_detect_order($encoding_list = array('iso-8859-1')) {
325 325
     return 'iso-8859-1';
326 326
   }
327 327
 }
328 328
 
329
-if ( !function_exists("mb_internal_encoding") ) {
330
-  function mb_internal_encoding($encoding=NULL) {
329
+if (!function_exists("mb_internal_encoding")) {
330
+  function mb_internal_encoding($encoding = NULL) {
331 331
     if (isset($encoding)) {
332 332
       return true;
333 333
     } else {
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
   }
337 337
 }
338 338
 
339
-if ( !function_exists("mb_strlen") ) {
340
-  function mb_strlen($str, $encoding='iso-8859-1') {
339
+if (!function_exists("mb_strlen")) {
340
+  function mb_strlen($str, $encoding = 'iso-8859-1') {
341 341
     if (str_replace('-', '', strtolower($encoding)) == 'utf8') {
342 342
       return strlen(utf8_encode($data));
343 343
     } else {
@@ -346,40 +346,40 @@  discard block
 block discarded – undo
346 346
   }
347 347
 }
348 348
 
349
-if ( !function_exists("mb_strpos") ) {
349
+if (!function_exists("mb_strpos")) {
350 350
   function mb_strpos($haystack, $needle, $offset = 0) {
351 351
     return strpos($haystack, $needle, $offset);
352 352
   }
353 353
 }
354 354
 
355
-if ( !function_exists("mb_strrpos") ) {
355
+if (!function_exists("mb_strrpos")) {
356 356
   function mb_strrpos($haystack, $needle, $offset = 0) {
357 357
     return strrpos($haystack, $needle, $offset);
358 358
   }
359 359
 }
360 360
 
361
-if ( !function_exists("mb_strtolower") ) {
361
+if (!function_exists("mb_strtolower")) {
362 362
   function mb_strtolower($str) {
363 363
     return strtolower($str);
364 364
   }
365 365
 }
366 366
 
367
-if ( !function_exists("mb_strtoupper") ) {
367
+if (!function_exists("mb_strtoupper")) {
368 368
   function mb_strtoupper($str) {
369 369
     return strtoupper($str);
370 370
   }
371 371
 }
372 372
 
373
-if ( !function_exists("mb_substr") ) {
374
-  function mb_substr($str, $start, $length=null, $encoding='iso-8859-1') {
375
-    if ( is_null($length) )
373
+if (!function_exists("mb_substr")) {
374
+  function mb_substr($str, $start, $length = null, $encoding = 'iso-8859-1') {
375
+    if (is_null($length))
376 376
       return substr($str, $start);
377 377
     else
378 378
       return substr($str, $start, $length);
379 379
   }
380 380
 }
381 381
 
382
-if ( !function_exists("mb_substr_count") ) {
382
+if (!function_exists("mb_substr_count")) {
383 383
   function mb_substr_count($haystack, $needle) {
384 384
     return substr_count($haystack, $needle);
385 385
   }
@@ -402,14 +402,14 @@  discard block
 block discarded – undo
402 402
  */
403 403
 function record_warnings($errno, $errstr, $errfile, $errline) {
404 404
 
405
-  if ( !($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING )) ) // Not a warning or notice
406
-    throw new DOMPDF_Exception($errstr . " $errno");
405
+  if (!($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING))) // Not a warning or notice
406
+    throw new DOMPDF_Exception($errstr." $errno");
407 407
 
408 408
   global $_dompdf_warnings;
409 409
   global $_dompdf_show_warnings;
410 410
 
411
-  if ( $_dompdf_show_warnings )
412
-    echo $errstr . "\n";
411
+  if ($_dompdf_show_warnings)
412
+    echo $errstr."\n";
413 413
 
414 414
   $_dompdf_warnings[] = $errstr;
415 415
 }
@@ -425,14 +425,14 @@  discard block
 block discarded – undo
425 425
 
426 426
   $i = 0;
427 427
   foreach ($bt as $call) {
428
-    $file = basename($call["file"]) . " (" . $call["line"] . ")";
429
-    if ( isset($call["class"]) ) {
430
-      $func = $call["class"] . "->" . $call["function"] . "()";
428
+    $file = basename($call["file"])." (".$call["line"].")";
429
+    if (isset($call["class"])) {
430
+      $func = $call["class"]."->".$call["function"]."()";
431 431
     } else {
432
-      $func = $call["function"] . "()";
432
+      $func = $call["function"]."()";
433 433
     }
434 434
 
435
-    echo "#" . str_pad($i, 2, " ", STR_PAD_RIGHT) . ": " . str_pad($file.":", 42) . " $func\n";
435
+    echo "#".str_pad($i, 2, " ", STR_PAD_RIGHT).": ".str_pad($file.":", 42)." $func\n";
436 436
     $i++;
437 437
   }
438 438
   echo "\n";
@@ -447,10 +447,10 @@  discard block
 block discarded – undo
447 447
   global $_DOMPDF_DEBUG_TYPES;
448 448
   global $_dompdf_show_warnings;
449 449
   global $_dompdf_debug;
450
-  if ( isset($_DOMPDF_DEBUG_TYPES[$type]) && ($_dompdf_show_warnings || $_dompdf_debug) ) {
450
+  if (isset($_DOMPDF_DEBUG_TYPES[$type]) && ($_dompdf_show_warnings || $_dompdf_debug)) {
451 451
     $arr = debug_backtrace();
452 452
 
453
-    echo basename($arr[0]["file"]) . " (" . $arr[0]["line"] ."): " . $arr[1]["function"] . ": ";
453
+    echo basename($arr[0]["file"])." (".$arr[0]["line"]."): ".$arr[1]["function"].": ";
454 454
     pre_r($msg);
455 455
   }
456 456
 }
@@ -458,29 +458,29 @@  discard block
 block discarded – undo
458 458
 /**
459 459
  * Dump memory usage
460 460
  */
461
-if ( !function_exists("print_memusage") ) {
461
+if (!function_exists("print_memusage")) {
462 462
 function print_memusage() {
463 463
   global $memusage;
464 464
   echo ("Memory Usage\n");
465 465
   $prev = 0;
466 466
   $initial = reset($memusage);
467
-  echo (str_pad("Initial:", 40) . $initial . "\n\n");
467
+  echo (str_pad("Initial:", 40).$initial."\n\n");
468 468
 
469 469
   foreach ($memusage as $key=>$mem) {
470 470
     $mem -= $initial;
471
-    echo (str_pad("$key:" , 40));
472
-    echo (str_pad("$mem", 12) . "(diff: " . ($mem - $prev) . ")\n");
471
+    echo (str_pad("$key:", 40));
472
+    echo (str_pad("$mem", 12)."(diff: ".($mem - $prev).")\n");
473 473
     $prev = $mem;
474 474
   }
475 475
 
476
-  echo ("\n" . str_pad("Total:", 40) . memory_get_usage()) . "\n";
476
+  echo ("\n".str_pad("Total:", 40).memory_get_usage())."\n";
477 477
 }
478 478
 }
479 479
 
480 480
 /**
481 481
  * Initialize memory profiling code
482 482
  */
483
-if ( !function_exists("enable_mem_profile") ) {
483
+if (!function_exists("enable_mem_profile")) {
484 484
 function enable_mem_profile() {
485 485
     global $memusage;
486 486
     $memusage = array("Startup" => memory_get_usage());
@@ -493,10 +493,10 @@  discard block
 block discarded – undo
493 493
  *
494 494
  * @param string $location a meaningful location
495 495
  */
496
-if ( !function_exists("mark_memusage") ) {
496
+if (!function_exists("mark_memusage")) {
497 497
 function mark_memusage($location) {
498 498
   global $memusage;
499
-  if ( isset($memusage) )
499
+  if (isset($memusage))
500 500
     $memusage[$location] = memory_get_usage();
501 501
 }
502 502
 }
@@ -506,12 +506,12 @@  discard block
 block discarded – undo
506 506
  *
507 507
  * @link http://us.php.net/manual/en/function.sys-get-temp-dir.php#85261
508 508
  */
509
-if ( !function_exists('sys_get_temp_dir')) {
509
+if (!function_exists('sys_get_temp_dir')) {
510 510
   function sys_get_temp_dir() {
511 511
     if (!empty($_ENV['TMP'])) { return realpath($_ENV['TMP']); }
512
-    if (!empty($_ENV['TMPDIR'])) { return realpath( $_ENV['TMPDIR']); }
513
-    if (!empty($_ENV['TEMP'])) { return realpath( $_ENV['TEMP']); }
514
-    $tempfile=tempnam(uniqid(rand(),TRUE),'');
512
+    if (!empty($_ENV['TMPDIR'])) { return realpath($_ENV['TMPDIR']); }
513
+    if (!empty($_ENV['TEMP'])) { return realpath($_ENV['TEMP']); }
514
+    $tempfile = tempnam(uniqid(rand(), TRUE), '');
515 515
     if (file_exists($tempfile)) {
516 516
     unlink($tempfile);
517 517
     return realpath(dirname($tempfile));
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/block_frame_decorator.cls.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
   protected $_lines; // array( [num] => array([frames] => array(<frame list>),
53 53
                      //                 y, w, h) )
54 54
   protected $_counters; // array([id] => counter_value) (for generated content)
55
-  protected $_cl;    // current line index
55
+  protected $_cl; // current line index
56 56
 
57 57
   //........................................................................
58 58
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 
88 88
   function get_current_line($i = null) {
89 89
     $cl = $this->_lines[$this->_cl];
90
-    if ( isset($i) )
90
+    if (isset($i))
91 91
       return $cl[$i];
92 92
     return $cl;
93 93
   }
@@ -102,13 +102,13 @@  discard block
 block discarded – undo
102 102
   }
103 103
 
104 104
   function clear_line($i) {
105
-    if ( isset($this->_lines[$i]) )
105
+    if (isset($this->_lines[$i]))
106 106
       unset($this->_lines[$i]);
107 107
   }
108 108
 
109 109
   function set_line($lineno, $y = null, $w = null, $h = null) {
110 110
 
111
-    if ( is_array($y) )
111
+    if (is_array($y))
112 112
       extract($y);
113 113
 
114 114
     if (is_numeric($y))
@@ -126,37 +126,37 @@  discard block
 block discarded – undo
126 126
   function add_frame_to_line(Frame $frame) {
127 127
 
128 128
     // Handle inline frames (which are effectively wrappers)
129
-    if ( $frame instanceof Inline_Frame_Decorator ) {
129
+    if ($frame instanceof Inline_Frame_Decorator) {
130 130
 
131 131
       // Handle line breaks
132
-      if ( $frame->get_node()->nodeName === "br" ) {
133
-        $this->maximize_line_height( $frame->get_style()->length_in_pt($frame->get_style()->line_height) );
132
+      if ($frame->get_node()->nodeName === "br") {
133
+        $this->maximize_line_height($frame->get_style()->length_in_pt($frame->get_style()->line_height));
134 134
         $this->add_line();
135 135
         return;
136 136
       }
137 137
 
138 138
       // Add each child of the inline frame to the line individually
139 139
       foreach ($frame->get_children() as $child)
140
-        $this->add_frame_to_line( $child );
140
+        $this->add_frame_to_line($child);
141 141
 
142 142
       return;
143 143
     }
144 144
 
145 145
     // Trim leading text if this is an empty line.  Kinda a hack to put it here,
146 146
     // but what can you do...
147
-    if ( $this->_lines[$this->_cl]["w"] == 0 &&
147
+    if ($this->_lines[$this->_cl]["w"] == 0 &&
148 148
          $frame->get_node()->nodeName === "#text" &&
149 149
          ($frame->get_style()->white_space !== "pre" ||
150
-          $frame->get_style()->white_space !== "pre-wrap") ) {
150
+          $frame->get_style()->white_space !== "pre-wrap")) {
151 151
 
152
-      $frame->set_text( ltrim($frame->get_text()) );
152
+      $frame->set_text(ltrim($frame->get_text()));
153 153
       $frame->recalculate_width();
154 154
 
155 155
     }
156 156
 
157 157
     $w = $frame->get_margin_width();
158 158
 
159
-    if ( $w == 0 )
159
+    if ($w == 0)
160 160
       return;
161 161
 
162 162
     // Debugging code:
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 
185 185
     $this->_lines[$this->_cl]["frames"][] = $frame;
186 186
 
187
-    if ( $frame->get_node()->nodeName === "#text")
187
+    if ($frame->get_node()->nodeName === "#text")
188 188
       $this->_lines[$this->_cl]["wc"] += count(preg_split("/\s+/", $frame->get_text()));
189 189
 
190 190
     $this->_lines[$this->_cl]["w"] += $w;
@@ -197,12 +197,12 @@  discard block
 block discarded – undo
197 197
     $i = $this->_cl;
198 198
 
199 199
     while ($i >= 0) {
200
-      if ( ($j = in_array($frame, $this->_lines[$i]["frames"], true)) !== false )
200
+      if (($j = in_array($frame, $this->_lines[$i]["frames"], true)) !== false)
201 201
         break;
202 202
       $i--;
203 203
     }
204 204
 
205
-    if ( $j === false )
205
+    if ($j === false)
206 206
       return;
207 207
 
208 208
     // Remove $frame and all frames that follow
@@ -215,22 +215,22 @@  discard block
 block discarded – undo
215 215
     // Recalculate the height of the line
216 216
     $h = 0;
217 217
     foreach ($this->_lines[$i]["frames"] as $f)
218
-      $h = max( $h, $f->get_margin_height() );
218
+      $h = max($h, $f->get_margin_height());
219 219
 
220 220
     $this->_lines[$i]["h"] = $h;
221 221
 
222 222
     // Remove all lines that follow
223 223
     while ($this->_cl > $i)
224
-      unset($this->_lines[ $this->_cl-- ]);
224
+      unset($this->_lines[$this->_cl--]);
225 225
 
226 226
   }
227 227
 
228 228
   function increase_line_width($w) {
229
-    $this->_lines[ $this->_cl ]["w"] += $w;
229
+    $this->_lines[$this->_cl]["w"] += $w;
230 230
   }
231 231
 
232 232
   function maximize_line_height($val) {
233
-    $this->_lines[ $this->_cl ]["h"] = max($this->_lines[ $this->_cl ]["h"], $val);
233
+    $this->_lines[$this->_cl]["h"] = max($this->_lines[$this->_cl]["h"], $val);
234 234
   }
235 235
 
236 236
   function add_line() {
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 
241 241
     $y = $this->_lines[$this->_cl]["y"] + $this->_lines[$this->_cl]["h"];
242 242
 
243
-    $this->_lines[ ++$this->_cl ] = array("frames" => array(),
243
+    $this->_lines[ ++$this->_cl] = array("frames" => array(),
244 244
                                           "wc" => 0,
245 245
                                           "y" => $y, "w" => 0, "h" => 0);
246 246
   }
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
   }
253 253
 
254 254
   function increment_counter($id = self::DEFAULT_COUNTER, $increment = 1) {
255
-    if ( !isset($this->_counters[$id]) )
255
+    if (!isset($this->_counters[$id]))
256 256
       $this->_counters[$id] = $increment;
257 257
     else
258 258
       $this->_counters[$id] += $increment;
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 
262 262
   function counter_value($id = self::DEFAULT_COUNTER, $type = "decimal") {
263 263
     $type = mb_strtolower($type);
264
-    if ( !isset($this->_counters[$id]) )
264
+    if (!isset($this->_counters[$id]))
265 265
       $this->_counters[$id] = 0;
266 266
 
267 267
     switch ($type) {
@@ -281,11 +281,11 @@  discard block
 block discarded – undo
281 281
 
282 282
     case "lower-latin":
283 283
     case "lower-alpha":
284
-      return chr( ($this->_counters[$id] % 26) + ord('a') - 1);
284
+      return chr(($this->_counters[$id] % 26) + ord('a') - 1);
285 285
 
286 286
     case "upper-latin":
287 287
     case "upper-alpha":
288
-      return chr( ($this->_counters[$id] % 26) + ord('A') - 1);
288
+      return chr(($this->_counters[$id] % 26) + ord('A') - 1);
289 289
 
290 290
     case "lower-greek":
291 291
       return chr($this->_counters[$id] + 944);
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/style.cls.php 1 patch
Spacing   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
    *
112 112
    * @var array
113 113
    */
114
-  static $BLOCK_TYPES = array("block","inline-block", "table-cell", "list-item");
114
+  static $BLOCK_TYPES = array("block", "inline-block", "table-cell", "list-item");
115 115
 
116 116
   /**
117 117
    * List of all table types.  Should really be a constant.
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
     $this->_parent_font_size = null;
200 200
     $this->__font_size_calculated = false;
201 201
     
202
-    if ( !isset(self::$_defaults) ) {
202
+    if (!isset(self::$_defaults)) {
203 203
     
204 204
       // Shorthand
205
-      $d =& self::$_defaults;
205
+      $d = & self::$_defaults;
206 206
     
207 207
       // All CSS 2.1 properties, and their default values
208 208
       $d["azimuth"] = "center";
@@ -398,90 +398,90 @@  discard block
 block discarded – undo
398 398
    */
399 399
   function length_in_pt($length, $ref_size = null) {
400 400
 
401
-    if ( !is_array($length) )
401
+    if (!is_array($length))
402 402
       $length = array($length);
403 403
 
404
-    if ( !isset($ref_size) )
404
+    if (!isset($ref_size))
405 405
       $ref_size = self::$default_font_size;
406 406
 
407 407
     $ret = 0;
408 408
     foreach ($length as $l) {
409 409
 
410
-      if ( $l === "auto" )
410
+      if ($l === "auto")
411 411
         return "auto";
412 412
       
413
-      if ( $l === "none" )
413
+      if ($l === "none")
414 414
         return "none";
415 415
 
416 416
       // Assume numeric values are already in points
417
-      if ( is_numeric($l) ) {
417
+      if (is_numeric($l)) {
418 418
         $ret += $l;
419 419
         continue;
420 420
       }
421 421
         
422
-      if ( $l === "normal" ) {
422
+      if ($l === "normal") {
423 423
         $ret += $ref_size;
424 424
         continue;
425 425
       }
426 426
 
427 427
       // Border lengths
428
-      if ( $l === "thin" ) {
428
+      if ($l === "thin") {
429 429
         $ret += 0.5;
430 430
         continue;
431 431
       }
432 432
       
433
-      if ( $l === "medium" ) {
433
+      if ($l === "medium") {
434 434
         $ret += 1.5;
435 435
         continue;
436 436
       }
437 437
     
438
-      if ( $l === "thick" ) {
438
+      if ($l === "thick") {
439 439
         $ret += 2.5;
440 440
         continue;
441 441
       }
442 442
       
443
-      if ( ($i = mb_strpos($l, "pt"))  !== false ) {
443
+      if (($i = mb_strpos($l, "pt")) !== false) {
444 444
         $ret += mb_substr($l, 0, $i);
445 445
         continue;
446 446
       }
447 447
 
448
-      if ( ($i = mb_strpos($l, "px"))  !== false ) {
449
-        $ret += ( mb_substr($l, 0, $i)  * 72 ) / DOMPDF_DPI;
448
+      if (($i = mb_strpos($l, "px")) !== false) {
449
+        $ret += (mb_substr($l, 0, $i) * 72) / DOMPDF_DPI;
450 450
         continue;
451 451
       }
452 452
 
453
-      if ( ($i = mb_strpos($l, "em"))  !== false ) {
453
+      if (($i = mb_strpos($l, "em")) !== false) {
454 454
         $ret += mb_substr($l, 0, $i) * $this->__get("font_size");
455 455
         continue;
456 456
       }
457 457
       
458 458
       // FIXME: em:ex ratio?
459
-      if ( ($i = mb_strpos($l, "ex"))  !== false ) {
459
+      if (($i = mb_strpos($l, "ex")) !== false) {
460 460
         $ret += mb_substr($l, 0, $i) * $this->__get("font_size");
461 461
         continue;
462 462
       }
463 463
       
464
-      if ( ($i = mb_strpos($l, "%"))  !== false ) {
465
-        $ret += mb_substr($l, 0, $i)/100 * $ref_size;
464
+      if (($i = mb_strpos($l, "%")) !== false) {
465
+        $ret += mb_substr($l, 0, $i) / 100 * $ref_size;
466 466
         continue;
467 467
       }
468 468
       
469
-      if ( ($i = mb_strpos($l, "in")) !== false ) {
469
+      if (($i = mb_strpos($l, "in")) !== false) {
470 470
         $ret += mb_substr($l, 0, $i) * 72;
471 471
         continue;
472 472
       }
473 473
           
474
-      if ( ($i = mb_strpos($l, "cm")) !== false ) {
474
+      if (($i = mb_strpos($l, "cm")) !== false) {
475 475
         $ret += mb_substr($l, 0, $i) * 72 / 2.54;
476 476
         continue;
477 477
       }
478 478
 
479
-      if ( ($i = mb_strpos($l, "mm")) !== false ) {
479
+      if (($i = mb_strpos($l, "mm")) !== false) {
480 480
         $ret += mb_substr($l, 0, $i) * 72 / 25.4;
481 481
         continue;
482 482
       }
483 483
           
484
-      if ( ($i = mb_strpos($l, "pc")) !== false ) {
484
+      if (($i = mb_strpos($l, "pc")) !== false) {
485 485
         $ret += mb_substr($l, 0, $i) / 12;
486 486
         continue;
487 487
       }
@@ -507,12 +507,12 @@  discard block
 block discarded – undo
507 507
     foreach (self::$_inherited as $prop) {
508 508
       //inherit the !important property also.
509 509
       //if local property is also !important, don't inherit.
510
-      if ( isset($parent->_props[$prop]) &&
511
-           ( !isset($this->_props[$prop]) ||
512
-             ( isset($parent->_important_props[$prop]) && !isset($this->_important_props[$prop]) )
510
+      if (isset($parent->_props[$prop]) &&
511
+           (!isset($this->_props[$prop]) ||
512
+             (isset($parent->_important_props[$prop]) && !isset($this->_important_props[$prop]))
513 513
            )
514 514
          ) {
515
-        if ( isset($parent->_important_props[$prop]) ) {
515
+        if (isset($parent->_important_props[$prop])) {
516 516
           $this->_important_props[$prop] = true;
517 517
         }
518 518
         //see __set and __get, on all assignments clear cache!
@@ -522,8 +522,8 @@  discard block
 block discarded – undo
522 522
     }
523 523
       
524 524
     foreach (array_keys($this->_props) as $prop) {
525
-      if ( $this->_props[$prop] === "inherit" ) {
526
-        if ( isset($parent->_important_props[$prop]) ) {
525
+      if ($this->_props[$prop] === "inherit") {
526
+        if (isset($parent->_important_props[$prop])) {
527 527
           $this->_important_props[$prop] = true;
528 528
         }
529 529
         //do not assign direct, but
@@ -554,20 +554,20 @@  discard block
 block discarded – undo
554 554
     //treat the !important attribute
555 555
     //if old rule has !important attribute, override with new rule only if
556 556
     //the new rule is also !important
557
-    foreach($style->_props as $prop => $val ) {
557
+    foreach ($style->_props as $prop => $val) {
558 558
       if (isset($style->_important_props[$prop])) {
559 559
  	    $this->_important_props[$prop] = true;
560 560
         //see __set and __get, on all assignments clear cache!
561 561
 		$this->_prop_cache[$prop] = null;
562 562
  	    $this->_props[$prop] = $val;
563
- 	  } else if ( !isset($this->_important_props[$prop]) ) {
563
+ 	  } else if (!isset($this->_important_props[$prop])) {
564 564
         //see __set and __get, on all assignments clear cache!
565 565
 		$this->_prop_cache[$prop] = null;
566 566
  	    $this->_props[$prop] = $val;
567 567
  	  }
568 568
  	}
569 569
 
570
-    if ( isset($style->_props["font_size"]) )
570
+    if (isset($style->_props["font_size"]))
571 571
       $this->__font_size_calculated = false;
572 572
   }
573 573
 
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
    * @return array
581 581
    */
582 582
   function munge_colour($colour) {
583
-    if ( is_array($colour) )
583
+    if (is_array($colour))
584 584
       // Assume the array has the right format...
585 585
       // FIXME: should/could verify this.
586 586
       return $colour;
@@ -671,19 +671,19 @@  discard block
 block discarded – undo
671 671
       return "transparent";
672 672
       
673 673
     default:
674
-      if ( mb_strlen($colour) == 4 && $colour[0] === "#" ) {
674
+      if (mb_strlen($colour) == 4 && $colour[0] === "#") {
675 675
         // #rgb format
676
-        $r = hexdec($colour[1] . $colour[1]);
677
-        $g = hexdec($colour[2] . $colour[2]);
678
-        $b = hexdec($colour[3] . $colour[3]);
676
+        $r = hexdec($colour[1].$colour[1]);
677
+        $g = hexdec($colour[2].$colour[2]);
678
+        $b = hexdec($colour[3].$colour[3]);
679 679
 
680
-      } else if ( mb_strlen($colour) == 7 && $colour[0] === "#" ) {
680
+      } else if (mb_strlen($colour) == 7 && $colour[0] === "#") {
681 681
         // #rrggbb format
682 682
         $r = hexdec(mb_substr($colour, 1, 2));
683 683
         $g = hexdec(mb_substr($colour, 3, 2));
684 684
         $b = hexdec(mb_substr($colour, 5, 2));
685 685
 
686
-      } else if ( mb_strpos($colour, "rgb") !== false ) {
686
+      } else if (mb_strpos($colour, "rgb") !== false) {
687 687
         // rgb( r,g,b ) format
688 688
         $i = mb_strpos($colour, "(");
689 689
         $j = mb_strpos($colour, ")");
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
         if ($i === false || $j === false)
693 693
           return null;
694 694
 
695
-        $triplet = explode(",", mb_substr($colour, $i+1, $j-$i-1));
695
+        $triplet = explode(",", mb_substr($colour, $i + 1, $j - $i - 1));
696 696
 
697 697
         if (count($triplet) != 3)
698 698
           return null;
@@ -700,7 +700,7 @@  discard block
 block discarded – undo
700 700
         foreach (array_keys($triplet) as $c) {
701 701
           $triplet[$c] = trim($triplet[$c]);
702 702
           
703
-          if ( $triplet[$c]{mb_strlen($triplet[$c]) - 1} === "%" )
703
+          if ($triplet[$c]{mb_strlen($triplet[$c]) - 1} === "%")
704 704
             $triplet[$c] = round($triplet[$c] * 0.255);
705 705
         }
706 706
 
@@ -784,19 +784,19 @@  discard block
 block discarded – undo
784 784
     $prop = str_replace("-", "_", $prop);
785 785
     $this->_prop_cache[$prop] = null;
786 786
     
787
-    if ( !isset(self::$_defaults[$prop]) ) {
787
+    if (!isset(self::$_defaults[$prop])) {
788 788
       $_dompdf_warnings[] = "'$prop' is not a valid CSS2 property.";
789 789
       return;
790 790
     }
791 791
     
792
-    if ( $prop !== "content" && is_string($val) && mb_strpos($val, "url") === false ) {
792
+    if ($prop !== "content" && is_string($val) && mb_strpos($val, "url") === false) {
793 793
       $val = mb_strtolower(trim(str_replace(array("\n", "\t"), array(" "), $val)));
794 794
       $val = preg_replace("/([0-9]+) (pt|px|pc|em|ex|in|cm|mm|%)/S", "\\1\\2", $val);
795 795
     }
796 796
     
797 797
     $method = "set_$prop";
798 798
 
799
-    if ( method_exists($this, $method) )
799
+    if (method_exists($this, $method))
800 800
       $this->$method($val);
801 801
     else
802 802
       $this->_props[$prop] = $val;
@@ -818,19 +818,19 @@  discard block
 block discarded – undo
818 818
    */
819 819
   function __get($prop) {
820 820
     
821
-    if ( !isset(self::$_defaults[$prop]) )
821
+    if (!isset(self::$_defaults[$prop]))
822 822
       throw new DOMPDF_Exception("'$prop' is not a valid CSS2 property.");
823 823
 
824
-    if ( isset($this->_prop_cache[$prop]) && $this->_prop_cache[$prop] != null)
824
+    if (isset($this->_prop_cache[$prop]) && $this->_prop_cache[$prop] != null)
825 825
       return $this->_prop_cache[$prop];
826 826
     
827 827
     $method = "get_$prop";
828 828
 
829 829
     // Fall back on defaults if property is not set
830
-    if ( !isset($this->_props[$prop]) )
830
+    if (!isset($this->_props[$prop]))
831 831
       $this->_props[$prop] = self::$_defaults[$prop];
832 832
 
833
-    if ( method_exists($this, $method) )
833
+    if (method_exists($this, $method))
834 834
       return $this->_prop_cache[$prop] = $this->$method();
835 835
 
836 836
 
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
    */
850 850
   function get_font_family() {
851 851
   
852
-    $DEBUGCSS=DEBUGCSS; //=DEBUGCSS; Allow override of global setting for ad hoc debug
852
+    $DEBUGCSS = DEBUGCSS; //=DEBUGCSS; Allow override of global setting for ad hoc debug
853 853
 	
854 854
     // Select the appropriate font.  First determine the subtype, then check
855 855
     // the specified font-families for a candidate.
@@ -857,14 +857,14 @@  discard block
 block discarded – undo
857 857
     // Resolve font-weight
858 858
     $weight = $this->__get("font_weight");
859 859
     
860
-    if ( is_numeric($weight) ) {
860
+    if (is_numeric($weight)) {
861 861
 
862
-      if ( $weight < 600 )
862
+      if ($weight < 600)
863 863
         $weight = "normal";
864 864
       else
865 865
         $weight = "bold";
866 866
 
867
-    } else if ( $weight === "bold" || $weight === "bolder" ) {
867
+    } else if ($weight === "bold" || $weight === "bolder") {
868 868
       $weight = "bold";
869 869
 
870 870
     } else {
@@ -875,11 +875,11 @@  discard block
 block discarded – undo
875 875
     // Resolve font-style
876 876
     $font_style = $this->__get("font_style");
877 877
 
878
-    if ( $weight === "bold" && ($font_style === "italic" || $font_style === "oblique") )
878
+    if ($weight === "bold" && ($font_style === "italic" || $font_style === "oblique"))
879 879
       $subtype = "bold_italic";
880
-    else if ( $weight === "bold" && $font_style !== "italic" && $font_style !== "oblique" )
880
+    else if ($weight === "bold" && $font_style !== "italic" && $font_style !== "oblique")
881 881
       $subtype = "bold";
882
-    else if ( $weight !== "bold" && ($font_style === "italic" || $font_style === "oblique") )
882
+    else if ($weight !== "bold" && ($font_style === "italic" || $font_style === "oblique"))
883 883
       $subtype = "italic";
884 884
     else
885 885
       $subtype = "normal";
@@ -890,19 +890,19 @@  discard block
 block discarded – undo
890 890
       print '('.$this->_props["font_family"].'.'.$font_style.'.'.$this->__get("font_weight").'.'.$weight.'.'.$subtype.')';
891 891
     }
892 892
     $families = explode(",", $this->_props["font_family"]);
893
-    $families = array_map('trim',$families);
893
+    $families = array_map('trim', $families);
894 894
     reset($families);
895 895
 
896 896
     $font = null;
897
-    while ( current($families) ) {
897
+    while (current($families)) {
898 898
       list(,$family) = each($families);
899 899
       //remove leading and trailing string delimiters, e.g. on font names with spaces;
900 900
       //remove leading and trailing whitespace
901
-      $family=trim($family," \t\n\r\x0B\"'");
901
+      $family = trim($family, " \t\n\r\x0B\"'");
902 902
       if ($DEBUGCSS) print '('.$family.')';
903 903
       $font = Font_Metrics::get_font($family, $subtype);
904 904
 
905
-      if ( $font ) {
905
+      if ($font) {
906 906
         if ($DEBUGCSS)  print '('.$font.")get_font_family]\n</pre>";
907 907
         return $font;
908 908
       }
@@ -912,11 +912,11 @@  discard block
 block discarded – undo
912 912
     if ($DEBUGCSS)  print '(default)';
913 913
     $font = Font_Metrics::get_font($family, $subtype);
914 914
 
915
-    if ( $font ) {
915
+    if ($font) {
916 916
       if ($DEBUGCSS) print '('.$font.")get_font_family]\n</pre>";
917 917
       return $font;
918 918
     }
919
-    throw new DOMPDF_Exception("Unable to find a suitable font replacement for: '" . $this->_props["font_family"] ."'");
919
+    throw new DOMPDF_Exception("Unable to find a suitable font replacement for: '".$this->_props["font_family"]."'");
920 920
     
921 921
   }
922 922
 
@@ -928,30 +928,30 @@  discard block
 block discarded – undo
928 928
    */
929 929
   function get_font_size() {
930 930
 
931
-    if ( $this->__font_size_calculated )
931
+    if ($this->__font_size_calculated)
932 932
       return $this->_props["font_size"];
933 933
     
934
-    if ( !isset($this->_props["font_size"]) )
934
+    if (!isset($this->_props["font_size"]))
935 935
       $fs = self::$_defaults["font_size"];
936 936
     else
937 937
       $fs = $this->_props["font_size"];
938 938
     
939
-    if ( !isset($this->_parent_font_size) )
939
+    if (!isset($this->_parent_font_size))
940 940
       $this->_parent_font_size = self::$default_font_size;
941 941
     
942 942
     switch ($fs) {
943 943
       
944 944
     case "xx-small":
945
-      $fs = 3/5 * $this->_parent_font_size;
945
+      $fs = 3 / 5 * $this->_parent_font_size;
946 946
       break;
947 947
 
948 948
     case "x-small":
949
-      $fs = 3/4 * $this->_parent_font_size;
949
+      $fs = 3 / 4 * $this->_parent_font_size;
950 950
       break;
951 951
 
952 952
     case "smaller":
953 953
     case "small":
954
-      $fs = 8/9 * $this->_parent_font_size;
954
+      $fs = 8 / 9 * $this->_parent_font_size;
955 955
       break;
956 956
 
957 957
     case "medium":
@@ -960,15 +960,15 @@  discard block
 block discarded – undo
960 960
 
961 961
     case "larger":
962 962
     case "large":
963
-      $fs = 6/5 * $this->_parent_font_size;
963
+      $fs = 6 / 5 * $this->_parent_font_size;
964 964
       break;
965 965
 
966 966
     case "x-large":
967
-      $fs = 3/2 * $this->_parent_font_size;
967
+      $fs = 3 / 2 * $this->_parent_font_size;
968 968
       break;
969 969
 
970 970
     case "xx-large":
971
-      $fs = 2/1 * $this->_parent_font_size;
971
+      $fs = 2 / 1 * $this->_parent_font_size;
972 972
       break;
973 973
 
974 974
     default:
@@ -976,10 +976,10 @@  discard block
 block discarded – undo
976 976
     }
977 977
 
978 978
     // Ensure relative sizes resolve to something
979
-    if ( ($i = mb_strpos($fs, "em")) !== false )
979
+    if (($i = mb_strpos($fs, "em")) !== false)
980 980
       $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size;
981 981
 
982
-    else if ( ($i = mb_strpos($fs, "ex")) !== false )
982
+    else if (($i = mb_strpos($fs, "ex")) !== false)
983 983
       $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size;
984 984
 
985 985
     else
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
    * @return float
999 999
    */
1000 1000
   function get_word_spacing() {
1001
-    if ( $this->_props["word_spacing"] === "normal" )
1001
+    if ($this->_props["word_spacing"] === "normal")
1002 1002
       return 0;
1003 1003
 
1004 1004
     return $this->_props["word_spacing"];
@@ -1009,13 +1009,13 @@  discard block
 block discarded – undo
1009 1009
    * @return float
1010 1010
    */
1011 1011
   function get_line_height() {
1012
-    if ( $this->_props["line_height"] === "normal" )
1012
+    if ($this->_props["line_height"] === "normal")
1013 1013
       return self::$default_line_height * $this->get_font_size();
1014 1014
 
1015
-    if ( is_numeric($this->_props["line_height"]) )
1016
-      return $this->length_in_pt( $this->_props["line_height"] . "%", $this->get_font_size());
1015
+    if (is_numeric($this->_props["line_height"]))
1016
+      return $this->length_in_pt($this->_props["line_height"]."%", $this->get_font_size());
1017 1017
     
1018
-    return $this->length_in_pt( $this->_props["line_height"], $this->get_font_size() );
1018
+    return $this->length_in_pt($this->_props["line_height"], $this->get_font_size());
1019 1019
   }
1020 1020
 
1021 1021
   /**
@@ -1028,7 +1028,7 @@  discard block
 block discarded – undo
1028 1028
    * @return array
1029 1029
    */
1030 1030
   function get_color() {
1031
-    return $this->munge_color( $this->_props["color"] );
1031
+    return $this->munge_color($this->_props["color"]);
1032 1032
   }
1033 1033
 
1034 1034
   /**
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
    * @return array
1041 1041
    */
1042 1042
   function get_background_color() {
1043
-    return $this->munge_color( $this->_props["background_color"] );
1043
+    return $this->munge_color($this->_props["background_color"]);
1044 1044
   }
1045 1045
   
1046 1046
   /**
@@ -1084,7 +1084,7 @@  discard block
 block discarded – undo
1084 1084
       break;
1085 1085
     }
1086 1086
 
1087
-    if ( isset($tmp[1]) ) {
1087
+    if (isset($tmp[1])) {
1088 1088
 
1089 1089
       switch ($tmp[1]) {
1090 1090
       case "left":
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
         break;
1105 1105
         
1106 1106
       case "center":
1107
-        if ( $tmp[0] === "left" || $tmp[0] === "right" || $tmp[0] === "center" )
1107
+        if ($tmp[0] === "left" || $tmp[0] === "right" || $tmp[0] === "center")
1108 1108
           $y = "50%";
1109 1109
         else
1110 1110
           $x = "50%";
@@ -1119,14 +1119,14 @@  discard block
 block discarded – undo
1119 1119
       $y = "50%";
1120 1120
     }
1121 1121
 
1122
-    if ( !isset($x) )
1122
+    if (!isset($x))
1123 1123
       $x = "0%";
1124 1124
 
1125
-    if ( !isset($y) )
1125
+    if (!isset($y))
1126 1126
       $y = "0%";
1127 1127
 
1128
-    return array( 0 => $x, "x" => $x,
1129
-                  1 => $y, "y" => $y );
1128
+    return array(0 => $x, "x" => $x,
1129
+                  1 => $y, "y" => $y);
1130 1130
   }
1131 1131
 
1132 1132
 
@@ -1181,7 +1181,7 @@  discard block
 block discarded – undo
1181 1181
    * @return array
1182 1182
    */
1183 1183
   function get_border_top_color() {
1184
-    if ( $this->_props["border_top_color"] === "" ) {
1184
+    if ($this->_props["border_top_color"] === "") {
1185 1185
       //see __set and __get, on all assignments clear cache!
1186 1186
       $this->_prop_cache["border_top_color"] = null;
1187 1187
       $this->_props["border_top_color"] = $this->__get("color");
@@ -1190,7 +1190,7 @@  discard block
 block discarded – undo
1190 1190
   }
1191 1191
 
1192 1192
   function get_border_right_color() {
1193
-    if ( $this->_props["border_right_color"] === "" ) {
1193
+    if ($this->_props["border_right_color"] === "") {
1194 1194
       //see __set and __get, on all assignments clear cache!
1195 1195
       $this->_prop_cache["border_right_color"] = null;
1196 1196
       $this->_props["border_right_color"] = $this->__get("color");
@@ -1199,16 +1199,16 @@  discard block
 block discarded – undo
1199 1199
   }
1200 1200
 
1201 1201
   function get_border_bottom_color() {
1202
-    if ( $this->_props["border_bottom_color"] === "" ) {
1202
+    if ($this->_props["border_bottom_color"] === "") {
1203 1203
       //see __set and __get, on all assignments clear cache!
1204 1204
       $this->_prop_cache["border_bottom_color"] = null;
1205 1205
       $this->_props["border_bottom_color"] = $this->__get("color");
1206 1206
     }
1207
-    return $this->munge_color($this->_props["border_bottom_color"]);;
1207
+    return $this->munge_color($this->_props["border_bottom_color"]); ;
1208 1208
   }
1209 1209
 
1210 1210
   function get_border_left_color() {
1211
-    if ( $this->_props["border_left_color"] === "" ) {
1211
+    if ($this->_props["border_left_color"] === "") {
1212 1212
       //see __set and __get, on all assignments clear cache!
1213 1213
       $this->_prop_cache["border_left_color"] = null;
1214 1214
       $this->_props["border_left_color"] = $this->__get("color");
@@ -1279,10 +1279,10 @@  discard block
 block discarded – undo
1279 1279
    * @return mixed
1280 1280
    */
1281 1281
   protected function _get_border($side) {
1282
-    $color = $this->__get("border_" . $side . "_color");
1282
+    $color = $this->__get("border_".$side."_color");
1283 1283
     
1284
-    return $this->__get("border_" . $side . "_width") . " " .
1285
-      $this->__get("border_" . $side . "_style") . " " . $color["hex"];
1284
+    return $this->__get("border_".$side."_width")." ".
1285
+      $this->__get("border_".$side."_style")." ".$color["hex"];
1286 1286
   }
1287 1287
 
1288 1288
   /**#@+
@@ -1363,8 +1363,8 @@  discard block
 block discarded – undo
1363 1363
    * Applicable for background, border, padding, margin, font, list_style
1364 1364
    * Note: $type has a leading underscore (or is empty), the others not.
1365 1365
    */
1366
-  protected function _set_style_side_type($style,$side,$type,$val,$important) {
1367
-    if ( !isset($this->_important_props[$style.'_'.$side.$type]) || $important) {
1366
+  protected function _set_style_side_type($style, $side, $type, $val, $important) {
1367
+    if (!isset($this->_important_props[$style.'_'.$side.$type]) || $important) {
1368 1368
       //see __set and __get, on all assignments clear cache!
1369 1369
       $this->_prop_cache[$style.'_'.$side.$type] = null;
1370 1370
       if ($important) {
@@ -1374,27 +1374,27 @@  discard block
 block discarded – undo
1374 1374
     }
1375 1375
   }
1376 1376
 
1377
-  protected function _set_style_sides_type($style,$top,$right,$bottom,$left,$type,$important) {
1378
-      $this->_set_style_side_type($style,'top',$type,$top,$important);
1379
-      $this->_set_style_side_type($style,'right',$type,$right,$important);
1380
-      $this->_set_style_side_type($style,'bottom',$type,$bottom,$important);
1381
-      $this->_set_style_side_type($style,'left',$type,$left,$important);
1377
+  protected function _set_style_sides_type($style, $top, $right, $bottom, $left, $type, $important) {
1378
+      $this->_set_style_side_type($style, 'top', $type, $top, $important);
1379
+      $this->_set_style_side_type($style, 'right', $type, $right, $important);
1380
+      $this->_set_style_side_type($style, 'bottom', $type, $bottom, $important);
1381
+      $this->_set_style_side_type($style, 'left', $type, $left, $important);
1382 1382
   }
1383 1383
 
1384
-  protected function _set_style_type($style,$type,$val,$important) {
1384
+  protected function _set_style_type($style, $type, $val, $important) {
1385 1385
     $arr = explode(" ", $val);
1386 1386
     switch (count($arr)) {
1387 1387
     case 1:
1388
-      $this->_set_style_sides_type($style,$arr[0],$arr[0],$arr[0],$arr[0],$type,$important);
1388
+      $this->_set_style_sides_type($style, $arr[0], $arr[0], $arr[0], $arr[0], $type, $important);
1389 1389
       break;
1390 1390
     case 2:
1391
-      $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[0],$arr[1],$type,$important);
1391
+      $this->_set_style_sides_type($style, $arr[0], $arr[1], $arr[0], $arr[1], $type, $important);
1392 1392
       break;
1393 1393
     case 3:
1394
-      $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[1],$arr[2],$type,$important);
1394
+      $this->_set_style_sides_type($style, $arr[0], $arr[1], $arr[1], $arr[2], $type, $important);
1395 1395
       break;
1396 1396
     case 4:
1397
-      $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[2],$arr[3],$type,$important);
1397
+      $this->_set_style_sides_type($style, $arr[0], $arr[1], $arr[2], $arr[3], $type, $important);
1398 1398
       break;
1399 1399
     default:
1400 1400
       break;
@@ -1404,21 +1404,21 @@  discard block
 block discarded – undo
1404 1404
     $this->_props[$style.$type] = $val;
1405 1405
   }
1406 1406
 
1407
-  protected function _set_style_type_important($style,$type,$val) {
1408
-    $this->_set_style_type($style,$type,$val,isset($this->_important_props[$style.$type]));
1407
+  protected function _set_style_type_important($style, $type, $val) {
1408
+    $this->_set_style_type($style, $type, $val, isset($this->_important_props[$style.$type]));
1409 1409
   }
1410 1410
 
1411 1411
   /* Anyway only called if _important matches and is assigned
1412 1412
    * E.g. _set_style_side_type($style,$side,'',str_replace("none", "0px", $val),isset($this->_important_props[$style.'_'.$side]));
1413 1413
    */
1414
-  protected function _set_style_side_width_important($style,$side,$val) {
1414
+  protected function _set_style_side_width_important($style, $side, $val) {
1415 1415
     //see __set and __get, on all assignments clear cache!
1416 1416
     $this->_prop_cache[$style.'_'.$side] = null;
1417 1417
     $this->_props[$style.'_'.$side] = str_replace("none", "0px", $val);
1418 1418
   }
1419 1419
 
1420
-  protected function _set_style($style,$val,$important) {
1421
-    if ( !isset($this->_important_props[$style]) || $important) {
1420
+  protected function _set_style($style, $val, $important) {
1421
+    if (!isset($this->_important_props[$style]) || $important) {
1422 1422
       if ($important) {
1423 1423
         $this->_important_props[$style] = true;
1424 1424
       }
@@ -1429,22 +1429,22 @@  discard block
 block discarded – undo
1429 1429
   }
1430 1430
 
1431 1431
   protected function _image($val) {
1432
-    $DEBUGCSS=DEBUGCSS;
1432
+    $DEBUGCSS = DEBUGCSS;
1433 1433
     
1434
-    if ( mb_strpos($val, "url") === false ) {
1434
+    if (mb_strpos($val, "url") === false) {
1435 1435
       $path = "none"; //Don't resolve no image -> otherwise would prefix path and no longer recognize as none
1436 1436
     } else {
1437
-      $val = preg_replace("/url\(['\"]?([^'\")]+)['\"]?\)/","\\1", trim($val));
1437
+      $val = preg_replace("/url\(['\"]?([^'\")]+)['\"]?\)/", "\\1", trim($val));
1438 1438
 
1439 1439
       // Resolve the url now in the context of the current stylesheet
1440 1440
       $parsed_url = explode_url($val);
1441
-      if ( $parsed_url["protocol"] == "" && $this->_stylesheet->get_protocol() == "" ) {
1442
-        if ($parsed_url["path"]{0} === '/' || $parsed_url["path"]{0} === '\\' ) {
1441
+      if ($parsed_url["protocol"] == "" && $this->_stylesheet->get_protocol() == "") {
1442
+        if ($parsed_url["path"]{0} === '/' || $parsed_url["path"]{0} === '\\') {
1443 1443
           $path = $_SERVER["DOCUMENT_ROOT"].'/';
1444 1444
         } else {
1445 1445
           $path = $this->_stylesheet->get_base_path();
1446 1446
         }
1447
-        $path .= $parsed_url["path"] . $parsed_url["file"];
1447
+        $path .= $parsed_url["path"].$parsed_url["file"];
1448 1448
         $path = realpath($path);
1449 1449
         // If realpath returns FALSE then specifically state that there is no background image
1450 1450
         if (!$path) { $path = 'none'; }
@@ -1459,7 +1459,7 @@  discard block
 block discarded – undo
1459 1459
       print "<pre>[_image\n";
1460 1460
       print_r($parsed_url);
1461 1461
       print $this->_stylesheet->get_protocol()."\n".$this->_stylesheet->get_base_path()."\n".$path."\n";
1462
-      print "_image]</pre>";;
1462
+      print "_image]</pre>"; ;
1463 1463
     }
1464 1464
     return $path;
1465 1465
   }
@@ -1477,7 +1477,7 @@  discard block
 block discarded – undo
1477 1477
   function set_color($colour) {
1478 1478
     $col = $this->munge_colour($colour);
1479 1479
 
1480
-    if ( is_null($col) )
1480
+    if (is_null($col))
1481 1481
       $col = self::$_defaults["color"];
1482 1482
 
1483 1483
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
@@ -1493,7 +1493,7 @@  discard block
 block discarded – undo
1493 1493
    */
1494 1494
   function set_background_color($colour) {
1495 1495
     $col = $this->munge_colour($colour);
1496
-    if ( is_null($col) )
1496
+    if (is_null($col))
1497 1497
       $col = self::$_defaults["background_color"];
1498 1498
 
1499 1499
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
@@ -1520,7 +1520,7 @@  discard block
 block discarded – undo
1520 1520
    * @param string $val
1521 1521
    */
1522 1522
   function set_background_repeat($val) {
1523
-    if ( is_null($val) )
1523
+    if (is_null($val))
1524 1524
       $val = self::$_defaults["background_repeat"];
1525 1525
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1526 1526
     $this->_prop_cache["background_repeat"] = null;
@@ -1534,7 +1534,7 @@  discard block
 block discarded – undo
1534 1534
    * @param string $val
1535 1535
    */
1536 1536
   function set_background_attachment($val) {
1537
-    if ( is_null($val) )
1537
+    if (is_null($val))
1538 1538
       $val = self::$_defaults["background_attachment"];
1539 1539
 
1540 1540
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
@@ -1549,7 +1549,7 @@  discard block
 block discarded – undo
1549 1549
    * @param string $val
1550 1550
    */
1551 1551
   function set_background_position($val) {
1552
-    if ( is_null($val) )
1552
+    if (is_null($val))
1553 1553
       $val = self::$_defaults["background_position"];
1554 1554
 
1555 1555
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
@@ -1568,21 +1568,21 @@  discard block
 block discarded – undo
1568 1568
     $pos = array();
1569 1569
     $tmp = explode(" ", $val);
1570 1570
     $important = isset($this->_important_props["background"]);
1571
-    foreach($tmp as $attr) {
1571
+    foreach ($tmp as $attr) {
1572 1572
 	  if (mb_substr($attr, 0, 3) === "url" || $attr === "none") {
1573 1573
    	    $this->_set_style("background_image", $this->_image($attr), $important);
1574 1574
   	  } else if ($attr === "fixed" || $attr === "scroll") {
1575 1575
    	    $this->_set_style("background_attachment", $attr, $important);
1576 1576
   	  } else if ($attr === "repeat" || $attr === "repeat-x" || $attr === "repeat-y" || $attr === "no-repeat") {
1577 1577
    	    $this->_set_style("background_repeat", $attr, $important);
1578
-      } else if (($col = $this->munge_color($attr)) != null ) {
1578
+      } else if (($col = $this->munge_color($attr)) != null) {
1579 1579
    	    $this->_set_style("background_color", is_array($col) ? $col["hex"] : $col, $important);
1580 1580
       } else {
1581 1581
  		$pos[] = $attr;
1582 1582
  	  }
1583 1583
  	}
1584 1584
  	if (count($pos)) {
1585
- 	  $this->_set_style("background_position",implode(' ',$pos), $important);
1585
+ 	  $this->_set_style("background_position", implode(' ', $pos), $important);
1586 1586
  	}
1587 1587
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1588 1588
 	$this->_prop_cache["background"] = null;
@@ -1636,14 +1636,14 @@  discard block
 block discarded – undo
1636 1636
 
1637 1637
     $important = isset($this->_important_props["font"]);
1638 1638
 
1639
-	if ( preg_match("/^(italic|oblique|normal)\s*(.*)$/i",$val,$match) ) {
1639
+	if (preg_match("/^(italic|oblique|normal)\s*(.*)$/i", $val, $match)) {
1640 1640
 		$this->_set_style("font_style", $match[1], $important);
1641 1641
 		$val = $match[2];
1642 1642
 	} else {
1643 1643
 		$this->_set_style("font_style", self::$_defaults["font_style"], $important);
1644 1644
 	}
1645 1645
 
1646
-	if ( preg_match("/^(small-caps|normal)\s*(.*)$/i",$val,$match) ) {
1646
+	if (preg_match("/^(small-caps|normal)\s*(.*)$/i", $val, $match)) {
1647 1647
 		$this->_set_style("font_variant", $match[1], $important);
1648 1648
 		$val = $match[2];
1649 1649
 	} else {
@@ -1651,8 +1651,8 @@  discard block
 block discarded – undo
1651 1651
 	}
1652 1652
 
1653 1653
     //matching numeric value followed by unit -> this is indeed a subsequent font size. Skip!
1654
-	if ( preg_match("/^(bold|bolder|lighter|100|200|300|400|500|600|700|800|900|normal)\s*(.*)$/i",$val,$match) &&
1655
-         !preg_match("/^(?:pt|px|pc|em|ex|in|cm|mm|%)/",$match[2])
1654
+	if (preg_match("/^(bold|bolder|lighter|100|200|300|400|500|600|700|800|900|normal)\s*(.*)$/i", $val, $match) &&
1655
+         !preg_match("/^(?:pt|px|pc|em|ex|in|cm|mm|%)/", $match[2])
1656 1656
 	   ) {
1657 1657
 		$this->_set_style("font_weight", $match[1], $important);
1658 1658
 		$val = $match[2];
@@ -1660,10 +1660,10 @@  discard block
 block discarded – undo
1660 1660
 		$this->_set_style("font_weight", self::$_defaults["font_weight"], $important);
1661 1661
 	}
1662 1662
 
1663
-	if ( preg_match("/^(xx-small|x-small|small|medium|large|x-large|xx-large|smaller|larger|\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))\s*(.*)$/i",$val,$match) ) {
1663
+	if (preg_match("/^(xx-small|x-small|small|medium|large|x-large|xx-large|smaller|larger|\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))\s*(.*)$/i", $val, $match)) {
1664 1664
 		$this->_set_style("font_size", $match[1], $important);
1665 1665
 		$val = $match[2];
1666
-        if (preg_match("/^\/\s*(\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))\s*(.*)$/i",$val,$match) ) {
1666
+        if (preg_match("/^\/\s*(\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))\s*(.*)$/i", $val, $match)) {
1667 1667
 			$this->_set_style("line_height", $match[1], $important);
1668 1668
 			$val = $match[2];
1669 1669
         } else {
@@ -1674,7 +1674,7 @@  discard block
 block discarded – undo
1674 1674
 		$this->_set_style("line_height", self::$_defaults["line_height"], $important);
1675 1675
 	}
1676 1676
 
1677
-	if(strlen($val) != 0) {
1677
+	if (strlen($val) != 0) {
1678 1678
 	  $this->_set_style("font_family", $val, $important);
1679 1679
 	} else {
1680 1680
 	  $this->_set_style("font_family", self::$_defaults["font_family"], $important);
@@ -1715,24 +1715,24 @@  discard block
 block discarded – undo
1715 1715
    * @param $val
1716 1716
    */
1717 1717
   function set_margin_top($val) {
1718
-    $this->_set_style_side_width_important('margin','top',$val);
1718
+    $this->_set_style_side_width_important('margin', 'top', $val);
1719 1719
   }
1720 1720
 
1721 1721
   function set_margin_right($val) {
1722
-    $this->_set_style_side_width_important('margin','right',$val);
1722
+    $this->_set_style_side_width_important('margin', 'right', $val);
1723 1723
   }
1724 1724
 
1725 1725
   function set_margin_bottom($val) {
1726
-    $this->_set_style_side_width_important('margin','bottom',$val);
1726
+    $this->_set_style_side_width_important('margin', 'bottom', $val);
1727 1727
   }
1728 1728
 
1729 1729
   function set_margin_left($val) {
1730
-    $this->_set_style_side_width_important('margin','left',$val);
1730
+    $this->_set_style_side_width_important('margin', 'left', $val);
1731 1731
   }
1732 1732
   
1733 1733
   function set_margin($val) {
1734 1734
     $val = str_replace("none", "0px", $val);
1735
-    $this->_set_style_type_important('margin','',$val);
1735
+    $this->_set_style_type_important('margin', '', $val);
1736 1736
   }
1737 1737
   /**#@-*/
1738 1738
 
@@ -1743,24 +1743,24 @@  discard block
 block discarded – undo
1743 1743
    * @param $val
1744 1744
    */
1745 1745
   function set_padding_top($val) {
1746
-    $this->_set_style_side_width_important('padding','top',$val);
1746
+    $this->_set_style_side_width_important('padding', 'top', $val);
1747 1747
   }
1748 1748
 
1749 1749
   function set_padding_right($val) {
1750
-    $this->_set_style_side_width_important('padding','right',$val);
1750
+    $this->_set_style_side_width_important('padding', 'right', $val);
1751 1751
   }
1752 1752
 
1753 1753
   function set_padding_bottom($val) {
1754
-    $this->_set_style_side_width_important('padding','bottom',$val);
1754
+    $this->_set_style_side_width_important('padding', 'bottom', $val);
1755 1755
   }
1756 1756
 
1757 1757
   function set_padding_left($val) {
1758
-    $this->_set_style_side_width_important('padding','left',$val);
1758
+    $this->_set_style_side_width_important('padding', 'left', $val);
1759 1759
   }
1760 1760
 
1761 1761
   function set_padding($val) {
1762 1762
     $val = str_replace("none", "0px", $val);
1763
-    $this->_set_style_type_important('padding','',$val);
1763
+    $this->_set_style_type_important('padding', '', $val);
1764 1764
   }
1765 1765
   /**#@-*/
1766 1766
 
@@ -1778,21 +1778,21 @@  discard block
 block discarded – undo
1778 1778
  
1779 1779
     //For consistency of individal and combined properties, and with ie8 and firefox3
1780 1780
     //reset all attributes, even if only partially given
1781
-    $this->_set_style_side_type('border',$side,'_style',self::$_defaults['border_'.$side.'_style'],$important);
1782
-    $this->_set_style_side_type('border',$side,'_width',self::$_defaults['border_'.$side.'_width'],$important);
1783
-    $this->_set_style_side_type('border',$side,'_color',self::$_defaults['border_'.$side.'_color'],$important);
1781
+    $this->_set_style_side_type('border', $side, '_style', self::$_defaults['border_'.$side.'_style'], $important);
1782
+    $this->_set_style_side_type('border', $side, '_width', self::$_defaults['border_'.$side.'_width'], $important);
1783
+    $this->_set_style_side_type('border', $side, '_color', self::$_defaults['border_'.$side.'_color'], $important);
1784 1784
 
1785 1785
     foreach ($arr as $value) {
1786 1786
       $value = trim($value);
1787
-      if ( in_array($value, self::$BORDER_STYLES) ) {
1788
-        $this->_set_style_side_type('border',$side,'_style',$value,$important);
1787
+      if (in_array($value, self::$BORDER_STYLES)) {
1788
+        $this->_set_style_side_type('border', $side, '_style', $value, $important);
1789 1789
 
1790
-      } else if ( preg_match("/[.0-9]+(?:px|pt|pc|em|ex|%|in|mm|cm)|(?:thin|medium|thick)/", $value ) ) {
1791
-        $this->_set_style_side_type('border',$side,'_width',$value,$important);
1790
+      } else if (preg_match("/[.0-9]+(?:px|pt|pc|em|ex|%|in|mm|cm)|(?:thin|medium|thick)/", $value)) {
1791
+        $this->_set_style_side_type('border', $side, '_width', $value, $important);
1792 1792
 
1793 1793
       } else {
1794 1794
         // must be colour
1795
-        $this->_set_style_side_type('border',$side,'_color',$value,$important);
1795
+        $this->_set_style_side_type('border', $side, '_color', $value, $important);
1796 1796
       }
1797 1797
     }
1798 1798
 
@@ -1824,15 +1824,15 @@  discard block
 block discarded – undo
1824 1824
   }
1825 1825
 
1826 1826
   function set_border_width($val) {
1827
-    $this->_set_style_type_important('border','_width',$val);
1827
+    $this->_set_style_type_important('border', '_width', $val);
1828 1828
   }
1829 1829
 
1830 1830
   function set_border_color($val) {
1831
-    $this->_set_style_type_important('border','_color',$val);
1831
+    $this->_set_style_type_important('border', '_color', $val);
1832 1832
   }
1833 1833
 
1834 1834
   function set_border_style($val) {
1835
-    $this->_set_style_type_important('border','_style',$val);
1835
+    $this->_set_style_type_important('border', '_style', $val);
1836 1836
   }
1837 1837
   /**#@-*/
1838 1838
 
@@ -1847,12 +1847,12 @@  discard block
 block discarded – undo
1847 1847
 
1848 1848
     $arr = explode(" ", $val);
1849 1849
 
1850
-    if ( count($arr) == 1 )
1850
+    if (count($arr) == 1)
1851 1851
       $arr[1] = $arr[0];
1852 1852
 
1853 1853
     //see __set and __get, on all assignments clear cache, not needed on direct set through __set
1854 1854
 	$this->_prop_cache["border_spacing"] = null;
1855
-    $this->_props["border_spacing"] = $arr[0] . " " . $arr[1];
1855
+    $this->_props["border_spacing"] = $arr[0]." ".$arr[1];
1856 1856
   }
1857 1857
 
1858 1858
   /**
@@ -1907,9 +1907,9 @@  discard block
 block discarded – undo
1907 1907
         continue;
1908 1908
       }
1909 1909
 
1910
-      if ( in_array($value, $types) ) {
1910
+      if (in_array($value, $types)) {
1911 1911
    	    $this->_set_style("list_style_type", $value, $important);
1912
-      } else if ( in_array($value, $positions) ) {
1912
+      } else if (in_array($value, $positions)) {
1913 1913
    	    $this->_set_style("list_style_position", $value, $important);
1914 1914
       }
1915 1915
     }
@@ -1935,8 +1935,8 @@  discard block
 block discarded – undo
1935 1935
 
1936 1936
 /*DEBUGCSS*/  function debug_print()
1937 1937
 /*DEBUGCSS*/  {
1938
-/*DEBUGCSS*/    print "parent_font_size:".$this->_parent_font_size . ";\n";
1939
-/*DEBUGCSS*/    foreach($this->_props as $prop => $val ) {
1938
+/*DEBUGCSS*/    print "parent_font_size:".$this->_parent_font_size.";\n";
1939
+/*DEBUGCSS*/    foreach ($this->_props as $prop => $val) {
1940 1940
 /*DEBUGCSS*/      print $prop.':'.$val;
1941 1941
 /*DEBUGCSS*/      if (isset($this->_important_props[$prop])) {
1942 1942
 /*DEBUGCSS*/      	print '!important';
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/table_frame_reflower.cls.php 1 patch
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
     $absolute_used = $this->_state["absolute_used"];
81 81
     $auto_min = $this->_state["auto_min"];
82 82
 
83
-    $absolute =& $this->_state["absolute"];
84
-    $percent =& $this->_state["percent"];
85
-    $auto =& $this->_state["auto"];
83
+    $absolute = & $this->_state["absolute"];
84
+    $percent = & $this->_state["percent"];
85
+    $auto = & $this->_state["auto"];
86 86
 
87 87
     // Determine the actual width of the table
88 88
     $cb = $this->_frame->get_containing_block();
89
-    $columns =& $this->_frame->get_cellmap()->get_columns();
89
+    $columns = & $this->_frame->get_cellmap()->get_columns();
90 90
 
91 91
     $width = $style->width;
92 92
 
@@ -102,34 +102,34 @@  discard block
 block discarded – undo
102 102
                                                          $style->border_right_width,
103 103
                                                          $style->padding_right), $cb["w"]);
104 104
 
105
-    $min_table_width = $style->length_in_pt( $style->min_width, $cb["w"] - $delta );
105
+    $min_table_width = $style->length_in_pt($style->min_width, $cb["w"] - $delta);
106 106
 
107 107
     // min & max widths already include borders & padding
108 108
     $min_width -= $delta;
109 109
     $max_width -= $delta;
110 110
     
111
-    if ( $width !== "auto" ) {
111
+    if ($width !== "auto") {
112 112
 
113 113
       $preferred_width = $style->length_in_pt($width, $cb["w"]) - $delta;
114 114
 
115
-      if ( $preferred_width < $min_table_width )
115
+      if ($preferred_width < $min_table_width)
116 116
         $preferred_width = $min_table_width;
117 117
 
118
-      if ( $preferred_width > $min_width )
118
+      if ($preferred_width > $min_width)
119 119
         $width = $preferred_width;
120 120
       else
121 121
         $width = $min_width;
122 122
 
123 123
     } else {
124 124
 
125
-      if ( $max_width + $delta < $cb["w"] )
125
+      if ($max_width + $delta < $cb["w"])
126 126
         $width = $max_width;
127
-      else if ( $cb["w"] - $delta > $min_width )
127
+      else if ($cb["w"] - $delta > $min_width)
128 128
         $width = $cb["w"] - $delta;
129 129
       else
130 130
         $width = $min_width;
131 131
 
132
-      if ( $width < $min_table_width )
132
+      if ($width < $min_table_width)
133 133
         $width = $min_table_width;
134 134
 
135 135
     }
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     $cellmap = $this->_frame->get_cellmap();
141 141
 
142 142
     // If the whole table fits on the page, then assign each column it's max width
143
-    if ( $width == $max_width ) {
143
+    if ($width == $max_width) {
144 144
 
145 145
       foreach (array_keys($columns) as $i)
146 146
         $cellmap->set_column_width($i, $columns[$i]["max-width"]);
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
     }
150 150
 
151 151
     // Determine leftover and assign it evenly to all columns
152
-    if ( $width > $min_width ) {
152
+    if ($width > $min_width) {
153 153
 
154 154
       // We have four cases to deal with:
155 155
       //
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
       // 4. Both absolute and percentage widths have been specified.
169 169
 
170 170
       // Case 1:
171
-      if ( $absolute_used == 0 && $percent_used == 0 ) {
171
+      if ($absolute_used == 0 && $percent_used == 0) {
172 172
         $increment = $width - $min_width;
173 173
 
174 174
         foreach (array_keys($columns) as $i)
@@ -178,17 +178,17 @@  discard block
 block discarded – undo
178 178
 
179 179
 
180 180
       // Case 2
181
-      if ( $absolute_used > 0 && $percent_used == 0 ) {
181
+      if ($absolute_used > 0 && $percent_used == 0) {
182 182
 
183
-        if ( count($auto) > 0 )
183
+        if (count($auto) > 0)
184 184
           $increment = ($width - $auto_min - $absolute_used) / count($auto);
185 185
 
186 186
         // Use the absolutely specified width or the increment
187 187
         foreach (array_keys($columns) as $i) {
188 188
 
189
-          if ( $columns[$i]["absolute"] > 0 && count($auto) )
189
+          if ($columns[$i]["absolute"] > 0 && count($auto))
190 190
             $cellmap->set_column_width($i, $columns[$i]["min-width"]);
191
-          else if ( count($auto) ) 
191
+          else if (count($auto)) 
192 192
             $cellmap->set_column_width($i, $columns[$i]["min-width"] + $increment);
193 193
           else {
194 194
             // All absolute columns
@@ -203,14 +203,14 @@  discard block
 block discarded – undo
203 203
 
204 204
 
205 205
       // Case 3:
206
-      if ( $absolute_used == 0 && $percent_used > 0 ) {
206
+      if ($absolute_used == 0 && $percent_used > 0) {
207 207
 
208 208
         $scale = null;
209 209
         $remaining = null;
210 210
 
211 211
         // Scale percent values if the total percentage is > 100, or if all
212 212
         // values are specified as percentages.
213
-        if ( $percent_used > 100 || count($auto) == 0)
213
+        if ($percent_used > 100 || count($auto) == 0)
214 214
           $scale = 100 / $percent_used;
215 215
         else
216 216
           $scale = 1;
@@ -223,9 +223,9 @@  discard block
 block discarded – undo
223 223
 
224 224
           $slack = $width - $used_width;
225 225
 
226
-          $w = min($columns[$i]["percent"] * $width/100, $slack);
226
+          $w = min($columns[$i]["percent"] * $width / 100, $slack);
227 227
 
228
-          if ( $w < $columns[$i]["min-width"] )
228
+          if ($w < $columns[$i]["min-width"])
229 229
             $w = $columns[$i]["min-width"];
230 230
 
231 231
           $cellmap->set_column_width($i, $w);
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 
236 236
         // This works because $used_width includes the min-width of each
237 237
         // unassigned column
238
-        if ( count($auto) > 0 ) {
238
+        if (count($auto) > 0) {
239 239
           $increment = ($width - $used_width) / count($auto);
240 240
 
241 241
           foreach ($auto as $i)
@@ -248,18 +248,18 @@  discard block
 block discarded – undo
248 248
       // Case 4:
249 249
 
250 250
       // First-come, first served
251
-      if ( $absolute_used > 0 && $percent_used > 0 ) {
251
+      if ($absolute_used > 0 && $percent_used > 0) {
252 252
 
253 253
         $used_width = $auto_min;
254 254
 
255 255
         foreach ($absolute as $i) {
256 256
           $cellmap->set_column_width($i, $columns[$i]["min-width"]);
257
-          $used_width +=  $columns[$i]["min-width"];
257
+          $used_width += $columns[$i]["min-width"];
258 258
         }
259 259
 
260 260
         // Scale percent values if the total percentage is > 100 or there
261 261
         // are no auto values to take up slack
262
-        if ( $percent_used > 100 || count($auto) == 0 )
262
+        if ($percent_used > 100 || count($auto) == 0)
263 263
           $scale = 100 / $percent_used;
264 264
         else
265 265
           $scale = 1;
@@ -272,14 +272,14 @@  discard block
 block discarded – undo
272 272
           $columns[$i]["percent"] *= $scale;
273 273
           $w = min($columns[$i]["percent"] * $remaining_width / 100, $slack);
274 274
 
275
-          if ( $w < $columns[$i]["min-width"] )
275
+          if ($w < $columns[$i]["min-width"])
276 276
             $w = $columns[$i]["min-width"];
277 277
 
278 278
           $columns[$i]["used-width"] = $w;
279 279
           $used_width += $w;
280 280
         }
281 281
 
282
-        if ( count($auto) > 0 ) {
282
+        if (count($auto) > 0) {
283 283
           $increment = ($width - $used_width) / count($auto);
284 284
 
285 285
           foreach ($auto as $i)
@@ -314,56 +314,56 @@  discard block
 block discarded – undo
314 314
 
315 315
     // Determine our content height
316 316
     $content_height = 0;
317
-    foreach ( $rows as $r )
317
+    foreach ($rows as $r)
318 318
       $content_height += $r["height"];
319 319
 
320 320
     $cb = $this->_frame->get_containing_block();
321 321
 
322
-    if ( !($style->overflow === "visible" ||
323
-           ($style->overflow === "hidden" && $height === "auto")) ) {
322
+    if (!($style->overflow === "visible" ||
323
+           ($style->overflow === "hidden" && $height === "auto"))) {
324 324
 
325 325
       // Only handle min/max height if the height is independent of the frame's content
326 326
 
327 327
       $min_height = $style->min_height;
328 328
       $max_height = $style->max_height;
329 329
 
330
-      if ( isset($cb["h"]) ) {
330
+      if (isset($cb["h"])) {
331 331
         $min_height = $style->length_in_pt($min_height, $cb["h"]);
332 332
         $max_height = $style->length_in_pt($max_height, $cb["h"]);
333 333
 
334
-      } else if ( isset($cb["w"]) ) {
334
+      } else if (isset($cb["w"])) {
335 335
 
336
-        if ( mb_strpos($min_height, "%") !== false )
336
+        if (mb_strpos($min_height, "%") !== false)
337 337
           $min_height = 0;
338 338
         else
339 339
           $min_height = $style->length_in_pt($min_height, $cb["w"]);
340 340
 
341
-        if ( mb_strpos($max_height, "%") !== false )
341
+        if (mb_strpos($max_height, "%") !== false)
342 342
           $max_height = "none";
343 343
         else
344 344
           $max_height = $style->length_in_pt($max_height, $cb["w"]);
345 345
       }
346 346
 
347
-      if ( $max_height !== "none" && $min_height > $max_height )
347
+      if ($max_height !== "none" && $min_height > $max_height)
348 348
         // Swap 'em
349 349
         list($max_height, $min_height) = array($min_height, $max_height);
350 350
 
351
-      if ( $max_height !== "none" && $height > $max_height )
351
+      if ($max_height !== "none" && $height > $max_height)
352 352
         $height = $max_height;
353 353
 
354
-      if ( $height < $min_height )
354
+      if ($height < $min_height)
355 355
         $height = $min_height;
356 356
 
357 357
     } else {
358 358
 
359 359
       // Use the content height or the height value, whichever is greater
360
-      if ( $height !== "auto" ) {
360
+      if ($height !== "auto") {
361 361
         $height = $style->length_in_pt($height, $cb["h"]);
362 362
 
363
-        if ( $height <= $content_height )
363
+        if ($height <= $content_height)
364 364
           $height = $content_height;
365 365
         else
366
-          $cellmap->set_frame_heights($height,$content_height);
366
+          $cellmap->set_frame_heights($height, $content_height);
367 367
 
368 368
       } else
369 369
         $height = $content_height;
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
     $page->check_forced_page_break($this->_frame);
383 383
 
384 384
     // Bail if the page is full
385
-    if ( $page->is_full() )
385
+    if ($page->is_full())
386 386
       return;
387 387
     
388 388
     // Let the page know that we're reflowing a table so that splits
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
     // Table layout algorithm:
401 401
     // http://www.w3.org/TR/CSS21/tables.html#auto-table-layout
402 402
 
403
-    if ( is_null($this->_state) )
403
+    if (is_null($this->_state))
404 404
       $this->get_min_max_width();
405 405
 
406 406
     $cb = $this->_frame->get_containing_block();
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
     // This is slightly inexact, but should be okay.  Add half the
410 410
     // border-spacing to the table as padding.  The other half is added to
411 411
     // the cells themselves.
412
-    if ( $style->border_collapse === "separate" ) {
412
+    if ($style->border_collapse === "separate") {
413 413
       list($h, $v) = $style->border_spacing;
414 414
 
415 415
       $v = $style->length_in_pt($v) / 2;
@@ -431,16 +431,16 @@  discard block
 block discarded – undo
431 431
 
432 432
     $diff = $cb["w"] - $width;
433 433
 
434
-    if ( $left === "auto" && $right === "auto" && $diff > 0 ) {
434
+    if ($left === "auto" && $right === "auto" && $diff > 0) {
435 435
       $left = $right = $diff / 2;
436 436
       $style->margin_left = "$left pt";
437 437
       $style->margin_right = "$right pt";
438 438
 
439 439
     } else {
440
-        if($left === "auto") {
440
+        if ($left === "auto") {
441 441
           $left = $style->length_in_pt($cb["w"] - $right - $width, $cb["w"]);
442 442
         }
443
-        if($right === "auto") {
443
+        if ($right === "auto") {
444 444
           $left = $style->length_in_pt($left, $cb["w"]);
445 445
         }
446 446
     }
@@ -455,32 +455,32 @@  discard block
 block discarded – undo
455 455
                                                  $style->border_top_width,
456 456
                                                  $style->padding_top), $cb["w"]);
457 457
 
458
-    if ( isset($cb["h"]) )
458
+    if (isset($cb["h"]))
459 459
       $h = $cb["h"];
460 460
     else
461 461
       $h = null;
462 462
 
463 463
 
464 464
     $cellmap = $this->_frame->get_cellmap();
465
-    $col =& $cellmap->get_column(0);
465
+    $col = & $cellmap->get_column(0);
466 466
     $col["x"] = $content_x;
467 467
 
468
-    $row =& $cellmap->get_row(0);
468
+    $row = & $cellmap->get_row(0);
469 469
     $row["y"] = $content_y;
470 470
 
471 471
     $cellmap->assign_x_positions();
472 472
 
473 473
     // Set the containing block of each child & reflow
474
-    foreach ( $this->_frame->get_children() as $child ) {
474
+    foreach ($this->_frame->get_children() as $child) {
475 475
 
476 476
       // Bail if the page is full
477
-      if ( !$page->in_nested_table() && $page->is_full() )
477
+      if (!$page->in_nested_table() && $page->is_full())
478 478
         break;
479 479
 
480 480
       $child->set_containing_block($content_x, $content_y, $width, $h);
481 481
       $child->reflow();
482 482
 
483
-      if ( !$page->in_nested_table() )
483
+      if (!$page->in_nested_table())
484 484
         // Check if a split has occured
485 485
         $page->check_page_break($child);
486 486
 
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
     // Assign heights to our cells:
490 490
     $style->height = $this->_calculate_height();
491 491
 
492
-    if ( $style->border_collapse === "collapse" ) {
492
+    if ($style->border_collapse === "collapse") {
493 493
       // Unset our borders because our cells are now using them
494 494
       $style->border_style = "none";
495 495
     }
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 
505 505
   function get_min_max_width() {
506 506
 
507
-    if ( !is_null($this->_min_max_cache)  )
507
+    if (!is_null($this->_min_max_cache))
508 508
       return $this->_min_max_cache;
509 509
 
510 510
     $style = $this->_frame->get_style();
@@ -529,16 +529,16 @@  discard block
 block discarded – undo
529 529
     $this->_state["percent"] = array();
530 530
     $this->_state["auto"] = array();
531 531
 
532
-    $columns =& $this->_frame->get_cellmap()->get_columns();
532
+    $columns = & $this->_frame->get_cellmap()->get_columns();
533 533
     foreach (array_keys($columns) as $i) {
534 534
       $this->_state["min_width"] += $columns[$i]["min-width"];
535 535
       $this->_state["max_width"] += $columns[$i]["max-width"];
536 536
 
537
-      if ( $columns[$i]["absolute"] > 0 ) {
537
+      if ($columns[$i]["absolute"] > 0) {
538 538
         $this->_state["absolute"][] = $i;
539 539
         $this->_state["absolute_used"] += $columns[$i]["absolute"];
540 540
 
541
-      } else if ( $columns[$i]["percent"] > 0 ) {
541
+      } else if ($columns[$i]["percent"] > 0) {
542 542
         $this->_state["percent"][] = $i;
543 543
         $this->_state["percent_used"] += $columns[$i]["percent"];
544 544
 
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
                   $style->margin_left,
557 557
                   $style->margin_right);
558 558
 
559
-    if ( $style->border_collapse !== "collapse" ) 
559
+    if ($style->border_collapse !== "collapse") 
560 560
       list($dims[]) = $style->border_spacing;
561 561
 
562 562
     $delta = $style->length_in_pt($dims, $this->_frame->get_containing_block("w"));
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/load_font.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -43,10 +43,10 @@  discard block
 block discarded – undo
43 43
 /**
44 44
  * @access private
45 45
  */
46
-define("_TTF2AFM", escapeshellarg(TTF2AFM) . " -a -GAef -OW ");
46
+define("_TTF2AFM", escapeshellarg(TTF2AFM)." -a -GAef -OW ");
47 47
 
48
-if ( !file_exists(TTF2AFM) ) {
49
-  die("Unable to locate the ttf2afm / ttf2pt1 executable (checked " . TTF2AFM . ").\n");
48
+if (!file_exists(TTF2AFM)) {
49
+  die("Unable to locate the ttf2afm / ttf2pt1 executable (checked ".TTF2AFM.").\n");
50 50
 }
51 51
 
52 52
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 
88 88
 }
89 89
 
90
-if ( $_SERVER["argc"] < 3 ) {
90
+if ($_SERVER["argc"] < 3) {
91 91
   usage();
92 92
   die();
93 93
 }
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 function install_font_family($fontname, $normal, $bold = null, $italic = null, $bold_italic = null) {
110 110
 
111 111
   // Check if the base filename is readable
112
-  if ( !is_readable($normal) )
112
+  if (!is_readable($normal))
113 113
     throw new DOMPDF_Exception("Unable to read '$normal'.");
114 114
 
115 115
   $dir = dirname($normal);
@@ -125,64 +125,64 @@  discard block
 block discarded – undo
125 125
 
126 126
   // Try $file_Bold.$ext etc.
127 127
 
128
-  if ( !isset($bold) || !is_readable($bold) ) {
129
-    $bold   = $dir . "/" . $file . "_Bold" . $ext;
130
-    if ( !is_readable($bold) ) {
128
+  if (!isset($bold) || !is_readable($bold)) {
129
+    $bold = $dir."/".$file."_Bold".$ext;
130
+    if (!is_readable($bold)) {
131 131
 
132 132
       // Try $file . "b"
133
-      $bold = $dir . "/" . $file . "b" . $ext;
134
-      if ( !is_readable($bold) ) {
133
+      $bold = $dir."/".$file."b".$ext;
134
+      if (!is_readable($bold)) {
135 135
 
136 136
         // Try $file . "B"
137
-        $bold = $dir . "/" . $file . "B" . $ext;
138
-        if ( !is_readable($bold) )
137
+        $bold = $dir."/".$file."B".$ext;
138
+        if (!is_readable($bold))
139 139
           $bold = null;
140 140
       }
141 141
     }
142 142
   }
143 143
 
144
-  if ( is_null($bold) )
144
+  if (is_null($bold))
145 145
     echo ("Unable to find bold face file.\n");
146 146
 
147
-  if ( !isset($italic) || !is_readable($italic) ) {
148
-    $italic = $dir . "/" . $file . "_Italic" . $ext;
149
-    if ( !is_readable($italic) ) {
147
+  if (!isset($italic) || !is_readable($italic)) {
148
+    $italic = $dir."/".$file."_Italic".$ext;
149
+    if (!is_readable($italic)) {
150 150
 
151 151
       // Try $file . "i"
152
-      $italic = $dir . "/" . $file . "i" . $ext;
153
-      if ( !is_readable($italic) ) {
152
+      $italic = $dir."/".$file."i".$ext;
153
+      if (!is_readable($italic)) {
154 154
 
155 155
         // Try $file . "I"
156
-        $italic = $dir . "/" . $file . "I" . $ext;
157
-        if ( !is_readable($italic) )
156
+        $italic = $dir."/".$file."I".$ext;
157
+        if (!is_readable($italic))
158 158
           $italic = null;
159 159
       }
160 160
     }
161 161
   }
162 162
 
163
-  if ( is_null($italic) )
163
+  if (is_null($italic))
164 164
     echo ("Unable to find italic face file.\n");
165 165
 
166
-  if ( !isset($bold_italic) || !is_readable($bold_italic) ) {
167
-    $bold_italic = $dir . "/" . $file . "_Bold_Italic" . $ext;
166
+  if (!isset($bold_italic) || !is_readable($bold_italic)) {
167
+    $bold_italic = $dir."/".$file."_Bold_Italic".$ext;
168 168
 
169
-    if ( !is_readable($bold_italic) ) {
169
+    if (!is_readable($bold_italic)) {
170 170
 
171 171
       // Try $file . "bi"
172
-      $bold_italic = $dir . "/" . $file . "bi" . $ext;
173
-      if ( !is_readable($bold_italic) ) {
172
+      $bold_italic = $dir."/".$file."bi".$ext;
173
+      if (!is_readable($bold_italic)) {
174 174
 
175 175
         // Try $file . "BI"
176
-        $bold_italic = $dir . "/" . $file . "BI" . $ext;
177
-        if ( !is_readable($bold_italic) ) {
176
+        $bold_italic = $dir."/".$file."BI".$ext;
177
+        if (!is_readable($bold_italic)) {
178 178
 
179 179
           // Try $file . "ib"
180
-          $bold_italic = $dir . "/" . $file . "ib" . $ext;
181
-          if ( !is_readable($bold_italic) ) {
180
+          $bold_italic = $dir."/".$file."ib".$ext;
181
+          if (!is_readable($bold_italic)) {
182 182
 
183 183
             // Try $file . "IB"
184
-            $bold_italic = $dir . "/" . $file . "IB" . $ext;
185
-            if ( !is_readable($bold_italic) )
184
+            $bold_italic = $dir."/".$file."IB".$ext;
185
+            if (!is_readable($bold_italic))
186 186
               $bold_italic = null;
187 187
           }
188 188
         }
@@ -190,34 +190,34 @@  discard block
 block discarded – undo
190 190
     }
191 191
   }
192 192
 
193
-  if ( is_null($bold_italic) )
193
+  if (is_null($bold_italic))
194 194
     echo ("Unable to find bold italic face file.\n");
195 195
 
196 196
   $fonts = compact("normal", "bold", "italic", "bold_italic");
197 197
   $entry = array();
198 198
 
199
-  if ( strtolower($ext) === ".pfb" || strtolower($ext) === ".ttf" || strtolower($ext) === ".otf"  ) {
199
+  if (strtolower($ext) === ".pfb" || strtolower($ext) === ".ttf" || strtolower($ext) === ".otf") {
200 200
 
201 201
     // Copy the files to the font directory.
202 202
     foreach ($fonts as $var => $src) {
203 203
 
204
-      if ( is_null($src) ) {
205
-        $entry[$var] = DOMPDF_FONT_DIR . basename($normal);
204
+      if (is_null($src)) {
205
+        $entry[$var] = DOMPDF_FONT_DIR.basename($normal);
206 206
         continue;
207 207
       }
208 208
 
209 209
       // Verify that the fonts exist and are readable
210
-      if ( !is_readable($src) )
210
+      if (!is_readable($src))
211 211
         throw new User_DOMPDF_Exception("Requested font '$pathname' is not readable");
212 212
 
213
-      $dest = DOMPDF_FONT_DIR . basename($src);
214
-      if ( !is_writeable(dirname($dest)) )
213
+      $dest = DOMPDF_FONT_DIR.basename($src);
214
+      if (!is_writeable(dirname($dest)))
215 215
         throw new User_DOMPDF_Exception("Unable to write to destination '$dest'.");
216 216
 
217 217
       echo "Copying $src to $dest...\n";
218 218
 
219
-      if ( !copy($src, $dest) )
220
-        throw new DOMPDF_Exception("Unable to copy '$src' to '" . DOMPDF_FONT_DIR . "$dest'.");
219
+      if (!copy($src, $dest))
220
+        throw new DOMPDF_Exception("Unable to copy '$src' to '".DOMPDF_FONT_DIR."$dest'.");
221 221
 
222 222
       $entry[$var] = $dest;
223 223
     }
@@ -227,16 +227,16 @@  discard block
 block discarded – undo
227 227
 
228 228
 
229 229
   // If the extension is a ttf, try and convert the fonts to afm too
230
-  if ( mb_strtolower($ext) === ".ttf" || strtolower($ext) === ".otf" ) {
230
+  if (mb_strtolower($ext) === ".ttf" || strtolower($ext) === ".otf") {
231 231
     foreach ($fonts as $var => $font) {
232
-      if ( is_null($font) ) {
233
-        $entry[$var] = DOMPDF_FONT_DIR . mb_substr(basename($normal), 0, -4);
232
+      if (is_null($font)) {
233
+        $entry[$var] = DOMPDF_FONT_DIR.mb_substr(basename($normal), 0, -4);
234 234
         continue;
235 235
       }
236
-      $dest = DOMPDF_FONT_DIR . mb_substr(basename($font),0, -4);
236
+      $dest = DOMPDF_FONT_DIR.mb_substr(basename($font), 0, -4);
237 237
       echo "Generating .afm for $font...\n";
238
-      echo "Command: " . _TTF2AFM . " " . escapeshellarg($font) . " " . escapeshellarg($dest) . "\n";
239
-      exec( _TTF2AFM . " " . escapeshellarg($font) . " " . escapeshellarg($dest) . " &> /dev/null", $output, $ret );
238
+      echo "Command: "._TTF2AFM." ".escapeshellarg($font)." ".escapeshellarg($dest)."\n";
239
+      exec(_TTF2AFM." ".escapeshellarg($font)." ".escapeshellarg($dest)." &> /dev/null", $output, $ret);
240 240
 
241 241
       $entry[$var] = $dest;
242 242
     }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/lib/class.pdf.php 1 patch
Spacing   +1069 added lines, -1069 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
   /**
58 58
    * this array contains all of the pdf objects, ready for final assembly
59 59
    */
60
-  public  $objects =  array();
60
+  public  $objects = array();
61 61
 
62 62
   /**
63 63
    * the objectId (number within the objects array) of the document catalog
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
   /**
115 115
    * Number of graphic state resources used
116 116
    */
117
-  private  $numStates =  0;
117
+  private  $numStates = 0;
118 118
 
119 119
 
120 120
   /**
@@ -146,12 +146,12 @@  discard block
 block discarded – undo
146 146
    * an array which is used to save the state of the document, mainly the colours and styles
147 147
    * it is used to temporarily change to another state, the change back to what it was before
148 148
    */
149
-  public  $stateStack =  array();
149
+  public  $stateStack = array();
150 150
 
151 151
   /**
152 152
    * number of elements within the state stack
153 153
    */
154
-  public  $nStateStack =  0;
154
+  public  $nStateStack = 0;
155 155
 
156 156
   /**
157 157
    * number of page objects within the document
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
    * this used so that the code knows which font is the bold version of another font, etc.
218 218
    * the value of this array is initialised in the constuctor function.
219 219
    */
220
-  public  $fontFamilies =  array();
220
+  public  $fontFamilies = array();
221 221
  
222 222
   /**
223 223
    * folder for php serialized formats of font metrics files.
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
   /**
246 246
    * track if the current font is bolded or italicised
247 247
    */
248
-  public  $currentTextState =  '';
248
+  public  $currentTextState = '';
249 249
 
250 250
   /**
251 251
    * messages are stored here during processing, these can be selected afterwards to give some useful debug information
@@ -280,25 +280,25 @@  discard block
 block discarded – undo
280 280
   /**
281 281
    * array which forms a stack to keep track of nested callback functions
282 282
    */
283
-  public  $callback =  array();
283
+  public  $callback = array();
284 284
 
285 285
   /**
286 286
    * the number of callback functions in the callback array
287 287
    */
288
-  public  $nCallback =  0;
288
+  public  $nCallback = 0;
289 289
 
290 290
   /**
291 291
    * store label->id pairs for named destinations, these will be used to replace internal links
292 292
    * done this way so that destinations can be defined after the location that links to them
293 293
    */
294
-  public  $destinations =  array();
294
+  public  $destinations = array();
295 295
 
296 296
   /**
297 297
    * store the stack for the transaction commands, each item in here is a record of the values of all the
298 298
    * publiciables within the class, so that the user can rollback at will (from each 'start' command)
299 299
    * note that this includes the objects array, so these can be large.
300 300
    */
301
-  public  $checkpoint =  '';
301
+  public  $checkpoint = '';
302 302
 
303 303
   /* Table of Image origin filenames and image labels which were already added with o_image().
304 304
    * Allows to merge identical images
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
    * @var array array of 4 numbers, defining the bottom left and upper right corner of the page. first two are normally zero.
319 319
    * @var boolean whether text will be treated as Unicode or not.
320 320
    */
321
-  function  Cpdf ($pageSize = array(0, 0, 612, 792), $isUnicode = false, $fontcache = '', $tmp = '') {
321
+  function  Cpdf($pageSize = array(0, 0, 612, 792), $isUnicode = false, $fontcache = '', $tmp = '') {
322 322
     $this->isUnicode = $isUnicode;
323 323
     $this->fontcache = $fontcache;
324 324
     $this->tmp = $tmp;
@@ -349,33 +349,33 @@  discard block
 block discarded – undo
349 349
    *destination object, used to specify the location for the user to jump to, presently on opening
350 350
    */
351 351
   protected function  o_destination($id, $action, $options = '') {
352
-    if  ($action !== 'new') {
352
+    if ($action !== 'new') {
353 353
       $o = & $this->objects[$id];
354 354
     }
355 355
 
356 356
     switch ($action) {
357 357
     case  'new':
358 358
       $this->objects[$id] = array('t'=>'destination', 'info'=>array());
359
-      $tmp =  '';
360
-      switch  ($options['type']) {
359
+      $tmp = '';
360
+      switch ($options['type']) {
361 361
       case  'XYZ':
362 362
       case  'FitR':
363
-        $tmp =   ' '.$options['p3'].$tmp;
363
+        $tmp = ' '.$options['p3'].$tmp;
364 364
       case  'FitH':
365 365
       case  'FitV':
366 366
       case  'FitBH':
367 367
       case  'FitBV':
368
-        $tmp =   ' '.$options['p1'].' '.$options['p2'].$tmp;
368
+        $tmp = ' '.$options['p1'].' '.$options['p2'].$tmp;
369 369
       case  'Fit':
370 370
       case  'FitB':
371
-        $tmp =   $options['type'].$tmp;
371
+        $tmp = $options['type'].$tmp;
372 372
         $this->objects[$id]['info']['string'] = $tmp;
373 373
         $this->objects[$id]['info']['page'] = $options['page'];
374 374
       }
375 375
       break;
376 376
 
377 377
     case  'out':
378
-      $tmp =  $o['info'];
378
+      $tmp = $o['info'];
379 379
       $res = "\n".$id." 0 obj\n".'['.$tmp['page'].' 0 R /'.$tmp['string']."]\nendobj";
380 380
       return  $res;
381 381
     }
@@ -386,18 +386,18 @@  discard block
 block discarded – undo
386 386
    * set the viewer preferences
387 387
    */
388 388
   protected function  o_viewerPreferences($id, $action, $options = '') {
389
-    if  ($action !== 'new') {
389
+    if ($action !== 'new') {
390 390
       $o = & $this->objects[$id];
391 391
     }
392 392
 
393
-    switch  ($action) {
393
+    switch ($action) {
394 394
     case  'new':
395 395
       $this->objects[$id] = array('t'=>'viewerPreferences', 'info'=>array());
396 396
       break;
397 397
 
398 398
     case  'add':
399
-      foreach($options as  $k=>$v) {
400
-        switch  ($k) {
399
+      foreach ($options as  $k=>$v) {
400
+        switch ($k) {
401 401
         case  'HideToolbar':
402 402
         case  'HideMenubar':
403 403
         case  'HideWindowUI':
@@ -413,10 +413,10 @@  discard block
 block discarded – undo
413 413
 
414 414
     case  'out':
415 415
       $res = "\n".$id." 0 obj\n".'<< ';
416
-      foreach($o['info'] as  $k=>$v) {
417
-        $res.= "\n/".$k.' '.$v;
416
+      foreach ($o['info'] as  $k=>$v) {
417
+        $res .= "\n/".$k.' '.$v;
418 418
       }
419
-      $res.= "\n>>\n";
419
+      $res .= "\n>>\n";
420 420
       return  $res;
421 421
     }
422 422
   }
@@ -426,11 +426,11 @@  discard block
 block discarded – undo
426 426
    * define the document catalog, the overall controller for the document
427 427
    */
428 428
   protected function  o_catalog($id, $action, $options = '') {
429
-    if  ($action !== 'new') {
429
+    if ($action !== 'new') {
430 430
       $o = & $this->objects[$id];
431 431
     }
432 432
 
433
-    switch  ($action) {
433
+    switch ($action) {
434 434
     case  'new':
435 435
       $this->objects[$id] = array('t'=>'catalog', 'info'=>array());
436 436
       $this->catalogId = $id;
@@ -444,13 +444,13 @@  discard block
 block discarded – undo
444 444
       break;
445 445
 
446 446
     case  'viewerPreferences':
447
-      if  (!isset($o['info']['viewerPreferences'])) {
447
+      if (!isset($o['info']['viewerPreferences'])) {
448 448
         $this->numObj++;
449 449
         $this->o_viewerPreferences($this->numObj, 'new');
450 450
         $o['info']['viewerPreferences'] = $this->numObj;
451 451
       }
452 452
 
453
-      $vp =  $o['info']['viewerPreferences'];
453
+      $vp = $o['info']['viewerPreferences'];
454 454
       $this->o_viewerPreferences($vp, 'add', $options);
455 455
 
456 456
       break;
@@ -458,31 +458,31 @@  discard block
 block discarded – undo
458 458
     case  'out':
459 459
       $res = "\n".$id." 0 obj\n".'<< /Type /Catalog';
460 460
 
461
-      foreach($o['info'] as  $k=>$v) {
461
+      foreach ($o['info'] as  $k=>$v) {
462 462
         switch ($k) {
463 463
         case  'outlines':
464
-          $res.= "\n".'/Outlines '.$v.' 0 R';
464
+          $res .= "\n".'/Outlines '.$v.' 0 R';
465 465
           break;
466 466
           
467 467
         case  'pages':
468
-          $res.= "\n".'/Pages '.$v.' 0 R';
468
+          $res .= "\n".'/Pages '.$v.' 0 R';
469 469
           break;
470 470
 
471 471
         case  'viewerPreferences':
472
-          $res.= "\n".'/ViewerPreferences '.$v.' 0 R';
472
+          $res .= "\n".'/ViewerPreferences '.$v.' 0 R';
473 473
           break;
474 474
 
475 475
         case  'openHere':
476
-          $res.= "\n".'/OpenAction '.$v.' 0 R';
476
+          $res .= "\n".'/OpenAction '.$v.' 0 R';
477 477
           break;
478 478
 
479 479
         case  'javascript':
480
-          $res.= "\n".'/Names <</JavaScript '.$v.' 0 R>>';
480
+          $res .= "\n".'/Names <</JavaScript '.$v.' 0 R>>';
481 481
           break;
482 482
         }
483 483
       }
484 484
 
485
-      $res.= " >>\nendobj";
485
+      $res .= " >>\nendobj";
486 486
       return  $res;
487 487
     }
488 488
   }
@@ -492,36 +492,36 @@  discard block
 block discarded – undo
492 492
    * object which is a parent to the pages in the document
493 493
    */
494 494
   protected function  o_pages($id, $action, $options = '') {
495
-    if  ($action !== 'new') {
495
+    if ($action !== 'new') {
496 496
       $o = & $this->objects[$id];
497 497
     }
498 498
 
499
-    switch  ($action) {
499
+    switch ($action) {
500 500
     case  'new':
501 501
       $this->objects[$id] = array('t'=>'pages', 'info'=>array());
502 502
       $this->o_catalog($this->catalogId, 'pages', $id);
503 503
       break;
504 504
 
505 505
     case  'page':
506
-      if  (!is_array($options)) {
506
+      if (!is_array($options)) {
507 507
         // then it will just be the id of the new page
508 508
         $o['info']['pages'][] = $options;
509 509
       } else {
510 510
         // then it should be an array having 'id','rid','pos', where rid=the page to which this one will be placed relative
511 511
         // and pos is either 'before' or 'after', saying where this page will fit.
512
-        if  (isset($options['id']) &&  isset($options['rid']) &&  isset($options['pos'])) {
513
-          $i =  array_search($options['rid'], $o['info']['pages']);
514
-          if  (isset($o['info']['pages'][$i]) &&  $o['info']['pages'][$i] == $options['rid']) {
512
+        if (isset($options['id']) && isset($options['rid']) && isset($options['pos'])) {
513
+          $i = array_search($options['rid'], $o['info']['pages']);
514
+          if (isset($o['info']['pages'][$i]) && $o['info']['pages'][$i] == $options['rid']) {
515 515
 
516 516
             // then there is a match
517 517
             // make a space
518
-            switch  ($options['pos']) {
518
+            switch ($options['pos']) {
519 519
             case  'before':
520
-              $k =  $i;
520
+              $k = $i;
521 521
               break;
522 522
 
523 523
             case  'after':
524
-              $k = $i+1;
524
+              $k = $i + 1;
525 525
               break;
526 526
 
527 527
             default:
@@ -529,9 +529,9 @@  discard block
 block discarded – undo
529 529
               break;
530 530
             }
531 531
 
532
-            if  ($k >= 0) {
533
-              for  ($j = count($o['info']['pages']) -1;$j >= $k;$j--) {
534
-                $o['info']['pages'][$j+1] = $o['info']['pages'][$j];
532
+            if ($k >= 0) {
533
+              for ($j = count($o['info']['pages']) - 1; $j >= $k; $j--) {
534
+                $o['info']['pages'][$j + 1] = $o['info']['pages'][$j];
535 535
               }
536 536
 
537 537
               $o['info']['pages'][$k] = $options['id'];
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
       break;
556 556
 
557 557
     case  'extGState':
558
-      $o['info']['extGStates'][] =  array('objNum' => $options['objNum'],  'stateNum' => $options['stateNum']);
558
+      $o['info']['extGStates'][] = array('objNum' => $options['objNum'], 'stateNum' => $options['stateNum']);
559 559
       break;
560 560
 
561 561
     case  'xObject':
@@ -563,55 +563,55 @@  discard block
 block discarded – undo
563 563
       break;
564 564
 
565 565
     case  'out':
566
-      if  (count($o['info']['pages'])) {
566
+      if (count($o['info']['pages'])) {
567 567
         $res = "\n".$id." 0 obj\n<< /Type /Pages\n/Kids [";
568
-        foreach($o['info']['pages'] as  $k=>$v) {
569
-          $res.= $v." 0 R\n";
568
+        foreach ($o['info']['pages'] as  $k=>$v) {
569
+          $res .= $v." 0 R\n";
570 570
         }
571 571
 
572
-        $res.= "]\n/Count ".count($this->objects[$id]['info']['pages']);
572
+        $res .= "]\n/Count ".count($this->objects[$id]['info']['pages']);
573 573
 
574
-        if  ( (isset($o['info']['fonts']) &&  count($o['info']['fonts'])) ||
574
+        if ((isset($o['info']['fonts']) && count($o['info']['fonts'])) ||
575 575
               isset($o['info']['procset']) ||
576
-              (isset($o['info']['extGStates']) &&  count($o['info']['extGStates']))) {
577
-          $res.= "\n/Resources <<";
576
+              (isset($o['info']['extGStates']) && count($o['info']['extGStates']))) {
577
+          $res .= "\n/Resources <<";
578 578
 
579
-          if  (isset($o['info']['procset'])) {
580
-            $res.= "\n/ProcSet ".$o['info']['procset']." 0 R";
579
+          if (isset($o['info']['procset'])) {
580
+            $res .= "\n/ProcSet ".$o['info']['procset']." 0 R";
581 581
           }
582 582
 
583
-          if  (isset($o['info']['fonts']) &&  count($o['info']['fonts'])) {
584
-            $res.= "\n/Font << ";
585
-            foreach($o['info']['fonts'] as  $finfo) {
586
-              $res.= "\n/F".$finfo['fontNum']." ".$finfo['objNum']." 0 R";
583
+          if (isset($o['info']['fonts']) && count($o['info']['fonts'])) {
584
+            $res .= "\n/Font << ";
585
+            foreach ($o['info']['fonts'] as  $finfo) {
586
+              $res .= "\n/F".$finfo['fontNum']." ".$finfo['objNum']." 0 R";
587 587
             }
588
-            $res.= "\n>>";
588
+            $res .= "\n>>";
589 589
           }
590 590
 
591
-          if  (isset($o['info']['xObjects']) &&  count($o['info']['xObjects'])) {
592
-            $res.= "\n/XObject << ";
593
-            foreach($o['info']['xObjects'] as  $finfo) {
594
-              $res.= "\n/".$finfo['label']." ".$finfo['objNum']." 0 R";
591
+          if (isset($o['info']['xObjects']) && count($o['info']['xObjects'])) {
592
+            $res .= "\n/XObject << ";
593
+            foreach ($o['info']['xObjects'] as  $finfo) {
594
+              $res .= "\n/".$finfo['label']." ".$finfo['objNum']." 0 R";
595 595
             }
596
-            $res.= "\n>>";
596
+            $res .= "\n>>";
597 597
           }
598 598
 
599
-          if  ( isset($o['info']['extGStates']) &&  count($o['info']['extGStates'])) {
600
-            $res.=  "\n/ExtGState << ";
599
+          if (isset($o['info']['extGStates']) && count($o['info']['extGStates'])) {
600
+            $res .= "\n/ExtGState << ";
601 601
             foreach ($o['info']['extGStates'] as  $gstate) {
602
-              $res.=  "\n/GS" . $gstate['stateNum'] . " " . $gstate['objNum'] . " 0 R";
602
+              $res .= "\n/GS".$gstate['stateNum']." ".$gstate['objNum']." 0 R";
603 603
             }
604
-            $res.=  "\n>>";
604
+            $res .= "\n>>";
605 605
           }
606 606
 
607
-          $res.= "\n>>";
608
-          if  (isset($o['info']['mediaBox'])) {
607
+          $res .= "\n>>";
608
+          if (isset($o['info']['mediaBox'])) {
609 609
             $tmp = $o['info']['mediaBox'];
610
-            $res.= "\n/MediaBox [".sprintf('%.3F', $tmp[0]) .' '.sprintf('%.3F', $tmp[1]) .' '.sprintf('%.3F', $tmp[2]) .' '.sprintf('%.3F', $tmp[3]) .']';
610
+            $res .= "\n/MediaBox [".sprintf('%.3F', $tmp[0]).' '.sprintf('%.3F', $tmp[1]).' '.sprintf('%.3F', $tmp[2]).' '.sprintf('%.3F', $tmp[3]).']';
611 611
           }
612 612
         }
613 613
 
614
-        $res.= "\n >>\nendobj";
614
+        $res .= "\n >>\nendobj";
615 615
       } else {
616 616
         $res = "\n".$id." 0 obj\n<< /Type /Pages\n/Count 0\n>>\nendobj";
617 617
       }
@@ -625,11 +625,11 @@  discard block
 block discarded – undo
625 625
    * define the outlines in the doc, empty for now
626 626
    */
627 627
   protected function  o_outlines($id, $action, $options = '') {
628
-    if  ($action !== 'new') {
628
+    if ($action !== 'new') {
629 629
       $o = & $this->objects[$id];
630 630
     }
631 631
 
632
-    switch  ($action) {
632
+    switch ($action) {
633 633
     case  'new':
634 634
       $this->objects[$id] = array('t'=>'outlines', 'info'=>array('outlines'=>array()));
635 635
       $this->o_catalog($this->catalogId, 'outlines', $id);
@@ -640,13 +640,13 @@  discard block
 block discarded – undo
640 640
       break;
641 641
 
642 642
     case  'out':
643
-      if  (count($o['info']['outlines'])) {
643
+      if (count($o['info']['outlines'])) {
644 644
         $res = "\n".$id." 0 obj\n<< /Type /Outlines /Kids [";
645
-        foreach($o['info']['outlines'] as  $k=>$v) {
646
-          $res.= $v." 0 R ";
645
+        foreach ($o['info']['outlines'] as  $k=>$v) {
646
+          $res .= $v." 0 R ";
647 647
         }
648 648
 
649
-        $res.= "] /Count ".count($o['info']['outlines']) ." >>\nendobj";
649
+        $res .= "] /Count ".count($o['info']['outlines'])." >>\nendobj";
650 650
       } else {
651 651
         $res = "\n".$id." 0 obj\n<< /Type /Outlines /Count 0 >>\nendobj";
652 652
       }
@@ -660,40 +660,40 @@  discard block
 block discarded – undo
660 660
    * an object to hold the font description
661 661
    */
662 662
   protected function  o_font($id, $action, $options = '') {
663
-    if  ($action !== 'new') {
663
+    if ($action !== 'new') {
664 664
       $o = & $this->objects[$id];
665 665
     }
666 666
 
667
-    switch  ($action) {
667
+    switch ($action) {
668 668
     case  'new':
669
-      $this->objects[$id] =  array('t' => 'font', 'info' => array('name' => $options['name'], 'fontFileName' => $options['fontFileName'], 'SubType' => 'Type1'));
670
-      $fontNum =  $this->numFonts;
671
-      $this->objects[$id]['info']['fontNum'] =  $fontNum;
669
+      $this->objects[$id] = array('t' => 'font', 'info' => array('name' => $options['name'], 'fontFileName' => $options['fontFileName'], 'SubType' => 'Type1'));
670
+      $fontNum = $this->numFonts;
671
+      $this->objects[$id]['info']['fontNum'] = $fontNum;
672 672
 
673 673
       // deal with the encoding and the differences
674
-      if  (isset($options['differences'])) {
674
+      if (isset($options['differences'])) {
675 675
         // then we'll need an encoding dictionary
676 676
         $this->numObj++;
677 677
         $this->o_fontEncoding($this->numObj, 'new', $options);
678
-        $this->objects[$id]['info']['encodingDictionary'] =  $this->numObj;
679
-      } else  if  (isset($options['encoding'])) {
678
+        $this->objects[$id]['info']['encodingDictionary'] = $this->numObj;
679
+      } else  if (isset($options['encoding'])) {
680 680
         // we can specify encoding here
681 681
         switch ($options['encoding']) {
682 682
         case  'WinAnsiEncoding':
683 683
         case  'MacRomanEncoding':
684 684
         case  'MacExpertEncoding':
685
-          $this->objects[$id]['info']['encoding'] =  $options['encoding'];
685
+          $this->objects[$id]['info']['encoding'] = $options['encoding'];
686 686
           break;
687 687
 
688 688
         case  'none':
689 689
           break;
690 690
 
691 691
         default:
692
-          $this->objects[$id]['info']['encoding'] =  'WinAnsiEncoding';
692
+          $this->objects[$id]['info']['encoding'] = 'WinAnsiEncoding';
693 693
           break;
694 694
         }
695 695
       } else {
696
-        $this->objects[$id]['info']['encoding'] =  'WinAnsiEncoding';
696
+        $this->objects[$id]['info']['encoding'] = 'WinAnsiEncoding';
697 697
       }
698 698
 
699 699
       if ($this->fonts[$options['fontFileName']]['isUnicode']) {
@@ -709,29 +709,29 @@  discard block
 block discarded – undo
709 709
         $this->o_contents($toUnicodeId, 'new', 'raw');
710 710
         $this->objects[$id]['info']['toUnicode'] = $toUnicodeId;
711 711
         
712
-        $stream =  "/CIDInit /ProcSet findresource begin\n";
713
-        $stream.=  "12 dict begin\n";
714
-        $stream.=  "begincmap\n";
715
-        $stream.=  "/CIDSystemInfo\n";
716
-        $stream.=  "<</Registry (Adobe)\n";
717
-        $stream.=  "/Ordering (UCS)\n";
718
-        $stream.=  "/Supplement 0\n";
719
-        $stream.=  ">> def\n";
720
-        $stream.=  "/CMapName /Adobe-Identity-UCS def\n";
721
-        $stream.=  "/CMapType 2 def\n";
722
-        $stream.=  "1 begincodespacerange\n";
723
-        $stream.=  "<0000> <FFFF>\n";
724
-        $stream.=  "endcodespacerange\n";
725
-        $stream.=  "1 beginbfrange\n";
726
-        $stream.=  "<0000> <FFFF> <0000>\n";
727
-        $stream.=  "endbfrange\n";
728
-        $stream.=  "endcmap\n";
729
-        $stream.=  "CMapName currentdict /CMap defineresource pop\n";
730
-        $stream.=  "end\n";
731
-        $stream.=  "end\n";
732
-
733
-        $res =   "<</Length " . mb_strlen($stream, '8bit') . " >>\n";
734
-        $res .=  "stream\n" . $stream . "endstream";
712
+        $stream = "/CIDInit /ProcSet findresource begin\n";
713
+        $stream .= "12 dict begin\n";
714
+        $stream .= "begincmap\n";
715
+        $stream .= "/CIDSystemInfo\n";
716
+        $stream .= "<</Registry (Adobe)\n";
717
+        $stream .= "/Ordering (UCS)\n";
718
+        $stream .= "/Supplement 0\n";
719
+        $stream .= ">> def\n";
720
+        $stream .= "/CMapName /Adobe-Identity-UCS def\n";
721
+        $stream .= "/CMapType 2 def\n";
722
+        $stream .= "1 begincodespacerange\n";
723
+        $stream .= "<0000> <FFFF>\n";
724
+        $stream .= "endcodespacerange\n";
725
+        $stream .= "1 beginbfrange\n";
726
+        $stream .= "<0000> <FFFF> <0000>\n";
727
+        $stream .= "endbfrange\n";
728
+        $stream .= "endcmap\n";
729
+        $stream .= "CMapName currentdict /CMap defineresource pop\n";
730
+        $stream .= "end\n";
731
+        $stream .= "end\n";
732
+
733
+        $res = "<</Length ".mb_strlen($stream, '8bit')." >>\n";
734
+        $res .= "stream\n".$stream."endstream";
735 735
 
736 736
         $this->objects[$toUnicodeId]['c'] = $res;
737 737
 
@@ -746,9 +746,9 @@  discard block
 block discarded – undo
746 746
 
747 747
     case  'add':
748 748
       foreach ($options as  $k => $v) {
749
-        switch  ($k) {
749
+        switch ($k) {
750 750
         case  'BaseFont':
751
-          $o['info']['name'] =  $v;
751
+          $o['info']['name'] = $v;
752 752
           break;
753 753
         case  'FirstChar':
754 754
         case  'LastChar':
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
         case  'FontDescriptor':
757 757
         case  'SubType':
758 758
           $this->addMessage('o_font '.$k." : ".$v);
759
-          $o['info'][$k] =  $v;
759
+          $o['info'][$k] = $v;
760 760
           break;
761 761
         }
762 762
       }
@@ -777,47 +777,47 @@  discard block
 block discarded – undo
777 777
         // All of this code is adapted from the excellent changes made to
778 778
         // transform FPDF to TCPDF (http://tcpdf.sourceforge.net/)
779 779
 
780
-        $res =  "\n".$id." 0 obj\n<</Type /Font\n/Subtype /Type0\n";
781
-        $res.=  "/BaseFont /".$o['info']['name']."\n";
780
+        $res = "\n".$id." 0 obj\n<</Type /Font\n/Subtype /Type0\n";
781
+        $res .= "/BaseFont /".$o['info']['name']."\n";
782 782
 
783 783
         // The horizontal identity mapping for 2-byte CIDs; may be used
784 784
         // with CIDFonts using any Registry, Ordering, and Supplement values.
785
-        $res.=  "/Encoding /Identity-H\n";
786
-        $res.=  "/DescendantFonts [".$o['info']['cidFont']." 0 R]\n";
787
-        $res.=  "/ToUnicode ".$o['info']['toUnicode']." 0 R\n";
788
-        $res.=  ">>\n";
789
-        $res.=  "endobj";
785
+        $res .= "/Encoding /Identity-H\n";
786
+        $res .= "/DescendantFonts [".$o['info']['cidFont']." 0 R]\n";
787
+        $res .= "/ToUnicode ".$o['info']['toUnicode']." 0 R\n";
788
+        $res .= ">>\n";
789
+        $res .= "endobj";
790 790
       } else {
791
-      $res =  "\n".$id." 0 obj\n<< /Type /Font\n/Subtype /".$o['info']['SubType']."\n";
792
-      $res.=  "/Name /F".$o['info']['fontNum']."\n";
793
-      $res.=  "/BaseFont /".$o['info']['name']."\n";
791
+      $res = "\n".$id." 0 obj\n<< /Type /Font\n/Subtype /".$o['info']['SubType']."\n";
792
+      $res .= "/Name /F".$o['info']['fontNum']."\n";
793
+      $res .= "/BaseFont /".$o['info']['name']."\n";
794 794
 
795
-      if  (isset($o['info']['encodingDictionary'])) {
795
+      if (isset($o['info']['encodingDictionary'])) {
796 796
         // then place a reference to the dictionary
797
-        $res.=  "/Encoding ".$o['info']['encodingDictionary']." 0 R\n";
798
-      } else  if  (isset($o['info']['encoding'])) {
797
+        $res .= "/Encoding ".$o['info']['encodingDictionary']." 0 R\n";
798
+      } else  if (isset($o['info']['encoding'])) {
799 799
         // use the specified encoding
800
-        $res.=  "/Encoding /".$o['info']['encoding']."\n";
800
+        $res .= "/Encoding /".$o['info']['encoding']."\n";
801 801
       }
802 802
 
803
-      if  (isset($o['info']['FirstChar'])) {
804
-        $res.=  "/FirstChar ".$o['info']['FirstChar']."\n";
803
+      if (isset($o['info']['FirstChar'])) {
804
+        $res .= "/FirstChar ".$o['info']['FirstChar']."\n";
805 805
       }
806 806
 
807
-      if  (isset($o['info']['LastChar'])) {
808
-        $res.=  "/LastChar ".$o['info']['LastChar']."\n";
807
+      if (isset($o['info']['LastChar'])) {
808
+        $res .= "/LastChar ".$o['info']['LastChar']."\n";
809 809
       }
810 810
 
811
-      if  (isset($o['info']['Widths'])) {
812
-        $res.=  "/Widths ".$o['info']['Widths']." 0 R\n";
811
+      if (isset($o['info']['Widths'])) {
812
+        $res .= "/Widths ".$o['info']['Widths']." 0 R\n";
813 813
       }
814 814
 
815
-      if  (isset($o['info']['FontDescriptor'])) {
816
-        $res.=  "/FontDescriptor ".$o['info']['FontDescriptor']." 0 R\n";
815
+      if (isset($o['info']['FontDescriptor'])) {
816
+        $res .= "/FontDescriptor ".$o['info']['FontDescriptor']." 0 R\n";
817 817
       }
818 818
 
819
-        $res.=  ">>\n";
820
-        $res.=  "endobj";
819
+        $res .= ">>\n";
820
+        $res .= "endobj";
821 821
       }
822 822
 
823 823
       return  $res;
@@ -829,11 +829,11 @@  discard block
 block discarded – undo
829 829
    * a font descriptor, needed for including additional fonts
830 830
    */
831 831
   protected function  o_fontDescriptor($id, $action, $options = '') {
832
-    if  ($action !== 'new') {
832
+    if ($action !== 'new') {
833 833
       $o = & $this->objects[$id];
834 834
     }
835 835
 
836
-    switch  ($action) {
836
+    switch ($action) {
837 837
     case  'new':
838 838
       $this->objects[$id] = array('t'=>'fontDescriptor', 'info'=>$options);
839 839
       break;
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
     case  'out':
842 842
       $res = "\n".$id." 0 obj\n<< /Type /FontDescriptor\n";
843 843
       foreach ($o['info'] as  $label => $value) {
844
-        switch  ($label) {
844
+        switch ($label) {
845 845
         case  'Ascent':
846 846
         case  'CapHeight':
847 847
         case  'Descent':
@@ -855,28 +855,28 @@  discard block
 block discarded – undo
855 855
         case  'StemH':
856 856
         case  'XHeight':
857 857
         case  'CharSet':
858
-          if  (mb_strlen($value, '8bit')) {
859
-            $res.= '/'.$label.' '.$value."\n";
858
+          if (mb_strlen($value, '8bit')) {
859
+            $res .= '/'.$label.' '.$value."\n";
860 860
           }
861 861
 
862 862
           break;
863 863
         case  'FontFile':
864 864
         case  'FontFile2':
865 865
         case  'FontFile3':
866
-          $res.= '/'.$label.' '.$value." 0 R\n";
866
+          $res .= '/'.$label.' '.$value." 0 R\n";
867 867
           break;
868 868
 
869 869
         case  'FontBBox':
870
-          $res.= '/'.$label.' ['.$value[0].' '.$value[1].' '.$value[2].' '.$value[3]."]\n";
870
+          $res .= '/'.$label.' ['.$value[0].' '.$value[1].' '.$value[2].' '.$value[3]."]\n";
871 871
           break;
872 872
 
873 873
         case  'FontName':
874
-          $res.= '/'.$label.' /'.$value."\n";
874
+          $res .= '/'.$label.' /'.$value."\n";
875 875
           break;
876 876
         }
877 877
       }
878 878
 
879
-      $res.= ">>\nendobj";
879
+      $res .= ">>\nendobj";
880 880
 
881 881
       return  $res;
882 882
     }
@@ -887,11 +887,11 @@  discard block
 block discarded – undo
887 887
    * the font encoding
888 888
    */
889 889
   protected function  o_fontEncoding($id, $action, $options = '') {
890
-    if  ($action !== 'new') {
890
+    if ($action !== 'new') {
891 891
       $o = & $this->objects[$id];
892 892
     }
893 893
 
894
-    switch  ($action) {
894
+    switch ($action) {
895 895
     case  'new':
896 896
       // the options array should contain 'differences' and maybe 'encoding'
897 897
       $this->objects[$id] = array('t'=>'fontEncoding', 'info'=>$options);
@@ -899,30 +899,30 @@  discard block
 block discarded – undo
899 899
 
900 900
     case  'out':
901 901
       $res = "\n".$id." 0 obj\n<< /Type /Encoding\n";
902
-      if  (!isset($o['info']['encoding'])) {
902
+      if (!isset($o['info']['encoding'])) {
903 903
         $o['info']['encoding'] = 'WinAnsiEncoding';
904 904
       }
905 905
 
906
-      if  ($o['info']['encoding'] !== 'none') {
907
-        $res.= "/BaseEncoding /".$o['info']['encoding']."\n";
906
+      if ($o['info']['encoding'] !== 'none') {
907
+        $res .= "/BaseEncoding /".$o['info']['encoding']."\n";
908 908
       }
909 909
 
910
-      $res.= "/Differences \n[";
910
+      $res .= "/Differences \n[";
911 911
 
912 912
       $onum = -100;
913 913
 
914
-      foreach($o['info']['differences'] as  $num=>$label) {
915
-        if  ($num != $onum+1) {
914
+      foreach ($o['info']['differences'] as  $num=>$label) {
915
+        if ($num != $onum + 1) {
916 916
           // we cannot make use of consecutive numbering
917
-          $res.=  "\n".$num." /".$label;
917
+          $res .= "\n".$num." /".$label;
918 918
         } else {
919
-          $res.=  " /".$label;
919
+          $res .= " /".$label;
920 920
         }
921 921
 
922 922
         $onum = $num;
923 923
       }
924 924
 
925
-      $res.= "\n]\n>>\nendobj";
925
+      $res .= "\n]\n>>\nendobj";
926 926
       return  $res;
927 927
     }
928 928
   }
@@ -932,22 +932,22 @@  discard block
 block discarded – undo
932 932
    * a descendent cid font,  needed for unicode fonts
933 933
    */
934 934
   protected function  o_fontDescendentCID($id, $action, $options = '') {
935
-    if  ($action !== 'new') {
935
+    if ($action !== 'new') {
936 936
       $o = & $this->objects[$id];
937 937
     }
938 938
 
939
-    switch  ($action) {
939
+    switch ($action) {
940 940
     case  'new':
941
-      $this->objects[$id] =  array('t'=>'fontDescendentCID', 'info'=>$options);
941
+      $this->objects[$id] = array('t'=>'fontDescendentCID', 'info'=>$options);
942 942
 
943 943
       // we need a CID system info section
944 944
       $cidSystemInfoId = ++$this->numObj;
945 945
       $this->o_contents($cidSystemInfoId, 'new', 'raw');
946 946
       $this->objects[$id]['info']['cidSystemInfo'] = $cidSystemInfoId;
947
-      $res=   "<</Registry (Adobe)\n"; // A string identifying an issuer of character collections
948
-      $res.=  "/Ordering (UCS)\n"; // A string that uniquely names a character collection issued by a specific registry
949
-      $res.=  "/Supplement 0\n"; // The supplement number of the character collection.
950
-      $res.=  ">>";
947
+      $res = "<</Registry (Adobe)\n"; // A string identifying an issuer of character collections
948
+      $res .= "/Ordering (UCS)\n"; // A string that uniquely names a character collection issued by a specific registry
949
+      $res .= "/Supplement 0\n"; // The supplement number of the character collection.
950
+      $res .= ">>";
951 951
       $this->objects[$cidSystemInfoId]['c'] = $res;
952 952
 
953 953
       // and a CID to GID map
@@ -958,9 +958,9 @@  discard block
 block discarded – undo
958 958
 
959 959
     case  'add':
960 960
       foreach ($options as  $k => $v) {
961
-        switch  ($k) {
961
+        switch ($k) {
962 962
         case  'BaseFont':
963
-          $o['info']['name'] =  $v;
963
+          $o['info']['name'] = $v;
964 964
           break;
965 965
 
966 966
         case  'FirstChar':
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
         case  'FontDescriptor':
970 970
         case  'SubType':
971 971
           $this->addMessage('o_fontDescendentCID '.$k." : ".$v);
972
-          $o['info'][$k] =  $v;
972
+          $o['info'][$k] = $v;
973 973
           break;
974 974
         }
975 975
       }
@@ -979,11 +979,11 @@  discard block
 block discarded – undo
979 979
       break;
980 980
 
981 981
     case  'out':
982
-      $res =  "\n".$id." 0 obj\n";
983
-      $res.=  "<</Type /Font\n";
984
-      $res.=  "/Subtype /CIDFontType2\n";
985
-      $res.=  "/BaseFont /".$o['info']['name']."\n";
986
-      $res.=  "/CIDSystemInfo ".$o['info']['cidSystemInfo']." 0 R\n";
982
+      $res = "\n".$id." 0 obj\n";
983
+      $res .= "<</Type /Font\n";
984
+      $res .= "/Subtype /CIDFontType2\n";
985
+      $res .= "/BaseFont /".$o['info']['name']."\n";
986
+      $res .= "/CIDSystemInfo ".$o['info']['cidSystemInfo']." 0 R\n";
987 987
 //      if  (isset($o['info']['FirstChar'])) {
988 988
 //        $res.=  "/FirstChar ".$o['info']['FirstChar']."\n";
989 989
 //      }
@@ -991,26 +991,26 @@  discard block
 block discarded – undo
991 991
 //      if  (isset($o['info']['LastChar'])) {
992 992
 //        $res.=  "/LastChar ".$o['info']['LastChar']."\n";
993 993
 //      }
994
-      if  (isset($o['info']['FontDescriptor'])) {
995
-        $res.=  "/FontDescriptor ".$o['info']['FontDescriptor']." 0 R\n";
994
+      if (isset($o['info']['FontDescriptor'])) {
995
+        $res .= "/FontDescriptor ".$o['info']['FontDescriptor']." 0 R\n";
996 996
       }
997 997
 
998
-      if  (isset($o['info']['MissingWidth'])) {
999
-        $res.=  "/DW ".$o['info']['MissingWidth']."\n";
998
+      if (isset($o['info']['MissingWidth'])) {
999
+        $res .= "/DW ".$o['info']['MissingWidth']."\n";
1000 1000
       }
1001 1001
 
1002
-      if  (isset($o['info']['fontFileName']) && isset($this->fonts[$o['info']['fontFileName']]['CIDWidths'])) {
1002
+      if (isset($o['info']['fontFileName']) && isset($this->fonts[$o['info']['fontFileName']]['CIDWidths'])) {
1003 1003
         $cid_widths = &$this->fonts[$o['info']['fontFileName']]['CIDWidths'];
1004 1004
         $w = '';
1005 1005
         foreach ($cid_widths as $cid => $width) {
1006 1006
           $w .= $cid.' ['.$width.'] ';
1007 1007
         }
1008
-        $res.=  "/W [".$w."]\n";
1008
+        $res .= "/W [".$w."]\n";
1009 1009
       }
1010 1010
 
1011
-      $res.=  "/CIDToGIDMap ".$o['info']['cidToGidMap']." 0 R\n";
1012
-      $res.=  ">>\n";
1013
-      $res.=  "endobj";
1011
+      $res .= "/CIDToGIDMap ".$o['info']['cidToGidMap']." 0 R\n";
1012
+      $res .= ">>\n";
1013
+      $res .= "endobj";
1014 1014
 
1015 1015
       return  $res;
1016 1016
     }
@@ -1021,13 +1021,13 @@  discard block
 block discarded – undo
1021 1021
    * a font glyph to character map,  needed for unicode fonts
1022 1022
    */
1023 1023
   protected function  o_fontGIDtoCIDMap($id, $action, $options = '') {
1024
-    if  ($action !== 'new') {
1024
+    if ($action !== 'new') {
1025 1025
       $o = & $this->objects[$id];
1026 1026
     }
1027 1027
 
1028
-    switch  ($action) {
1028
+    switch ($action) {
1029 1029
     case  'new':
1030
-      $this->objects[$id] =  array('t'=>'fontGIDtoCIDMap', 'info'=>$options);
1030
+      $this->objects[$id] = array('t'=>'fontGIDtoCIDMap', 'info'=>$options);
1031 1031
       break;
1032 1032
 
1033 1033
     case  'out':
@@ -1036,24 +1036,24 @@  discard block
 block discarded – undo
1036 1036
       $compressed = isset($this->fonts[$o['info']['fontFileName']]['CIDtoGID_Compressed']) &&
1037 1037
                     $this->fonts[$o['info']['fontFileName']]['CIDtoGID_Compressed'];
1038 1038
 
1039
-      if  (!$compressed && isset($o['raw'])) {
1040
-        $res.= $tmp;
1039
+      if (!$compressed && isset($o['raw'])) {
1040
+        $res .= $tmp;
1041 1041
       } else {
1042
-        $res.=  "<<";
1042
+        $res .= "<<";
1043 1043
 
1044
-        if  (!$compressed && function_exists('gzcompress') &&  $this->options['compression']) {
1044
+        if (!$compressed && function_exists('gzcompress') && $this->options['compression']) {
1045 1045
           // then implement ZLIB based compression on this content stream
1046 1046
           $compressed = true;
1047
-          $tmp =  gzcompress($tmp,  6);
1047
+          $tmp = gzcompress($tmp, 6);
1048 1048
         }
1049 1049
         if ($compressed) {
1050
-          $res.= "\n/Filter /FlateDecode";
1050
+          $res .= "\n/Filter /FlateDecode";
1051 1051
         }
1052 1052
 
1053
-        $res.= "\n/Length ".mb_strlen($tmp, '8bit') .">>\nstream\n".$tmp."\nendstream";
1053
+        $res .= "\n/Length ".mb_strlen($tmp, '8bit').">>\nstream\n".$tmp."\nendstream";
1054 1054
       }
1055 1055
 
1056
-      $res.= "\nendobj";
1056
+      $res .= "\nendobj";
1057 1057
       return  $res;
1058 1058
     }
1059 1059
   }
@@ -1063,11 +1063,11 @@  discard block
 block discarded – undo
1063 1063
    * the document procset, solves some problems with printing to old PS printers
1064 1064
    */
1065 1065
   protected function  o_procset($id, $action, $options = '') {
1066
-    if  ($action !== 'new') {
1066
+    if ($action !== 'new') {
1067 1067
       $o = & $this->objects[$id];
1068 1068
     }
1069 1069
 
1070
-    switch  ($action) {
1070
+    switch ($action) {
1071 1071
     case  'new':
1072 1072
       $this->objects[$id] = array('t'=>'procset', 'info'=>array('PDF'=>1, 'Text'=>1));
1073 1073
       $this->o_pages($this->currentNode, 'procset', $id);
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
     case  'add':
1078 1078
       // this is to add new items to the procset list, despite the fact that this is considered
1079 1079
       // obselete, the items are required for printing to some postscript printers
1080
-      switch  ($options) {
1080
+      switch ($options) {
1081 1081
       case  'ImageB':
1082 1082
       case  'ImageC':
1083 1083
       case  'ImageI':
@@ -1089,9 +1089,9 @@  discard block
 block discarded – undo
1089 1089
     case  'out':
1090 1090
       $res = "\n".$id." 0 obj\n[";
1091 1091
       foreach ($o['info'] as  $label=>$val) {
1092
-        $res.= '/'.$label.' ';
1092
+        $res .= '/'.$label.' ';
1093 1093
       }
1094
-      $res.= "]\nendobj";
1094
+      $res .= "]\nendobj";
1095 1095
       return  $res;
1096 1096
     }
1097 1097
   }
@@ -1101,11 +1101,11 @@  discard block
 block discarded – undo
1101 1101
    * define the document information
1102 1102
    */
1103 1103
   protected function  o_info($id, $action, $options = '') {
1104
-    if  ($action !== 'new') {
1104
+    if ($action !== 'new') {
1105 1105
       $o = & $this->objects[$id];
1106 1106
     }
1107 1107
 
1108
-    switch  ($action) {
1108
+    switch ($action) {
1109 1109
     case  'new':
1110 1110
       $this->infoObject = $id;
1111 1111
       $date = 'D:'.@date('Ymd');
@@ -1124,26 +1124,26 @@  discard block
 block discarded – undo
1124 1124
       break;
1125 1125
 
1126 1126
     case  'out':
1127
-      if  ($this->encrypted) {
1127
+      if ($this->encrypted) {
1128 1128
         $this->encryptInit($id);
1129 1129
       }
1130 1130
 
1131 1131
       $res = "\n".$id." 0 obj\n<<\n";
1132 1132
       foreach ($o['info'] as  $k=>$v) {
1133
-        $res.= '/'.$k.' (';
1133
+        $res .= '/'.$k.' (';
1134 1134
         // dates must be outputted as-is, without Unicode transformations
1135 1135
         $raw = ($k === 'CreationDate' || $k === 'ModDate');
1136 1136
         $c = $v;
1137 1137
 
1138
-        if  ($this->encrypted) {
1138
+        if ($this->encrypted) {
1139 1139
           $c = $this->ARC4($c);
1140 1140
         }
1141 1141
 
1142
-        $res.= ($raw) ? $c : $this->filterText($c);
1143
-        $res.= ")\n";
1142
+        $res .= ($raw) ? $c : $this->filterText($c);
1143
+        $res .= ")\n";
1144 1144
       }
1145 1145
 
1146
-      $res.= ">>\nendobj";
1146
+      $res .= ">>\nendobj";
1147 1147
       return  $res;
1148 1148
     }
1149 1149
   }
@@ -1153,13 +1153,13 @@  discard block
 block discarded – undo
1153 1153
    * an action object, used to link to URLS initially
1154 1154
    */
1155 1155
   protected function  o_action($id, $action, $options = '') {
1156
-    if  ($action !== 'new') {
1156
+    if ($action !== 'new') {
1157 1157
       $o = & $this->objects[$id];
1158 1158
     }
1159 1159
 
1160
-    switch  ($action) {
1160
+    switch ($action) {
1161 1161
     case  'new':
1162
-      if  (is_array($options)) {
1162
+      if (is_array($options)) {
1163 1163
         $this->objects[$id] = array('t'=>'action', 'info'=>$options, 'type'=>$options['type']);
1164 1164
       } else {
1165 1165
         // then assume a URI action
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
       break;
1169 1169
 
1170 1170
     case  'out':
1171
-      if  ($this->encrypted) {
1171
+      if ($this->encrypted) {
1172 1172
         $this->encryptInit($id);
1173 1173
       }
1174 1174
 
@@ -1176,22 +1176,22 @@  discard block
 block discarded – undo
1176 1176
       switch ($o['type']) {
1177 1177
       case  'ilink':
1178 1178
         // there will be an 'label' setting, this is the name of the destination
1179
-        $res.= "\n/S /GoTo\n/D ".$this->destinations[(string)$o['info']['label']]." 0 R";
1179
+        $res .= "\n/S /GoTo\n/D ".$this->destinations[(string) $o['info']['label']]." 0 R";
1180 1180
         break;
1181 1181
 
1182 1182
       case  'URI':
1183
-        $res.= "\n/S /URI\n/URI (";
1184
-        if  ($this->encrypted) {
1185
-          $res.= $this->filterText($this->ARC4($o['info']));
1183
+        $res .= "\n/S /URI\n/URI (";
1184
+        if ($this->encrypted) {
1185
+          $res .= $this->filterText($this->ARC4($o['info']));
1186 1186
         } else {
1187
-          $res.= $this->filterText($o['info']);
1187
+          $res .= $this->filterText($o['info']);
1188 1188
         }
1189 1189
 
1190
-        $res.= ")";
1190
+        $res .= ")";
1191 1191
         break;
1192 1192
       }
1193 1193
 
1194
-      $res.= "\n>>\nendobj";
1194
+      $res .= "\n>>\nendobj";
1195 1195
       return  $res;
1196 1196
     }
1197 1197
   }
@@ -1202,14 +1202,14 @@  discard block
 block discarded – undo
1202 1202
    * initially will support just link annotations
1203 1203
    */
1204 1204
   protected function  o_annotation($id, $action, $options = '') {
1205
-    if  ($action !== 'new') {
1205
+    if ($action !== 'new') {
1206 1206
       $o = & $this->objects[$id];
1207 1207
     }
1208 1208
 
1209
-    switch  ($action) {
1209
+    switch ($action) {
1210 1210
     case  'new':
1211 1211
       // add the annotation to the current page
1212
-      $pageId =  $this->currentPage;
1212
+      $pageId = $this->currentPage;
1213 1213
       $this->o_page($pageId, 'annot', $id);
1214 1214
 
1215 1215
       // and add the action object which is going to be required
@@ -1223,7 +1223,7 @@  discard block
 block discarded – undo
1223 1223
 
1224 1224
       case  'ilink':
1225 1225
         // this is to a named internal link
1226
-        $label =  $options['label'];
1226
+        $label = $options['label'];
1227 1227
         $this->objects[$id] = array('t'=>'annotation', 'info'=>$options);
1228 1228
         $this->numObj++;
1229 1229
         $this->o_action($this->numObj, 'new', array('type'=>'ilink', 'label'=>$label));
@@ -1237,20 +1237,20 @@  discard block
 block discarded – undo
1237 1237
       switch ($o['info']['type']) {
1238 1238
       case  'link':
1239 1239
       case  'ilink':
1240
-        $res.=  "\n/Subtype /Link";
1240
+        $res .= "\n/Subtype /Link";
1241 1241
         break;
1242 1242
       }
1243
-      $res.= "\n/A ".$o['info']['actionId']." 0 R";
1244
-      $res.= "\n/Border [0 0 0]";
1245
-      $res.= "\n/H /I";
1246
-      $res.= "\n/Rect [ ";
1243
+      $res .= "\n/A ".$o['info']['actionId']." 0 R";
1244
+      $res .= "\n/Border [0 0 0]";
1245
+      $res .= "\n/H /I";
1246
+      $res .= "\n/Rect [ ";
1247 1247
 
1248
-      foreach($o['info']['rect'] as  $v) {
1249
-        $res.=  sprintf("%.4F ", $v);
1248
+      foreach ($o['info']['rect'] as  $v) {
1249
+        $res .= sprintf("%.4F ", $v);
1250 1250
       }
1251 1251
 
1252
-      $res.= "]";
1253
-      $res.= "\n>>\nendobj";
1252
+      $res .= "]";
1253
+      $res .= "\n>>\nendobj";
1254 1254
       return  $res;
1255 1255
     }
1256 1256
   }
@@ -1260,16 +1260,16 @@  discard block
 block discarded – undo
1260 1260
    * a page object, it also creates a contents object to hold its contents
1261 1261
    */
1262 1262
   protected function  o_page($id, $action, $options = '') {
1263
-    if  ($action !== 'new') {
1263
+    if ($action !== 'new') {
1264 1264
       $o = & $this->objects[$id];
1265 1265
     }
1266 1266
 
1267
-    switch  ($action) {
1267
+    switch ($action) {
1268 1268
     case  'new':
1269 1269
       $this->numPages++;
1270 1270
       $this->objects[$id] = array('t'=>'page', 'info'=>array('parent'=>$this->currentNode, 'pageNum'=>$this->numPages));
1271 1271
 
1272
-      if  (is_array($options)) {
1272
+      if (is_array($options)) {
1273 1273
         // then this must be a page insertion, array should contain 'rid','pos'=[before|after]
1274 1274
         $options['id'] = $id;
1275 1275
         $this->o_pages($this->currentNode, 'page', $options);
@@ -1285,9 +1285,9 @@  discard block
 block discarded – undo
1285 1285
       $this->objects[$id]['info']['contents'] = array();
1286 1286
       $this->objects[$id]['info']['contents'][] = $this->numObj;
1287 1287
 
1288
-      $match =  ($this->numPages%2 ?  'odd' :  'even');
1289
-      foreach($this->addLooseObjects as  $oId=>$target) {
1290
-        if  ($target === 'all' || $match === $target) {
1288
+      $match = ($this->numPages % 2 ? 'odd' : 'even');
1289
+      foreach ($this->addLooseObjects as  $oId=>$target) {
1290
+        if ($target === 'all' || $match === $target) {
1291 1291
           $this->objects[$id]['info']['contents'][] = $oId;
1292 1292
         }
1293 1293
       }
@@ -1299,7 +1299,7 @@  discard block
 block discarded – undo
1299 1299
 
1300 1300
     case  'annot':
1301 1301
       // add an annotation to this page
1302
-      if  (!isset($o['info']['annot'])) {
1302
+      if (!isset($o['info']['annot'])) {
1303 1303
         $o['info']['annot'] = array();
1304 1304
       }
1305 1305
 
@@ -1309,32 +1309,32 @@  discard block
 block discarded – undo
1309 1309
 
1310 1310
     case  'out':
1311 1311
       $res = "\n".$id." 0 obj\n<< /Type /Page";
1312
-      $res.= "\n/Parent ".$o['info']['parent']." 0 R";
1312
+      $res .= "\n/Parent ".$o['info']['parent']." 0 R";
1313 1313
 
1314
-      if  (isset($o['info']['annot'])) {
1315
-        $res.= "\n/Annots [";
1316
-        foreach($o['info']['annot'] as  $aId) {
1317
-          $res.= " ".$aId." 0 R";
1314
+      if (isset($o['info']['annot'])) {
1315
+        $res .= "\n/Annots [";
1316
+        foreach ($o['info']['annot'] as  $aId) {
1317
+          $res .= " ".$aId." 0 R";
1318 1318
         }
1319
-        $res.= " ]";
1319
+        $res .= " ]";
1320 1320
       }
1321 1321
 
1322
-      $count =  count($o['info']['contents']);
1323
-      if  ($count == 1) {
1324
-        $res.= "\n/Contents ".$o['info']['contents'][0]." 0 R";
1325
-      } else  if  ($count>1) {
1326
-        $res.= "\n/Contents [\n";
1322
+      $count = count($o['info']['contents']);
1323
+      if ($count == 1) {
1324
+        $res .= "\n/Contents ".$o['info']['contents'][0]." 0 R";
1325
+      } else  if ($count > 1) {
1326
+        $res .= "\n/Contents [\n";
1327 1327
 
1328 1328
         // reverse the page contents so added objects are below normal content
1329 1329
         //foreach (array_reverse($o['info']['contents']) as  $cId) {
1330 1330
         // Back to normal now that I've got transparency working --Benj
1331 1331
         foreach ($o['info']['contents'] as  $cId) {
1332
-          $res.= $cId." 0 R\n";
1332
+          $res .= $cId." 0 R\n";
1333 1333
         }
1334
-        $res.= "]";
1334
+        $res .= "]";
1335 1335
       }
1336 1336
 
1337
-      $res.= "\n>>\nendobj";
1337
+      $res .= "\n>>\nendobj";
1338 1338
       return  $res;
1339 1339
     }
1340 1340
   }
@@ -1344,17 +1344,17 @@  discard block
 block discarded – undo
1344 1344
    * the contents objects hold all of the content which appears on pages
1345 1345
    */
1346 1346
   protected function  o_contents($id, $action, $options = '') {
1347
-    if  ($action !== 'new') {
1347
+    if ($action !== 'new') {
1348 1348
       $o = & $this->objects[$id];
1349 1349
     }
1350 1350
 
1351
-    switch  ($action) {
1351
+    switch ($action) {
1352 1352
     case  'new':
1353 1353
       $this->objects[$id] = array('t'=>'contents', 'c'=>'', 'info'=>array());
1354
-      if  (mb_strlen($options, '8bit') &&  intval($options)) {
1354
+      if (mb_strlen($options, '8bit') && intval($options)) {
1355 1355
         // then this contents is the primary for a page
1356 1356
         $this->objects[$id]['onPage'] = $options;
1357
-      } else  if  ($options === 'raw') {
1357
+      } else  if ($options === 'raw') {
1358 1358
         // then this page contains some other type of system object
1359 1359
         $this->objects[$id]['raw'] = 1;
1360 1360
       }
@@ -1368,63 +1368,63 @@  discard block
 block discarded – undo
1368 1368
 
1369 1369
     case  'out':
1370 1370
       $tmp = $o['c'];
1371
-      $res =  "\n".$id." 0 obj\n";
1371
+      $res = "\n".$id." 0 obj\n";
1372 1372
 
1373
-      if  (isset($this->objects[$id]['raw'])) {
1374
-        $res.= $tmp;
1373
+      if (isset($this->objects[$id]['raw'])) {
1374
+        $res .= $tmp;
1375 1375
       } else {
1376
-        $res.=  "<<";
1377
-        if  (function_exists('gzcompress') &&  $this->options['compression']) {
1376
+        $res .= "<<";
1377
+        if (function_exists('gzcompress') && $this->options['compression']) {
1378 1378
           // then implement ZLIB based compression on this content stream
1379
-          $res.= " /Filter /FlateDecode";
1380
-          $tmp =  gzcompress($tmp,  6);
1379
+          $res .= " /Filter /FlateDecode";
1380
+          $tmp = gzcompress($tmp, 6);
1381 1381
         }
1382 1382
 
1383
-        if  ($this->encrypted) {
1383
+        if ($this->encrypted) {
1384 1384
           $this->encryptInit($id);
1385
-          $tmp =  $this->ARC4($tmp);
1385
+          $tmp = $this->ARC4($tmp);
1386 1386
         }
1387 1387
 
1388
-        foreach($o['info'] as  $k=>$v) {
1389
-          $res.=  "\n/".$k.' '.$v;
1388
+        foreach ($o['info'] as  $k=>$v) {
1389
+          $res .= "\n/".$k.' '.$v;
1390 1390
         }
1391 1391
 
1392
-        $res.= "\n/Length ".mb_strlen($tmp, '8bit') ." >>\nstream\n".$tmp."\nendstream";
1392
+        $res .= "\n/Length ".mb_strlen($tmp, '8bit')." >>\nstream\n".$tmp."\nendstream";
1393 1393
       }
1394 1394
 
1395
-      $res.= "\nendobj";
1395
+      $res .= "\nendobj";
1396 1396
       return  $res;
1397 1397
     }
1398 1398
   }
1399 1399
 
1400 1400
   protected function  o_embedjs($id, $action, $code = '') {
1401
-    if  ($action !== 'new') {
1401
+    if ($action !== 'new') {
1402 1402
       $o = & $this->objects[$id];
1403 1403
     }
1404 1404
 
1405
-    switch  ($action) {
1405
+    switch ($action) {
1406 1406
     case  'new':
1407 1407
       $this->objects[$id] = array('t'=>'embedjs', 'info'=>array(
1408
-        'Names' => '[(EmbeddedJS) '.($id+1).' 0 R]'
1408
+        'Names' => '[(EmbeddedJS) '.($id + 1).' 0 R]'
1409 1409
       ));
1410 1410
       break;
1411 1411
 
1412 1412
     case  'out':
1413 1413
       $res .= "\n".$id." 0 obj\n".'<< ';
1414
-      foreach($o['info'] as  $k=>$v) {
1415
-        $res.=  "\n/".$k.' '.$v;
1414
+      foreach ($o['info'] as  $k=>$v) {
1415
+        $res .= "\n/".$k.' '.$v;
1416 1416
       }
1417
-      $res.= "\n>>\nendobj";
1417
+      $res .= "\n>>\nendobj";
1418 1418
       return  $res;
1419 1419
     }
1420 1420
   }
1421 1421
   
1422 1422
   protected function  o_javascript($id, $action, $code = '') {
1423
-    if  ($action !== 'new') {
1423
+    if ($action !== 'new') {
1424 1424
       $o = & $this->objects[$id];
1425 1425
     }
1426 1426
 
1427
-    switch  ($action) {
1427
+    switch ($action) {
1428 1428
     case  'new':
1429 1429
       $this->objects[$id] = array('t'=>'javascript', 'info'=>array(
1430 1430
         'S' => '/JavaScript',
@@ -1434,10 +1434,10 @@  discard block
 block discarded – undo
1434 1434
 
1435 1435
     case  'out':
1436 1436
       $res = "\n".$id." 0 obj\n".'<< ';
1437
-      foreach($o['info'] as  $k=>$v) {
1438
-        $res.=  "\n/".$k.' '.$v;
1437
+      foreach ($o['info'] as  $k=>$v) {
1438
+        $res .= "\n/".$k.' '.$v;
1439 1439
       }
1440
-      $res.= "\n>>\nendobj";
1440
+      $res .= "\n>>\nendobj";
1441 1441
       return  $res;
1442 1442
     }
1443 1443
   }
@@ -1446,7 +1446,7 @@  discard block
 block discarded – undo
1446 1446
    * an image object, will be an XObject in the document, includes description and data
1447 1447
    */
1448 1448
   protected function  o_image($id, $action, $options = '') {
1449
-    if  ($action !== 'new') {
1449
+    if ($action !== 'new') {
1450 1450
       $o = & $this->objects[$id];
1451 1451
     }
1452 1452
 
@@ -1459,8 +1459,8 @@  discard block
 block discarded – undo
1459 1459
       $this->objects[$id]['info']['Width'] = $options['iw'];
1460 1460
       $this->objects[$id]['info']['Height'] = $options['ih'];
1461 1461
 
1462
-      if  (!isset($options['type']) ||  $options['type'] === 'jpg') {
1463
-        if  (!isset($options['channels'])) {
1462
+      if (!isset($options['type']) || $options['type'] === 'jpg') {
1463
+        if (!isset($options['channels'])) {
1464 1464
           $options['channels'] = 3;
1465 1465
         }
1466 1466
 
@@ -1476,30 +1476,30 @@  discard block
 block discarded – undo
1476 1476
 
1477 1477
         $this->objects[$id]['info']['Filter'] = '/DCTDecode';
1478 1478
         $this->objects[$id]['info']['BitsPerComponent'] = 8;
1479
-      } else  if  ($options['type'] === 'png') {
1479
+      } else  if ($options['type'] === 'png') {
1480 1480
         $this->objects[$id]['info']['Filter'] = '/FlateDecode';
1481 1481
         $this->objects[$id]['info']['DecodeParms'] = '<< /Predictor 15 /Colors '.$options['ncolor'].' /Columns '.$options['iw'].' /BitsPerComponent '.$options['bitsPerComponent'].'>>';
1482 1482
 
1483
-        if  (mb_strlen($options['pdata'], '8bit')) {
1484
-          $tmp =  ' [ /Indexed /DeviceRGB '.(mb_strlen($options['pdata'], '8bit') /3-1) .' ';
1483
+        if (mb_strlen($options['pdata'], '8bit')) {
1484
+          $tmp = ' [ /Indexed /DeviceRGB '.(mb_strlen($options['pdata'], '8bit') / 3 - 1).' ';
1485 1485
           $this->numObj++;
1486 1486
           $this->o_contents($this->numObj, 'new');
1487 1487
           $this->objects[$this->numObj]['c'] = $options['pdata'];
1488
-          $tmp.= $this->numObj.' 0 R';
1489
-          $tmp.= ' ]';
1490
-          $this->objects[$id]['info']['ColorSpace'] =  $tmp;
1491
-          if  (isset($options['transparency'])) {
1488
+          $tmp .= $this->numObj.' 0 R';
1489
+          $tmp .= ' ]';
1490
+          $this->objects[$id]['info']['ColorSpace'] = $tmp;
1491
+          if (isset($options['transparency'])) {
1492 1492
             switch ($options['transparency']['type']) {
1493 1493
             case  'indexed':
1494 1494
               $tmp = ' [ '.$options['transparency']['data'].' '.$options['transparency']['data'].'] ';
1495
-              $this->objects[$id]['info']['Mask'] =  $tmp;
1495
+              $this->objects[$id]['info']['Mask'] = $tmp;
1496 1496
               break;
1497 1497
 
1498 1498
             case 'color-key':
1499 1499
               $tmp = ' [ '.
1500
-                $options['transparency']['r'] . ' ' . $options['transparency']['r'] .
1501
-                $options['transparency']['g'] . ' ' . $options['transparency']['g'] .
1502
-                $options['transparency']['b'] . ' ' . $options['transparency']['b'] .
1500
+                $options['transparency']['r'].' '.$options['transparency']['r'].
1501
+                $options['transparency']['g'].' '.$options['transparency']['g'].
1502
+                $options['transparency']['b'].' '.$options['transparency']['b'].
1503 1503
                 ' ] ';
1504 1504
               $this->objects[$id]['info']['Mask'] = $tmp;
1505 1505
               pre_r($tmp);
@@ -1508,18 +1508,18 @@  discard block
 block discarded – undo
1508 1508
             }
1509 1509
           }
1510 1510
         } else {
1511
-          if  (isset($options['transparency'])) {
1511
+          if (isset($options['transparency'])) {
1512 1512
             switch ($options['transparency']['type']) {
1513 1513
             case  'indexed':
1514 1514
               $tmp = ' [ '.$options['transparency']['data'].' '.$options['transparency']['data'].'] ';
1515
-              $this->objects[$id]['info']['Mask'] =  $tmp;
1515
+              $this->objects[$id]['info']['Mask'] = $tmp;
1516 1516
               break;
1517 1517
 
1518 1518
             case 'color-key':
1519 1519
               $tmp = ' [ '.
1520
-                $options['transparency']['r'] . ' ' . $options['transparency']['r'] . ' ' .
1521
-                $options['transparency']['g'] . ' ' . $options['transparency']['g'] . ' ' .
1522
-                $options['transparency']['b'] . ' ' . $options['transparency']['b'] .
1520
+                $options['transparency']['r'].' '.$options['transparency']['r'].' '.
1521
+                $options['transparency']['g'].' '.$options['transparency']['g'].' '.
1522
+                $options['transparency']['b'].' '.$options['transparency']['b'].
1523 1523
                 ' ] ';
1524 1524
               $this->objects[$id]['info']['Mask'] = $tmp;
1525 1525
               break;              
@@ -1541,18 +1541,18 @@  discard block
 block discarded – undo
1541 1541
 
1542 1542
     case  'out':
1543 1543
       $tmp = &$o['data'];
1544
-      $res =  "\n".$id." 0 obj\n<<";
1544
+      $res = "\n".$id." 0 obj\n<<";
1545 1545
 
1546
-      foreach($o['info'] as  $k=>$v) {
1547
-        $res.= "\n/".$k.' '.$v;
1546
+      foreach ($o['info'] as  $k=>$v) {
1547
+        $res .= "\n/".$k.' '.$v;
1548 1548
       }
1549 1549
 
1550
-      if  ($this->encrypted) {
1550
+      if ($this->encrypted) {
1551 1551
         $this->encryptInit($id);
1552
-        $tmp =  $this->ARC4($tmp);
1552
+        $tmp = $this->ARC4($tmp);
1553 1553
       }
1554 1554
 
1555
-      $res.= "\n/Length ".mb_strlen($tmp, '8bit') .">>\nstream\n".$tmp."\nendstream\nendobj";
1555
+      $res .= "\n/Length ".mb_strlen($tmp, '8bit').">>\nstream\n".$tmp."\nendstream\nendobj";
1556 1556
 
1557 1557
       return  $res;
1558 1558
     }
@@ -1562,39 +1562,39 @@  discard block
 block discarded – undo
1562 1562
   /**
1563 1563
    * graphics state object
1564 1564
    */
1565
-  protected function  o_extGState($id,  $action,  $options = "") {
1566
-    static  $valid_params =  array("LW",  "LC",  "LC",  "LJ",  "ML",
1567
-                                   "D",  "RI",  "OP",  "op",  "OPM",
1568
-                                   "Font",  "BG",  "BG2",  "UCR",
1569
-                                   "TR",  "TR2",  "HT",  "FL",
1570
-                                   "SM",  "SA",  "BM",  "SMask",
1571
-                                   "CA",  "ca",  "AIS",  "TK");
1565
+  protected function  o_extGState($id, $action, $options = "") {
1566
+    static  $valid_params = array("LW", "LC", "LC", "LJ", "ML",
1567
+                                   "D", "RI", "OP", "op", "OPM",
1568
+                                   "Font", "BG", "BG2", "UCR",
1569
+                                   "TR", "TR2", "HT", "FL",
1570
+                                   "SM", "SA", "BM", "SMask",
1571
+                                   "CA", "ca", "AIS", "TK");
1572 1572
 
1573
-    if  ($action !==  "new") {
1573
+    if ($action !== "new") {
1574 1574
       $o = & $this->objects[$id];
1575 1575
     }
1576 1576
 
1577
-    switch  ($action) {
1577
+    switch ($action) {
1578 1578
     case  "new":
1579
-      $this->objects[$id] =  array('t' => 'extGState',  'info' => $options);
1579
+      $this->objects[$id] = array('t' => 'extGState', 'info' => $options);
1580 1580
 
1581 1581
       // Tell the pages about the new resource
1582 1582
       $this->numStates++;
1583
-      $this->o_pages($this->currentNode,  'extGState',  array("objNum" => $id,  "stateNum" => $this->numStates));
1583
+      $this->o_pages($this->currentNode, 'extGState', array("objNum" => $id, "stateNum" => $this->numStates));
1584 1584
       break;
1585 1585
 
1586 1586
     case  "out":
1587 1587
       $res =
1588
-        "\n" . $id . " 0 obj\n".
1588
+        "\n".$id." 0 obj\n".
1589 1589
         "<< /Type /ExtGState\n";
1590 1590
 
1591 1591
       foreach ($o["info"] as  $parameter => $value) {
1592
-        if  ( !in_array($parameter,  $valid_params))
1592
+        if (!in_array($parameter, $valid_params))
1593 1593
           continue;
1594
-        $res.=  "/$parameter $value\n";
1594
+        $res .= "/$parameter $value\n";
1595 1595
       }
1596 1596
 
1597
-      $res.=
1597
+      $res .=
1598 1598
         ">>\n".
1599 1599
         "endobj";
1600 1600
       return  $res;
@@ -1606,7 +1606,7 @@  discard block
 block discarded – undo
1606 1606
    * encryption object.
1607 1607
    */
1608 1608
   protected function  o_encryption($id, $action, $options = '') {
1609
-    if  ($action !== 'new') {
1609
+    if ($action !== 'new') {
1610 1610
       $o = & $this->objects[$id];
1611 1611
     }
1612 1612
 
@@ -1617,38 +1617,38 @@  discard block
 block discarded – undo
1617 1617
       $this->arc4_objnum = $id;
1618 1618
 
1619 1619
       // figure out the additional paramaters required
1620
-      $pad =  chr(0x28) .chr(0xBF) .chr(0x4E) .chr(0x5E) .chr(0x4E) .chr(0x75) .chr(0x8A) .chr(0x41) .chr(0x64) .chr(0x00) .chr(0x4E) .chr(0x56) .chr(0xFF) .chr(0xFA) .chr(0x01) .chr(0x08) .chr(0x2E) .chr(0x2E) .chr(0x00) .chr(0xB6) .chr(0xD0) .chr(0x68) .chr(0x3E) .chr(0x80) .chr(0x2F) .chr(0x0C) .chr(0xA9) .chr(0xFE) .chr(0x64) .chr(0x53) .chr(0x69) .chr(0x7A);
1621
-      $len =  mb_strlen($options['owner'], '8bit');
1620
+      $pad = chr(0x28).chr(0xBF).chr(0x4E).chr(0x5E).chr(0x4E).chr(0x75).chr(0x8A).chr(0x41).chr(0x64).chr(0x00).chr(0x4E).chr(0x56).chr(0xFF).chr(0xFA).chr(0x01).chr(0x08).chr(0x2E).chr(0x2E).chr(0x00).chr(0xB6).chr(0xD0).chr(0x68).chr(0x3E).chr(0x80).chr(0x2F).chr(0x0C).chr(0xA9).chr(0xFE).chr(0x64).chr(0x53).chr(0x69).chr(0x7A);
1621
+      $len = mb_strlen($options['owner'], '8bit');
1622 1622
 
1623
-      if  ($len>32) {
1624
-        $owner =  substr($options['owner'], 0, 32);
1625
-      } else  if  ($len<32) {
1626
-        $owner =  $options['owner'].substr($pad, 0, 32-$len);
1623
+      if ($len > 32) {
1624
+        $owner = substr($options['owner'], 0, 32);
1625
+      } else  if ($len < 32) {
1626
+        $owner = $options['owner'].substr($pad, 0, 32 - $len);
1627 1627
       } else {
1628
-        $owner =  $options['owner'];
1628
+        $owner = $options['owner'];
1629 1629
       }
1630 1630
 
1631
-      $len =  mb_strlen($options['user'], '8bit');
1632
-      if  ($len>32) {
1633
-        $user =  substr($options['user'], 0, 32);
1634
-      } else  if  ($len<32) {
1635
-        $user =  $options['user'].substr($pad, 0, 32-$len);
1631
+      $len = mb_strlen($options['user'], '8bit');
1632
+      if ($len > 32) {
1633
+        $user = substr($options['user'], 0, 32);
1634
+      } else  if ($len < 32) {
1635
+        $user = $options['user'].substr($pad, 0, 32 - $len);
1636 1636
       } else {
1637
-        $user =  $options['user'];
1637
+        $user = $options['user'];
1638 1638
       }
1639 1639
 
1640
-      $tmp =  $this->md5_16($owner);
1641
-      $okey =  substr($tmp, 0, 5);
1640
+      $tmp = $this->md5_16($owner);
1641
+      $okey = substr($tmp, 0, 5);
1642 1642
       $this->ARC4_init($okey);
1643 1643
       $ovalue = $this->ARC4($user);
1644 1644
       $this->objects[$id]['info']['O'] = $ovalue;
1645 1645
 
1646 1646
       // now make the u value, phew.
1647
-      $tmp =  $this->md5_16($user.$ovalue.chr($options['p']) .chr(255) .chr(255) .chr(255) .$this->fileIdentifier);
1647
+      $tmp = $this->md5_16($user.$ovalue.chr($options['p']).chr(255).chr(255).chr(255).$this->fileIdentifier);
1648 1648
 
1649
-      $ukey =  substr($tmp, 0, 5);
1649
+      $ukey = substr($tmp, 0, 5);
1650 1650
       $this->ARC4_init($ukey);
1651
-      $this->encryptionKey =  $ukey;
1651
+      $this->encryptionKey = $ukey;
1652 1652
       $this->encrypted = 1;
1653 1653
       $uvalue = $this->ARC4($pad);
1654 1654
       $this->objects[$id]['info']['U'] = $uvalue;
@@ -1657,16 +1657,16 @@  discard block
 block discarded – undo
1657 1657
       break;
1658 1658
 
1659 1659
     case  'out':
1660
-      $res =  "\n".$id." 0 obj\n<<";
1661
-      $res.= "\n/Filter /Standard";
1662
-      $res.= "\n/V 1";
1663
-      $res.= "\n/R 2";
1664
-      $res.= "\n/O (".$this->filterText($o['info']['O']) .')';
1665
-      $res.= "\n/U (".$this->filterText($o['info']['U']) .')';
1660
+      $res = "\n".$id." 0 obj\n<<";
1661
+      $res .= "\n/Filter /Standard";
1662
+      $res .= "\n/V 1";
1663
+      $res .= "\n/R 2";
1664
+      $res .= "\n/O (".$this->filterText($o['info']['O']).')';
1665
+      $res .= "\n/U (".$this->filterText($o['info']['U']).')';
1666 1666
       // and the p-value needs to be converted to account for the twos-complement approach
1667
-      $o['info']['p'] =  (($o['info']['p']^255) +1) *-1;
1668
-      $res.= "\n/P ".($o['info']['p']);
1669
-      $res.= "\n>>\nendobj";
1667
+      $o['info']['p'] = (($o['info']['p'] ^ 255) + 1) * -1;
1668
+      $res .= "\n/P ".($o['info']['p']);
1669
+      $res .= "\n>>\nendobj";
1670 1670
       return  $res;
1671 1671
     }
1672 1672
   }
@@ -1681,10 +1681,10 @@  discard block
 block discarded – undo
1681 1681
    * calculate the 16 byte version of the 128 bit md5 digest of the string
1682 1682
    */
1683 1683
   function  md5_16($string) {
1684
-    $tmp =  md5($string);
1684
+    $tmp = md5($string);
1685 1685
     $out = '';
1686
-    for  ($i = 0;$i <= 30;$i = $i+2) {
1687
-      $out.= chr(hexdec(substr($tmp, $i, 2)));
1686
+    for ($i = 0; $i <= 30; $i = $i + 2) {
1687
+      $out .= chr(hexdec(substr($tmp, $i, 2)));
1688 1688
     }
1689 1689
     return  $out;
1690 1690
   }
@@ -1694,13 +1694,13 @@  discard block
 block discarded – undo
1694 1694
    * initialize the encryption for processing a particular object
1695 1695
    */
1696 1696
   function  encryptInit($id) {
1697
-    $tmp =  $this->encryptionKey;
1698
-    $hex =  dechex($id);
1699
-    if  (mb_strlen($hex, '8bit') <6) {
1700
-      $hex =  substr('000000', 0, 6-mb_strlen($hex, '8bit')) .$hex;
1697
+    $tmp = $this->encryptionKey;
1698
+    $hex = dechex($id);
1699
+    if (mb_strlen($hex, '8bit') < 6) {
1700
+      $hex = substr('000000', 0, 6 - mb_strlen($hex, '8bit')).$hex;
1701 1701
     }
1702
-    $tmp.=  chr(hexdec(substr($hex, 4, 2))) .chr(hexdec(substr($hex, 2, 2))) .chr(hexdec(substr($hex, 0, 2))) .chr(0) .chr(0);
1703
-    $key =  $this->md5_16($tmp);
1702
+    $tmp .= chr(hexdec(substr($hex, 4, 2))).chr(hexdec(substr($hex, 2, 2))).chr(hexdec(substr($hex, 0, 2))).chr(0).chr(0);
1703
+    $key = $this->md5_16($tmp);
1704 1704
     $this->ARC4_init(substr($key, 0, 10));
1705 1705
   }
1706 1706
 
@@ -1709,28 +1709,28 @@  discard block
 block discarded – undo
1709 1709
    * initialize the ARC4 encryption
1710 1710
    */
1711 1711
   function  ARC4_init($key = '') {
1712
-    $this->arc4 =  '';
1712
+    $this->arc4 = '';
1713 1713
 
1714 1714
     // setup the control array
1715
-    if  (mb_strlen($key, '8bit') == 0) {
1715
+    if (mb_strlen($key, '8bit') == 0) {
1716 1716
       return;
1717 1717
     }
1718 1718
 
1719
-    $k =  '';
1720
-    while (mb_strlen($k, '8bit') <256) {
1721
-      $k.= $key;
1719
+    $k = '';
1720
+    while (mb_strlen($k, '8bit') < 256) {
1721
+      $k .= $key;
1722 1722
     }
1723 1723
 
1724 1724
     $k = substr($k, 0, 256);
1725
-    for  ($i = 0;$i<256;$i++) {
1726
-      $this->arc4.=  chr($i);
1725
+    for ($i = 0; $i < 256; $i++) {
1726
+      $this->arc4 .= chr($i);
1727 1727
     }
1728 1728
 
1729 1729
     $j = 0;
1730 1730
 
1731
-    for  ($i = 0;$i<256;$i++) {
1732
-      $t =  $this->arc4[$i];
1733
-      $j =  ($j + ord($t)  + ord($k[$i])) %256;
1731
+    for ($i = 0; $i < 256; $i++) {
1732
+      $t = $this->arc4[$i];
1733
+      $j = ($j + ord($t) + ord($k[$i])) % 256;
1734 1734
       $this->arc4[$i] = $this->arc4[$j];
1735 1735
       $this->arc4[$j] = $t;
1736 1736
     }
@@ -1744,16 +1744,16 @@  discard block
 block discarded – undo
1744 1744
     $len = mb_strlen($text, '8bit');
1745 1745
     $a = 0;
1746 1746
     $b = 0;
1747
-    $c =  $this->arc4;
1747
+    $c = $this->arc4;
1748 1748
     $out = '';
1749
-    for  ($i = 0;$i<$len;$i++) {
1750
-      $a =  ($a+1) %256;
1751
-      $t =  $c[$a];
1752
-      $b =  ($b+ord($t)) %256;
1749
+    for ($i = 0; $i < $len; $i++) {
1750
+      $a = ($a + 1) % 256;
1751
+      $t = $c[$a];
1752
+      $b = ($b + ord($t)) % 256;
1753 1753
       $c[$a] = $c[$b];
1754 1754
       $c[$b] = $t;
1755
-      $k =  ord($c[(ord($c[$a]) +ord($c[$b])) %256]);
1756
-      $out.= chr(ord($text[$i])  ^ $k);
1755
+      $k = ord($c[(ord($c[$a]) + ord($c[$b])) % 256]);
1756
+      $out .= chr(ord($text[$i]) ^ $k);
1757 1757
     }
1758 1758
     return  $out;
1759 1759
   }
@@ -1768,7 +1768,7 @@  discard block
 block discarded – undo
1768 1768
    */
1769 1769
   function  addLink($url, $x0, $y0, $x1, $y1) {
1770 1770
     $this->numObj++;
1771
-    $info =  array('type'=>'link', 'url'=>$url, 'rect'=>array($x0, $y0, $x1, $y1));
1771
+    $info = array('type'=>'link', 'url'=>$url, 'rect'=>array($x0, $y0, $x1, $y1));
1772 1772
     $this->o_annotation($this->numObj, 'new', $info);
1773 1773
   }
1774 1774
 
@@ -1778,7 +1778,7 @@  discard block
 block discarded – undo
1778 1778
    */
1779 1779
   function  addInternalLink($label, $x0, $y0, $x1, $y1) {
1780 1780
     $this->numObj++;
1781
-    $info =  array('type'=>'ilink', 'label'=>$label, 'rect'=>array($x0, $y0, $x1, $y1));
1781
+    $info = array('type'=>'ilink', 'label'=>$label, 'rect'=>array($x0, $y0, $x1, $y1));
1782 1782
     $this->o_annotation($this->numObj, 'new', $info);
1783 1783
   }
1784 1784
 
@@ -1791,21 +1791,21 @@  discard block
 block discarded – undo
1791 1791
   function  setEncryption($userPass = '', $ownerPass = '', $pc = array()) {
1792 1792
     $p = bindec(11000000);
1793 1793
 
1794
-    $options =  array('print'=>4, 'modify'=>8, 'copy'=>16, 'add'=>32);
1794
+    $options = array('print'=>4, 'modify'=>8, 'copy'=>16, 'add'=>32);
1795 1795
 
1796
-    foreach($pc as  $k=>$v) {
1797
-      if  ($v &&  isset($options[$k])) {
1798
-        $p+= $options[$k];
1799
-      } else  if  (isset($options[$v])) {
1800
-        $p+= $options[$v];
1796
+    foreach ($pc as  $k=>$v) {
1797
+      if ($v && isset($options[$k])) {
1798
+        $p += $options[$k];
1799
+      } else  if (isset($options[$v])) {
1800
+        $p += $options[$v];
1801 1801
       }
1802 1802
     }
1803 1803
 
1804 1804
     // implement encryption on the document
1805
-    if  ($this->arc4_objnum ==  0) {
1805
+    if ($this->arc4_objnum == 0) {
1806 1806
       // then the block does not exist already, add it.
1807 1807
       $this->numObj++;
1808
-      if  (mb_strlen($ownerPass) == 0) {
1808
+      if (mb_strlen($ownerPass) == 0) {
1809 1809
         $ownerPass = $userPass;
1810 1810
       }
1811 1811
 
@@ -1825,7 +1825,7 @@  discard block
 block discarded – undo
1825 1825
    * return the pdf stream as a string returned from the function
1826 1826
    */
1827 1827
   function  output($debug = false) {
1828
-    if  ($debug) {
1828
+    if ($debug) {
1829 1829
       // turn compression off
1830 1830
       $this->options['compression'] = 0;
1831 1831
     }
@@ -1837,12 +1837,12 @@  discard block
 block discarded – undo
1837 1837
       $this->o_embedjs($js_id, 'new');
1838 1838
       $this->o_javascript(++$this->numObj, 'new', $this->javascript);
1839 1839
       
1840
-      $id =  $this->catalogId;
1840
+      $id = $this->catalogId;
1841 1841
       
1842 1842
       $this->o_catalog($id, 'javascript', $js_id);
1843 1843
     }
1844 1844
 
1845
-    if  ($this->arc4_objnum) {
1845
+    if ($this->arc4_objnum) {
1846 1846
       $this->ARC4_init($this->encryptionKey);
1847 1847
     }
1848 1848
 
@@ -1853,32 +1853,32 @@  discard block
 block discarded – undo
1853 1853
     $content = '%PDF-1.3';
1854 1854
     $pos = mb_strlen($content, '8bit');
1855 1855
 
1856
-    foreach($this->objects as  $k=>$v) {
1856
+    foreach ($this->objects as  $k=>$v) {
1857 1857
       $tmp = 'o_'.$v['t'];
1858 1858
       $cont = $this->$tmp($k, 'out');
1859
-      $content.= $cont;
1859
+      $content .= $cont;
1860 1860
       $xref[] = $pos;
1861
-      $pos+= mb_strlen($cont, '8bit');
1861
+      $pos += mb_strlen($cont, '8bit');
1862 1862
     }
1863 1863
 
1864
-    $content.= "\nxref\n0 ".(count($xref) +1) ."\n0000000000 65535 f \n";
1864
+    $content .= "\nxref\n0 ".(count($xref) + 1)."\n0000000000 65535 f \n";
1865 1865
 
1866
-    foreach($xref as  $p) {
1867
-      $content.= str_pad($p,  10,  "0",  STR_PAD_LEFT)  . " 00000 n \n";
1866
+    foreach ($xref as  $p) {
1867
+      $content .= str_pad($p, 10, "0", STR_PAD_LEFT)." 00000 n \n";
1868 1868
     }
1869 1869
 
1870
-    $content.= "trailer\n<<\n/Size ".(count($xref) +1) ."\n/Root 1 0 R\n/Info ".$this->infoObject." 0 R\n";
1870
+    $content .= "trailer\n<<\n/Size ".(count($xref) + 1)."\n/Root 1 0 R\n/Info ".$this->infoObject." 0 R\n";
1871 1871
 
1872 1872
     // if encryption has been applied to this document then add the marker for this dictionary
1873
-    if  ($this->arc4_objnum > 0) {
1874
-      $content.=  "/Encrypt ".$this->arc4_objnum." 0 R\n";
1873
+    if ($this->arc4_objnum > 0) {
1874
+      $content .= "/Encrypt ".$this->arc4_objnum." 0 R\n";
1875 1875
     }
1876 1876
 
1877
-    if  (mb_strlen($this->fileIdentifier, '8bit')) {
1878
-      $content.=  "/ID[<".$this->fileIdentifier."><".$this->fileIdentifier.">]\n";
1877
+    if (mb_strlen($this->fileIdentifier, '8bit')) {
1878
+      $content .= "/ID[<".$this->fileIdentifier."><".$this->fileIdentifier.">]\n";
1879 1879
     }
1880 1880
 
1881
-    $content.=  ">>\nstartxref\n".$pos."\n%%EOF\n";
1881
+    $content .= ">>\nstartxref\n".$pos."\n%%EOF\n";
1882 1882
 
1883 1883
     return  $content;
1884 1884
   }
@@ -1892,7 +1892,7 @@  discard block
 block discarded – undo
1892 1892
    */
1893 1893
   function  newDocument($pageSize = array(0, 0, 612, 792)) {
1894 1894
     $this->numObj = 0;
1895
-    $this->objects =  array();
1895
+    $this->objects = array();
1896 1896
 
1897 1897
     $this->numObj++;
1898 1898
     $this->o_catalog($this->numObj, 'new');
@@ -1904,7 +1904,7 @@  discard block
 block discarded – undo
1904 1904
     $this->o_pages($this->numObj, 'new');
1905 1905
 
1906 1906
     $this->o_pages($this->numObj, 'mediaBox', $pageSize);
1907
-    $this->currentNode =  3;
1907
+    $this->currentNode = 3;
1908 1908
 
1909 1909
     $this->numObj++;
1910 1910
     $this->o_procset($this->numObj, 'new');
@@ -1917,7 +1917,7 @@  discard block
 block discarded – undo
1917 1917
 
1918 1918
     // need to store the first page id as there is no way to get it to the user during
1919 1919
     // startup
1920
-    $this->firstPageId =  $this->currentContents;
1920
+    $this->firstPageId = $this->currentContents;
1921 1921
   }
1922 1922
 
1923 1923
   /**
@@ -1933,12 +1933,12 @@  discard block
 block discarded – undo
1933 1933
     // assume that $font contains the path and file but not the extension
1934 1934
     $pos = strrpos($font, '/');
1935 1935
 
1936
-    if  ($pos === false) {
1937
-      $dir =  './';
1938
-      $name =  $font;
1936
+    if ($pos === false) {
1937
+      $dir = './';
1938
+      $name = $font;
1939 1939
     } else {
1940
-      $dir = substr($font, 0, $pos+1);
1941
-      $name = substr($font, $pos+1);
1940
+      $dir = substr($font, 0, $pos + 1);
1941
+      $name = substr($font, $pos + 1);
1942 1942
     }
1943 1943
     
1944 1944
     $fontcache = $this->fontcache;
@@ -1954,31 +1954,31 @@  discard block
 block discarded – undo
1954 1954
     
1955 1955
     $this->addMessage('openFont: '.$font.' - '.$name);
1956 1956
 
1957
-    $metrics_name = $name . (($this->isUnicode) ? '.ufm' : '.afm');
1957
+    $metrics_name = $name.(($this->isUnicode) ? '.ufm' : '.afm');
1958 1958
     
1959 1959
     // Core fonts don't currently work with composite fonts (for Unicode support).
1960 1960
     // The .ufm files have been removed so we need to check whether or not to use the
1961 1961
     // .ufm or .afm.
1962
-    if ($this->isUnicode && !file_exists($dir . '/' . $metrics_name)) { $metrics_name = $name . '.afm'; }
1962
+    if ($this->isUnicode && !file_exists($dir.'/'.$metrics_name)) { $metrics_name = $name.'.afm'; }
1963 1963
     
1964
-    $cache_name = 'php_' . $metrics_name;
1964
+    $cache_name = 'php_'.$metrics_name;
1965 1965
     $this->addMessage('metrics: '.$metrics_name.', cache: '.$cache_name);
1966
-    if  (file_exists($fontcache . $cache_name)) {
1967
-      $this->addMessage('openFont: php file exists ' . $fontcache . $cache_name);
1968
-      $tmp =  file_get_contents($fontcache . $cache_name);
1966
+    if (file_exists($fontcache.$cache_name)) {
1967
+      $this->addMessage('openFont: php file exists '.$fontcache.$cache_name);
1968
+      $tmp = file_get_contents($fontcache.$cache_name);
1969 1969
       eval($tmp);
1970 1970
 
1971
-      if  (!isset($this->fonts[$font]['_version_']) ||  $this->fonts[$font]['_version_'] != $this->fontcacheVersion) {
1971
+      if (!isset($this->fonts[$font]['_version_']) || $this->fonts[$font]['_version_'] != $this->fontcacheVersion) {
1972 1972
         // if the font file is old, then clear it out and prepare for re-creation
1973 1973
         $this->addMessage('openFont: clear out, make way for new version.');
1974 1974
         unset($this->fonts[$font]);
1975 1975
       }
1976 1976
     }
1977 1977
 
1978
-    if  (!isset($this->fonts[$font]) &&  file_exists($dir . $metrics_name)) {
1978
+    if (!isset($this->fonts[$font]) && file_exists($dir.$metrics_name)) {
1979 1979
       // then rebuild the php_<font>.afm file from the <font>.afm file
1980
-      $this->addMessage('openFont: build php file from ' . $dir . $metrics_name);
1981
-      $data =  array();
1980
+      $this->addMessage('openFont: build php file from '.$dir.$metrics_name);
1981
+      $data = array();
1982 1982
       
1983 1983
       // Since we're not going to enable Unicode for the core fonts we need to use a font-based
1984 1984
       // setting for Unicode support rather than a global setting.
@@ -1986,19 +1986,19 @@  discard block
 block discarded – undo
1986 1986
       
1987 1987
       $cidtogid = '';
1988 1988
       if ($data['isUnicode']) {
1989
-        $cidtogid = str_pad('', 256*256*2, "\x00");
1989
+        $cidtogid = str_pad('', 256 * 256 * 2, "\x00");
1990 1990
       }
1991 1991
 
1992
-      $file =  file($dir . $metrics_name);
1992
+      $file = file($dir.$metrics_name);
1993 1993
 
1994 1994
       foreach ($file as  $rowA) {
1995 1995
         $row = trim($rowA);
1996 1996
         $pos = strpos($row, ' ');
1997 1997
 
1998
-        if  ($pos) {
1998
+        if ($pos) {
1999 1999
           // then there must be some keyword
2000
-          $key =  substr($row, 0, $pos);
2001
-          switch  ($key) {
2000
+          $key = substr($row, 0, $pos);
2001
+          switch ($key) {
2002 2002
           case  'FontName':
2003 2003
           case  'FullName':
2004 2004
           case  'FamilyName':
@@ -2030,29 +2030,29 @@  discard block
 block discarded – undo
2030 2030
             $bits = explode(';', trim($row));
2031 2031
             $dtmp = array();
2032 2032
 
2033
-            foreach($bits as  $bit) {
2034
-              $bits2 =  explode(' ', trim($bit));
2035
-              if  (mb_strlen($bits2[0], '8bit')) {
2036
-                if  (count($bits2) >2) {
2033
+            foreach ($bits as  $bit) {
2034
+              $bits2 = explode(' ', trim($bit));
2035
+              if (mb_strlen($bits2[0], '8bit')) {
2036
+                if (count($bits2) > 2) {
2037 2037
                   $dtmp[$bits2[0]] = array();
2038
-                  for  ($i = 1;$i<count($bits2);$i++) {
2038
+                  for ($i = 1; $i < count($bits2); $i++) {
2039 2039
                     $dtmp[$bits2[0]][] = $bits2[$i];
2040 2040
                   }
2041
-                } else  if  (count($bits2) == 2) {
2041
+                } else  if (count($bits2) == 2) {
2042 2042
                   $dtmp[$bits2[0]] = $bits2[1];
2043 2043
                 }
2044 2044
               }
2045 2045
             }
2046 2046
 
2047
-            $cc = (int)$dtmp['C'];
2048
-            if  ($cc >= 0) {
2047
+            $cc = (int) $dtmp['C'];
2048
+            if ($cc >= 0) {
2049 2049
               $data['C'][$dtmp['C']] = $dtmp;
2050 2050
               $data['C'][$dtmp['N']] = $dtmp;
2051 2051
             } else {
2052 2052
               $data['C'][$dtmp['N']] = $dtmp;
2053 2053
             }
2054 2054
 
2055
-            if  (!isset($data['MissingWidth']) && $cc == -1 && $dtmp['N'] === '.notdef') {
2055
+            if (!isset($data['MissingWidth']) && $cc == -1 && $dtmp['N'] === '.notdef') {
2056 2056
               $data['MissingWidth'] = $width;
2057 2057
             }
2058 2058
             
@@ -2064,28 +2064,28 @@  discard block
 block discarded – undo
2064 2064
               $bits = explode(';', trim($row));
2065 2065
               $dtmp = array();
2066 2066
 
2067
-              foreach($bits as  $bit) {
2068
-                $bits2 =  explode(' ', trim($bit));
2069
-                if  (mb_strlen($bits2[0], '8bit')) {
2070
-                  if  (count($bits2) >2) {
2067
+              foreach ($bits as  $bit) {
2068
+                $bits2 = explode(' ', trim($bit));
2069
+                if (mb_strlen($bits2[0], '8bit')) {
2070
+                  if (count($bits2) > 2) {
2071 2071
                     $dtmp[$bits2[0]] = array();
2072
-                    for  ($i = 1;$i<count($bits2);$i++) {
2072
+                    for ($i = 1; $i < count($bits2); $i++) {
2073 2073
                       $dtmp[$bits2[0]][] = $bits2[$i];
2074 2074
                     }
2075
-                  } else  if  (count($bits2) == 2) {
2075
+                  } else  if (count($bits2) == 2) {
2076 2076
                     $dtmp[$bits2[0]] = $bits2[1];
2077 2077
                   }
2078 2078
                 }
2079 2079
               }
2080 2080
 
2081
-              $cc = (int)$dtmp['U'];
2081
+              $cc = (int) $dtmp['U'];
2082 2082
               $glyph = $dtmp['G'];
2083 2083
               $width = $dtmp['WX'];
2084
-              if  ($cc >= 0) {
2084
+              if ($cc >= 0) {
2085 2085
                 // Set values in CID to GID map
2086 2086
                 if ($cc >= 0 && $cc < 0xFFFF && $glyph) {
2087
-                  $cidtogid[$cc*2] = chr($glyph >> 8);
2088
-                  $cidtogid[$cc*2 + 1] = chr($glyph & 0xFF);
2087
+                  $cidtogid[$cc * 2] = chr($glyph >> 8);
2088
+                  $cidtogid[$cc * 2 + 1] = chr($glyph & 0xFF);
2089 2089
                 }
2090 2090
 
2091 2091
                 $data['C'][$dtmp['U']] = $dtmp;
@@ -2094,7 +2094,7 @@  discard block
 block discarded – undo
2094 2094
                 $data['C'][$dtmp['N']] = $dtmp;
2095 2095
               }
2096 2096
               
2097
-              if  (!isset($data['MissingWidth']) && $cc == -1 && $dtmp['N'] === '.notdef') {
2097
+              if (!isset($data['MissingWidth']) && $cc == -1 && $dtmp['N'] === '.notdef') {
2098 2098
                 $data['MissingWidth'] = $width;
2099 2099
               }
2100 2100
             }
@@ -2110,10 +2110,10 @@  discard block
 block discarded – undo
2110 2110
       }
2111 2111
 
2112 2112
       //    echo $cidtogid; die("CIDtoGID Displayed!");
2113
-      if  (function_exists('gzcompress') &&  $this->options['compression']) {
2113
+      if (function_exists('gzcompress') && $this->options['compression']) {
2114 2114
         // then implement ZLIB based compression on CIDtoGID string
2115 2115
         $data['CIDtoGID_Compressed'] = true;
2116
-        $cidtogid =  gzcompress($cidtogid,  6);
2116
+        $cidtogid = gzcompress($cidtogid, 6);
2117 2117
       }
2118 2118
       $data['CIDtoGID'] = base64_encode($cidtogid);
2119 2119
       $data['_version_'] = $this->fontcacheVersion;
@@ -2121,12 +2121,12 @@  discard block
 block discarded – undo
2121 2121
 
2122 2122
       //Because of potential trouble with php safe mode, expect that the folder already exists.
2123 2123
       //If not existing, this will hit performance because of missing cached results.
2124
-      if ( is_dir(substr($fontcache,0,-1)) ) {
2125
-        file_put_contents($fontcache . $cache_name,  '$this->fonts[$font]=' . var_export($data,  true)  . ';');
2124
+      if (is_dir(substr($fontcache, 0, -1))) {
2125
+        file_put_contents($fontcache.$cache_name, '$this->fonts[$font]='.var_export($data, true).';');
2126 2126
       }
2127 2127
     }
2128 2128
     
2129
-    if  (!isset($this->fonts[$font])) {
2129
+    if (!isset($this->fonts[$font])) {
2130 2130
       $this->addMessage("openFont: no font file found for $font.  Do you need to run load_font.php?");
2131 2131
       //echo 'Font not Found '.$font;
2132 2132
     }
@@ -2142,59 +2142,59 @@  discard block
 block discarded – undo
2142 2142
    * and 'differences' => an array of mappings between numbers 0->255 and character names.
2143 2143
    *
2144 2144
    */
2145
-  function  selectFont($fontName, $encoding =  '', $set =  true) {
2145
+  function  selectFont($fontName, $encoding = '', $set = true) {
2146 2146
     $ext = substr($fontName, -4);
2147
-    if  ($ext === '.afm' || $ext === '.ufm') {
2148
-      $fontName = substr($fontName, 0, mb_strlen($fontName)-4);
2147
+    if ($ext === '.afm' || $ext === '.ufm') {
2148
+      $fontName = substr($fontName, 0, mb_strlen($fontName) - 4);
2149 2149
     }
2150 2150
 
2151
-    if  (!isset($this->fonts[$fontName])) {
2151
+    if (!isset($this->fonts[$fontName])) {
2152 2152
       $this->addMessage("selectFont: selecting - $fontName - $encoding, $set");
2153 2153
 
2154 2154
       // load the file
2155 2155
       $this->openFont($fontName);
2156 2156
 
2157
-      if  (isset($this->fonts[$fontName])) {
2157
+      if (isset($this->fonts[$fontName])) {
2158 2158
         $this->numObj++;
2159 2159
         $this->numFonts++;
2160 2160
 
2161 2161
         //$this->numFonts = md5($fontName);
2162
-        $pos =  strrpos($fontName, '/');
2162
+        $pos = strrpos($fontName, '/');
2163 2163
         //      $dir = substr($fontName,0,$pos+1);
2164
-        $name =  substr($fontName, $pos+1);
2165
-        $options =  array('name' => $name, 'fontFileName' => $fontName);
2164
+        $name = substr($fontName, $pos + 1);
2165
+        $options = array('name' => $name, 'fontFileName' => $fontName);
2166 2166
 
2167
-        if  (is_array($encoding)) {
2167
+        if (is_array($encoding)) {
2168 2168
           // then encoding and differences might be set
2169
-          if  (isset($encoding['encoding'])) {
2170
-            $options['encoding'] =  $encoding['encoding'];
2169
+          if (isset($encoding['encoding'])) {
2170
+            $options['encoding'] = $encoding['encoding'];
2171 2171
           }
2172 2172
 
2173
-          if  (isset($encoding['differences'])) {
2174
-            $options['differences'] =  $encoding['differences'];
2173
+          if (isset($encoding['differences'])) {
2174
+            $options['differences'] = $encoding['differences'];
2175 2175
           }
2176
-        } else  if  (mb_strlen($encoding, '8bit')) {
2176
+        } else  if (mb_strlen($encoding, '8bit')) {
2177 2177
           // then perhaps only the encoding has been set
2178
-          $options['encoding'] =  $encoding;
2178
+          $options['encoding'] = $encoding;
2179 2179
         }
2180 2180
 
2181
-        $fontObj =  $this->numObj;
2181
+        $fontObj = $this->numObj;
2182 2182
         $this->o_font($this->numObj, 'new', $options);
2183
-        $this->fonts[$fontName]['fontNum'] =  $this->numFonts;
2183
+        $this->fonts[$fontName]['fontNum'] = $this->numFonts;
2184 2184
 
2185 2185
         // if this is a '.afm' font, and there is a '.pfa' file to go with it ( as there
2186 2186
         // should be for all non-basic fonts), then load it into an object and put the
2187 2187
         // references into the font object
2188
-        $basefile =  $fontName;
2189
-        if  (file_exists($basefile.'.pfb')) {
2190
-          $fbtype =  'pfb';
2191
-        } else  if  (file_exists($basefile.'.ttf')) {
2192
-          $fbtype =  'ttf';
2188
+        $basefile = $fontName;
2189
+        if (file_exists($basefile.'.pfb')) {
2190
+          $fbtype = 'pfb';
2191
+        } else  if (file_exists($basefile.'.ttf')) {
2192
+          $fbtype = 'ttf';
2193 2193
         } else {
2194
-          $fbtype =  '';
2194
+          $fbtype = '';
2195 2195
         }
2196 2196
 
2197
-        $fbfile =  $basefile.'.'.$fbtype;
2197
+        $fbfile = $basefile.'.'.$fbtype;
2198 2198
 
2199 2199
         //      $pfbfile = substr($fontName,0,strlen($fontName)-4).'.pfb';
2200 2200
         //      $ttffile = substr($fontName,0,strlen($fontName)-4).'.ttf';
@@ -2202,60 +2202,60 @@  discard block
 block discarded – undo
2202 2202
 
2203 2203
         // OAR - I don't understand this old check
2204 2204
         // if  (substr($fontName, -4) ===  '.afm' &&  strlen($fbtype)) {
2205
-        if  (mb_strlen($fbtype, '8bit')) {
2206
-          $adobeFontName =  $this->fonts[$fontName]['FontName'];
2205
+        if (mb_strlen($fbtype, '8bit')) {
2206
+          $adobeFontName = $this->fonts[$fontName]['FontName'];
2207 2207
           //        $fontObj = $this->numObj;
2208 2208
           $this->addMessage('selectFont: adding font file - '.$fbfile.' - '.$adobeFontName);
2209 2209
 
2210 2210
           // find the array of font widths, and put that into an object.
2211
-          $firstChar =  -1;
2212
-          $lastChar =  0;
2213
-          $widths =  array();
2211
+          $firstChar = -1;
2212
+          $lastChar = 0;
2213
+          $widths = array();
2214 2214
           $cid_widths = array();
2215 2215
 
2216 2216
           foreach ($this->fonts[$fontName]['C'] as  $num => $d) {
2217
-            if  (intval($num) >0 ||  $num ==  '0') {
2217
+            if (intval($num) > 0 || $num == '0') {
2218 2218
               if (!$this->fonts[$fontName]['isUnicode']) {
2219 2219
                 // With Unicode, widths array isn't used
2220
-                if  ($lastChar>0 &&  $num>$lastChar+1) {
2221
-                  for ($i =  $lastChar+1;$i<$num;$i++) {
2222
-                    $widths[] =  0;
2220
+                if ($lastChar > 0 && $num > $lastChar + 1) {
2221
+                  for ($i = $lastChar + 1; $i < $num; $i++) {
2222
+                    $widths[] = 0;
2223 2223
                   }
2224 2224
                 }
2225 2225
               }
2226 2226
 
2227
-              $widths[] =  $d['WX'];
2227
+              $widths[] = $d['WX'];
2228 2228
 
2229 2229
               if ($this->fonts[$fontName]['isUnicode']) {
2230
-                $cid_widths[$num] =  $d['WX'];
2230
+                $cid_widths[$num] = $d['WX'];
2231 2231
               }
2232 2232
 
2233
-              if  ($firstChar ==  -1) {
2234
-                $firstChar =  $num;
2233
+              if ($firstChar == -1) {
2234
+                $firstChar = $num;
2235 2235
               }
2236 2236
 
2237
-              $lastChar =  $num;
2237
+              $lastChar = $num;
2238 2238
             }
2239 2239
           }
2240 2240
 
2241 2241
           // also need to adjust the widths for the differences array
2242
-          if  (isset($options['differences'])) {
2243
-            foreach($options['differences'] as  $charNum => $charName) {
2244
-              if  ($charNum > $lastChar) {
2242
+          if (isset($options['differences'])) {
2243
+            foreach ($options['differences'] as  $charNum => $charName) {
2244
+              if ($charNum > $lastChar) {
2245 2245
                 if (!$this->fonts[$fontName]['isUnicode']) {
2246 2246
                   // With Unicode, widths array isn't used
2247
-                  for ($i =  $lastChar + 1; $i <=  $charNum; $i++) {
2248
-                    $widths[] =  0;
2247
+                  for ($i = $lastChar + 1; $i <= $charNum; $i++) {
2248
+                    $widths[] = 0;
2249 2249
                   }
2250 2250
                 }
2251 2251
 
2252
-                $lastChar =  $charNum;
2252
+                $lastChar = $charNum;
2253 2253
               }
2254 2254
 
2255
-              if  (isset($this->fonts[$fontName]['C'][$charName])) {
2256
-                $widths[$charNum-$firstChar] =  $this->fonts[$fontName]['C'][$charName]['WX'];
2255
+              if (isset($this->fonts[$fontName]['C'][$charName])) {
2256
+                $widths[$charNum - $firstChar] = $this->fonts[$fontName]['C'][$charName]['WX'];
2257 2257
                 if ($this->fonts[$fontName]['isUnicode']) {
2258
-                  $cid_widths[$charName] =  $this->fonts[$fontName]['C'][$charName]['WX'];
2258
+                  $cid_widths[$charName] = $this->fonts[$fontName]['C'][$charName]['WX'];
2259 2259
                 }
2260 2260
               }
2261 2261
             }
@@ -2275,21 +2275,21 @@  discard block
 block discarded – undo
2275 2275
 
2276 2276
             $this->numObj++;
2277 2277
             $this->o_contents($this->numObj, 'new', 'raw');
2278
-            $this->objects[$this->numObj]['c'].=  '[';
2278
+            $this->objects[$this->numObj]['c'] .= '[';
2279 2279
 
2280
-            foreach($widths as  $width) {
2281
-              $this->objects[$this->numObj]['c'].=  ' '.$width;
2280
+            foreach ($widths as  $width) {
2281
+              $this->objects[$this->numObj]['c'] .= ' '.$width;
2282 2282
             }
2283 2283
 
2284
-            $this->objects[$this->numObj]['c'].=  ' ]';
2285
-            $widthid =  $this->numObj;
2284
+            $this->objects[$this->numObj]['c'] .= ' ]';
2285
+            $widthid = $this->numObj;
2286 2286
           }
2287 2287
 
2288 2288
           $missing_width = 500;
2289 2289
           $stemV = 70;
2290 2290
 
2291 2291
           if (isset($this->fonts[$fontName]['MissingWidth'])) {
2292
-            $missing_width =  $this->fonts[$fontName]['MissingWidth'];
2292
+            $missing_width = $this->fonts[$fontName]['MissingWidth'];
2293 2293
           }
2294 2294
           if (isset($this->fonts[$fontName]['StdVW'])) {
2295 2295
             $stemV = $this->fonts[$fontName]['StdVW'];
@@ -2300,28 +2300,28 @@  discard block
 block discarded – undo
2300 2300
           // load the pfb file, and put that into an object too.
2301 2301
           // note that pdf supports only binary format type 1 font files, though there is a
2302 2302
           // simple utility to convert them from pfa to pfb.
2303
-          $data =  file_get_contents($fbfile);
2303
+          $data = file_get_contents($fbfile);
2304 2304
 
2305 2305
           // create the font descriptor
2306 2306
           $this->numObj++;
2307
-          $fontDescriptorId =  $this->numObj;
2307
+          $fontDescriptorId = $this->numObj;
2308 2308
 
2309 2309
           $this->numObj++;
2310
-          $pfbid =  $this->numObj;
2310
+          $pfbid = $this->numObj;
2311 2311
 
2312 2312
           // determine flags (more than a little flakey, hopefully will not matter much)
2313
-          $flags =  0;
2313
+          $flags = 0;
2314 2314
 
2315
-          if  ($this->fonts[$fontName]['ItalicAngle'] !=  0) {
2316
-            $flags+=  pow(2, 6);
2315
+          if ($this->fonts[$fontName]['ItalicAngle'] != 0) {
2316
+            $flags += pow(2, 6);
2317 2317
           }
2318 2318
 
2319
-          if  ($this->fonts[$fontName]['IsFixedPitch'] === 'true') {
2320
-            $flags+=  1;
2319
+          if ($this->fonts[$fontName]['IsFixedPitch'] === 'true') {
2320
+            $flags += 1;
2321 2321
           }
2322 2322
 
2323
-          $flags+=  pow(2, 5); // assume non-sybolic
2324
-          $list =  array(
2323
+          $flags += pow(2, 5); // assume non-sybolic
2324
+          $list = array(
2325 2325
             'Ascent' => 'Ascender', 
2326 2326
             'CapHeight' => 'CapHeight', 
2327 2327
             'MissingWidth' => 'MissingWidth', 
@@ -2329,51 +2329,51 @@  discard block
 block discarded – undo
2329 2329
             'FontBBox' => 'FontBBox', 
2330 2330
             'ItalicAngle' => 'ItalicAngle'
2331 2331
           );
2332
-          $fdopt =  array(
2332
+          $fdopt = array(
2333 2333
             'Flags' => $flags, 
2334 2334
             'FontName' => $adobeFontName, 
2335 2335
             'StemV' => $stemV
2336 2336
           );
2337 2337
 
2338
-          foreach($list as  $k => $v) {
2339
-            if  (isset($this->fonts[$fontName][$v])) {
2340
-              $fdopt[$k] =  $this->fonts[$fontName][$v];
2338
+          foreach ($list as  $k => $v) {
2339
+            if (isset($this->fonts[$fontName][$v])) {
2340
+              $fdopt[$k] = $this->fonts[$fontName][$v];
2341 2341
             }
2342 2342
           }
2343 2343
 
2344
-          if  ($fbtype === 'pfb') {
2345
-            $fdopt['FontFile'] =  $pfbid;
2346
-          } else  if  ($fbtype === 'ttf') {
2347
-            $fdopt['FontFile2'] =  $pfbid;
2344
+          if ($fbtype === 'pfb') {
2345
+            $fdopt['FontFile'] = $pfbid;
2346
+          } else  if ($fbtype === 'ttf') {
2347
+            $fdopt['FontFile2'] = $pfbid;
2348 2348
           }
2349 2349
 
2350 2350
           $this->o_fontDescriptor($fontDescriptorId, 'new', $fdopt);
2351 2351
 
2352 2352
           // embed the font program
2353 2353
           $this->o_contents($this->numObj, 'new');
2354
-          $this->objects[$pfbid]['c'].=  $data;
2354
+          $this->objects[$pfbid]['c'] .= $data;
2355 2355
 
2356 2356
           // determine the cruicial lengths within this file
2357
-          if  ($fbtype === 'pfb') {
2358
-            $l1 =  strpos($data, 'eexec') +6;
2359
-            $l2 =  strpos($data, '00000000') -$l1;
2360
-            $l3 =  mb_strlen($data, '8bit') -$l2-$l1;
2357
+          if ($fbtype === 'pfb') {
2358
+            $l1 = strpos($data, 'eexec') + 6;
2359
+            $l2 = strpos($data, '00000000') - $l1;
2360
+            $l3 = mb_strlen($data, '8bit') - $l2 - $l1;
2361 2361
             $this->o_contents($this->numObj, 'add', array('Length1' => $l1, 'Length2' => $l2, 'Length3' => $l3));
2362
-          } else  if  ($fbtype == 'ttf') {
2363
-            $l1 =  mb_strlen($data, '8bit');
2362
+          } else  if ($fbtype == 'ttf') {
2363
+            $l1 = mb_strlen($data, '8bit');
2364 2364
             $this->o_contents($this->numObj, 'add', array('Length1' => $l1));
2365 2365
           }
2366 2366
 
2367 2367
           // tell the font object about all this new stuff
2368
-          $tmp =  array('BaseFont' => $adobeFontName, 'MissingWidth' => $missing_width, 'Widths' => $widthid, 'FirstChar' => $firstChar, 'LastChar' => $lastChar, 'FontDescriptor' => $fontDescriptorId);
2368
+          $tmp = array('BaseFont' => $adobeFontName, 'MissingWidth' => $missing_width, 'Widths' => $widthid, 'FirstChar' => $firstChar, 'LastChar' => $lastChar, 'FontDescriptor' => $fontDescriptorId);
2369 2369
 
2370
-          if  ($fbtype === 'ttf') {
2371
-            $tmp['SubType'] =  'TrueType';
2370
+          if ($fbtype === 'ttf') {
2371
+            $tmp['SubType'] = 'TrueType';
2372 2372
           }
2373 2373
 
2374 2374
           $this->addMessage('adding extra info to font.('.$fontObj.')');
2375 2375
 
2376
-          foreach($tmp as  $fk => $fv) {
2376
+          foreach ($tmp as  $fk => $fv) {
2377 2377
             $this->addMessage($fk." : ".$fv);
2378 2378
           }
2379 2379
 
@@ -2384,20 +2384,20 @@  discard block
 block discarded – undo
2384 2384
 
2385 2385
         // also set the differences here, note that this means that these will take effect only the
2386 2386
         //first time that a font is selected, else they are ignored
2387
-        if  (isset($options['differences'])) {
2388
-          $this->fonts[$fontName]['differences'] =  $options['differences'];
2387
+        if (isset($options['differences'])) {
2388
+          $this->fonts[$fontName]['differences'] = $options['differences'];
2389 2389
         }
2390 2390
       }
2391 2391
     }
2392 2392
 
2393
-    if  ($set &&  isset($this->fonts[$fontName])) {
2393
+    if ($set && isset($this->fonts[$fontName])) {
2394 2394
       // so if for some reason the font was not set in the last one then it will not be selected
2395
-      $this->currentBaseFont =  $fontName;
2395
+      $this->currentBaseFont = $fontName;
2396 2396
 
2397 2397
       // the next lines mean that if a new font is selected, then the current text state will be
2398 2398
       // applied to it as well.
2399
-      $this->currentFont =  $this->currentBaseFont;
2400
-      $this->currentFontNum =  $this->fonts[$this->currentFont]['fontNum'];
2399
+      $this->currentFont = $this->currentBaseFont;
2400
+      $this->currentFontNum = $this->fonts[$this->currentFont]['fontNum'];
2401 2401
 
2402 2402
       //$this->setCurrentFont();
2403 2403
     }
@@ -2437,8 +2437,8 @@  discard block
 block discarded – undo
2437 2437
     //   } else {
2438 2438
     //     // the this font must not have the right family member for the current state
2439 2439
     //     // simply assume the base font
2440
-    $this->currentFont =  $this->currentBaseFont;
2441
-    $this->currentFontNum =  $this->fonts[$this->currentFont]['fontNum'];
2440
+    $this->currentFont = $this->currentBaseFont;
2441
+    $this->currentFontNum = $this->fonts[$this->currentFont]['fontNum'];
2442 2442
     //  }
2443 2443
   }
2444 2444
 
@@ -2458,17 +2458,17 @@  discard block
 block discarded – undo
2458 2458
    * @access private
2459 2459
    */
2460 2460
   function  addContent($content) {
2461
-    $this->objects[$this->currentContents]['c'].=  $content;
2461
+    $this->objects[$this->currentContents]['c'] .= $content;
2462 2462
   }
2463 2463
 
2464 2464
 
2465 2465
   /**
2466 2466
    * sets the colour for fill operations
2467 2467
    */
2468
-  function  setColor($r, $g, $b, $force =  0) {
2469
-    if  ($r >=  0 &&  ($force ||  $r !=  $this->currentColour['r'] ||  $g !=  $this->currentColour['g'] ||  $b !=  $this->currentColour['b'])) {
2470
-      $this->objects[$this->currentContents]['c'].=  "\n".sprintf('%.3F', $r) .' '.sprintf('%.3F', $g) .' '.sprintf('%.3F', $b) .' rg';
2471
-      $this->currentColour =  array('r' => $r, 'g' => $g, 'b' => $b);
2468
+  function  setColor($r, $g, $b, $force = 0) {
2469
+    if ($r >= 0 && ($force || $r != $this->currentColour['r'] || $g != $this->currentColour['g'] || $b != $this->currentColour['b'])) {
2470
+      $this->objects[$this->currentContents]['c'] .= "\n".sprintf('%.3F', $r).' '.sprintf('%.3F', $g).' '.sprintf('%.3F', $b).' rg';
2471
+      $this->currentColour = array('r' => $r, 'g' => $g, 'b' => $b);
2472 2472
     }
2473 2473
   }
2474 2474
 
@@ -2476,10 +2476,10 @@  discard block
 block discarded – undo
2476 2476
   /**
2477 2477
    * sets the colour for stroke operations
2478 2478
    */
2479
-  function  setStrokeColor($r, $g, $b, $force =  0) {
2480
-    if  ($r >=  0 &&  ($force ||  $r !=  $this->currentStrokeColour['r'] ||  $g !=  $this->currentStrokeColour['g'] ||  $b !=  $this->currentStrokeColour['b'])) {
2481
-      $this->objects[$this->currentContents]['c'].=  "\n".sprintf('%.3F', $r) .' '.sprintf('%.3F', $g) .' '.sprintf('%.3F', $b) .' RG';
2482
-      $this->currentStrokeColour =  array('r' => $r, 'g' => $g, 'b' => $b);
2479
+  function  setStrokeColor($r, $g, $b, $force = 0) {
2480
+    if ($r >= 0 && ($force || $r != $this->currentStrokeColour['r'] || $g != $this->currentStrokeColour['g'] || $b != $this->currentStrokeColour['b'])) {
2481
+      $this->objects[$this->currentContents]['c'] .= "\n".sprintf('%.3F', $r).' '.sprintf('%.3F', $g).' '.sprintf('%.3F', $b).' RG';
2482
+      $this->currentStrokeColour = array('r' => $r, 'g' => $g, 'b' => $b);
2483 2483
     }
2484 2484
   }
2485 2485
 
@@ -2491,8 +2491,8 @@  discard block
 block discarded – undo
2491 2491
     // Create a new graphics state object
2492 2492
     // FIXME: should actually keep track of states that have already been created...
2493 2493
     $this->numObj++;
2494
-    $this->o_extGState($this->numObj,  'new',  $parameters);
2495
-    $this->objects[ $this->currentContents ]['c'].=  "\n/GS" . $this->numStates . " gs";
2494
+    $this->o_extGState($this->numObj, 'new', $parameters);
2495
+    $this->objects[$this->currentContents]['c'] .= "\n/GS".$this->numStates." gs";
2496 2496
   }
2497 2497
 
2498 2498
 
@@ -2514,16 +2514,16 @@  discard block
 block discarded – undo
2514 2514
                                 "ColorDogde", "ColorBurn", "HardLight",
2515 2515
                                 "SoftLight", "Difference", "Exclusion");
2516 2516
 
2517
-    if ( !in_array($mode, $blend_modes) )
2517
+    if (!in_array($mode, $blend_modes))
2518 2518
       $mode = "Normal";
2519 2519
     
2520 2520
     // Only create a new graphics state if required
2521
-    if ( $mode == $this->currentLineTransparency["mode"]  &&
2522
-         $opacity == $this->currentLineTransparency["opacity"] )
2521
+    if ($mode == $this->currentLineTransparency["mode"] &&
2522
+         $opacity == $this->currentLineTransparency["opacity"])
2523 2523
       return;
2524 2524
 
2525 2525
     $options = array("BM" => "/$mode",
2526
-                     "CA" => (float)$opacity);
2526
+                     "CA" => (float) $opacity);
2527 2527
 
2528 2528
     $this->setGraphicsState($options);
2529 2529
   }
@@ -2546,15 +2546,15 @@  discard block
 block discarded – undo
2546 2546
                                 "ColorDogde", "ColorBurn", "HardLight",
2547 2547
                                 "SoftLight", "Difference", "Exclusion");
2548 2548
 
2549
-    if ( !in_array($mode, $blend_modes) )
2549
+    if (!in_array($mode, $blend_modes))
2550 2550
       $mode = "Normal";
2551 2551
 
2552
-    if ( $mode == $this->currentFillTransparency["mode"]  &&
2553
-         $opacity == $this->currentFillTransparency["opacity"] )
2552
+    if ($mode == $this->currentFillTransparency["mode"] &&
2553
+         $opacity == $this->currentFillTransparency["opacity"])
2554 2554
       return;
2555 2555
 
2556 2556
     $options = array("BM" => "/$mode",
2557
-                     "ca" => (float)$opacity);
2557
+                     "ca" => (float) $opacity);
2558 2558
     
2559 2559
     $this->setGraphicsState($options);
2560 2560
   }
@@ -2564,7 +2564,7 @@  discard block
 block discarded – undo
2564 2564
    */
2565 2565
   function  line($x1, $y1, $x2, $y2) {
2566 2566
     $this->objects[$this->currentContents]['c'] .=
2567
-      "\n".sprintf('%.3F', $x1) .' '.sprintf('%.3F', $y1) .' m '.sprintf('%.3F', $x2) .' '.sprintf('%.3F', $y2) .' l S';
2567
+      "\n".sprintf('%.3F', $x1).' '.sprintf('%.3F', $y1).' m '.sprintf('%.3F', $x2).' '.sprintf('%.3F', $y2).' l S';
2568 2568
   }
2569 2569
 
2570 2570
 
@@ -2575,17 +2575,17 @@  discard block
 block discarded – undo
2575 2575
     // in the current line style, draw a bezier curve from (x0,y0) to (x3,y3) using the other two points
2576 2576
     // as the control points for the curve.
2577 2577
     $this->objects[$this->currentContents]['c'] .=
2578
-      "\n".sprintf('%.3F', $x0) .' '.sprintf('%.3F', $y0) .' m '.sprintf('%.3F', $x1) .' '.sprintf('%.3F', $y1);
2578
+      "\n".sprintf('%.3F', $x0).' '.sprintf('%.3F', $y0).' m '.sprintf('%.3F', $x1).' '.sprintf('%.3F', $y1);
2579 2579
 
2580 2580
     $this->objects[$this->currentContents]['c'] .=
2581
-      ' '.sprintf('%.3F', $x2) .' '.sprintf('%.3F', $y2) .' '.sprintf('%.3F', $x3) .' '.sprintf('%.3F', $y3) .' c S';
2581
+      ' '.sprintf('%.3F', $x2).' '.sprintf('%.3F', $y2).' '.sprintf('%.3F', $x3).' '.sprintf('%.3F', $y3).' c S';
2582 2582
   }
2583 2583
 
2584 2584
 
2585 2585
   /**
2586 2586
    * draw a part of an ellipse
2587 2587
    */
2588
-  function  partEllipse($x0, $y0, $astart, $afinish, $r1, $r2 =  0, $angle =  0, $nSeg =  8) {
2588
+  function  partEllipse($x0, $y0, $astart, $afinish, $r1, $r2 = 0, $angle = 0, $nSeg = 8) {
2589 2589
     $this->ellipse($x0, $y0, $r1, $r2, $angle, $nSeg, $astart, $afinish, 0);
2590 2590
   }
2591 2591
 
@@ -2593,8 +2593,8 @@  discard block
 block discarded – undo
2593 2593
   /**
2594 2594
    * draw a filled ellipse
2595 2595
    */
2596
-  function  filledEllipse($x0, $y0, $r1, $r2 =  0, $angle =  0, $nSeg =  8, $astart =  0, $afinish =  360) {
2597
-    return  $this->ellipse($x0, $y0, $r1, $r2 =  0, $angle, $nSeg, $astart, $afinish, 1, 1);
2596
+  function  filledEllipse($x0, $y0, $r1, $r2 = 0, $angle = 0, $nSeg = 8, $astart = 0, $afinish = 360) {
2597
+    return  $this->ellipse($x0, $y0, $r1, $r2 = 0, $angle, $nSeg, $astart, $afinish, 1, 1);
2598 2598
   }
2599 2599
 
2600 2600
 
@@ -2608,78 +2608,78 @@  discard block
 block discarded – undo
2608 2608
    * nSeg is not allowed to be less than 2, as this will simply draw a line (and will even draw a
2609 2609
    * pretty crappy shape at 2, as we are approximating with bezier curves.
2610 2610
    */
2611
-  function  ellipse($x0, $y0, $r1, $r2 =  0, $angle =  0, $nSeg =  8, $astart =  0, $afinish =  360, $close =  1, $fill =  0) {
2612
-    if  ($r1 ==  0) {
2611
+  function  ellipse($x0, $y0, $r1, $r2 = 0, $angle = 0, $nSeg = 8, $astart = 0, $afinish = 360, $close = 1, $fill = 0) {
2612
+    if ($r1 == 0) {
2613 2613
       return;
2614 2614
     }
2615 2615
 
2616
-    if  ($r2 ==  0) {
2617
-      $r2 =  $r1;
2616
+    if ($r2 == 0) {
2617
+      $r2 = $r1;
2618 2618
     }
2619 2619
 
2620
-    if  ($nSeg < 2) {
2621
-      $nSeg =  2;
2620
+    if ($nSeg < 2) {
2621
+      $nSeg = 2;
2622 2622
     }
2623 2623
 
2624
-    $astart =  deg2rad((float)$astart);
2625
-    $afinish =  deg2rad((float)$afinish);
2626
-    $totalAngle = $afinish-$astart;
2624
+    $astart = deg2rad((float) $astart);
2625
+    $afinish = deg2rad((float) $afinish);
2626
+    $totalAngle = $afinish - $astart;
2627 2627
 
2628
-    $dt =  $totalAngle/$nSeg;
2629
-    $dtm =  $dt/3;
2628
+    $dt = $totalAngle / $nSeg;
2629
+    $dtm = $dt / 3;
2630 2630
 
2631
-    if  ($angle !=  0) {
2632
-      $a =  -1*deg2rad((float)$angle);
2631
+    if ($angle != 0) {
2632
+      $a = -1 * deg2rad((float) $angle);
2633 2633
 
2634
-      $tmp  =  "\n q ";
2635
-      $tmp .=  sprintf('%.3F', cos($a)) .' '.sprintf('%.3F', (-1.0*sin($a))) .' '.sprintf('%.3F', sin($a)) .' '.sprintf('%.3F', cos($a)) .' ';
2636
-      $tmp .=  sprintf('%.3F', $x0) .' '.sprintf('%.3F', $y0) .' cm';
2634
+      $tmp  = "\n q ";
2635
+      $tmp .= sprintf('%.3F', cos($a)).' '.sprintf('%.3F', (-1.0 * sin($a))).' '.sprintf('%.3F', sin($a)).' '.sprintf('%.3F', cos($a)).' ';
2636
+      $tmp .= sprintf('%.3F', $x0).' '.sprintf('%.3F', $y0).' cm';
2637 2637
 
2638
-      $this->objects[$this->currentContents]['c'].=  $tmp;
2638
+      $this->objects[$this->currentContents]['c'] .= $tmp;
2639 2639
 
2640
-      $x0 =  0;
2641
-      $y0 =  0;
2640
+      $x0 = 0;
2641
+      $y0 = 0;
2642 2642
     }
2643 2643
 
2644
-    $t1 =  $astart;
2645
-    $a0 =  $x0 + $r1*cos($t1);
2646
-    $b0 =  $y0 + $r2*sin($t1);
2647
-    $c0 =  -$r1 * sin($t1);
2648
-    $d0 =  $r2 * cos($t1);
2644
+    $t1 = $astart;
2645
+    $a0 = $x0 + $r1 * cos($t1);
2646
+    $b0 = $y0 + $r2 * sin($t1);
2647
+    $c0 = -$r1 * sin($t1);
2648
+    $d0 = $r2 * cos($t1);
2649 2649
 
2650
-    $this->objects[$this->currentContents]['c'] .=  "\n".sprintf('%.3F', $a0) .' '.sprintf('%.3F', $b0) .' m ';
2650
+    $this->objects[$this->currentContents]['c'] .= "\n".sprintf('%.3F', $a0).' '.sprintf('%.3F', $b0).' m ';
2651 2651
 
2652
-    for  ($i = 1; $i <=  $nSeg; $i++) {
2652
+    for ($i = 1; $i <= $nSeg; $i++) {
2653 2653
       // draw this bit of the total curve
2654
-      $t1 =  $i * $dt + $astart;
2655
-      $a1 =  $x0 + $r1 * cos($t1);
2656
-      $b1 =  $y0 + $r2 * sin($t1);
2654
+      $t1 = $i * $dt + $astart;
2655
+      $a1 = $x0 + $r1 * cos($t1);
2656
+      $b1 = $y0 + $r2 * sin($t1);
2657 2657
       $c1 = -$r1 * sin($t1);
2658
-      $d1 =  $r2 * cos($t1);
2658
+      $d1 = $r2 * cos($t1);
2659 2659
 
2660 2660
       $this->objects[$this->currentContents]['c']
2661
-        .=  "\n".sprintf('%.3F', ($a0+$c0*$dtm)) .' '.sprintf('%.3F', ($b0 + $d0 * $dtm));
2661
+        .=  "\n".sprintf('%.3F', ($a0 + $c0 * $dtm)).' '.sprintf('%.3F', ($b0 + $d0 * $dtm));
2662 2662
 
2663 2663
       $this->objects[$this->currentContents]['c'] .=
2664
-        ' '.sprintf('%.3F', ($a1-$c1*$dtm)) .' '.sprintf('%.3F', ($b1-$d1*$dtm)) .' '.sprintf('%.3F', $a1) .' '.sprintf('%.3F', $b1) .' c';
2664
+        ' '.sprintf('%.3F', ($a1 - $c1 * $dtm)).' '.sprintf('%.3F', ($b1 - $d1 * $dtm)).' '.sprintf('%.3F', $a1).' '.sprintf('%.3F', $b1).' c';
2665 2665
 
2666
-      $a0 =  $a1;
2667
-      $b0 =  $b1;
2668
-      $c0 =  $c1;
2669
-      $d0 =  $d1;
2666
+      $a0 = $a1;
2667
+      $b0 = $b1;
2668
+      $c0 = $c1;
2669
+      $d0 = $d1;
2670 2670
     }
2671 2671
 
2672
-    if  ($fill) {
2673
-      $this->objects[$this->currentContents]['c'].=  ' f';
2672
+    if ($fill) {
2673
+      $this->objects[$this->currentContents]['c'] .= ' f';
2674 2674
     } else if ($close) {
2675
-        $this->objects[$this->currentContents]['c'].=  ' s';
2675
+        $this->objects[$this->currentContents]['c'] .= ' s';
2676 2676
         // small 's' signifies closing the path as well
2677 2677
     } else {
2678
-      $this->objects[$this->currentContents]['c'].=  ' S';
2678
+      $this->objects[$this->currentContents]['c'] .= ' S';
2679 2679
     }
2680 2680
 
2681
-    if  ($angle !=  0) {
2682
-      $this->objects[$this->currentContents]['c'].=  ' Q';
2681
+    if ($angle != 0) {
2682
+      $this->objects[$this->currentContents]['c'] .= ' Q';
2683 2683
     }
2684 2684
   }
2685 2685
 
@@ -2697,38 +2697,38 @@  discard block
 block discarded – undo
2697 2697
    *   (2,1) is 2 on, 1 off, 2 on, 1 off.. etc
2698 2698
    * phase is a modifier on the dash pattern which is used to shift the point at which the pattern starts.
2699 2699
    */
2700
-  function  setLineStyle($width =  1, $cap =  '', $join =  '', $dash =  '', $phase =  0) {
2700
+  function  setLineStyle($width = 1, $cap = '', $join = '', $dash = '', $phase = 0) {
2701 2701
     // this is quite inefficient in that it sets all the parameters whenever 1 is changed, but will fix another day
2702
-    $string =  '';
2702
+    $string = '';
2703 2703
 
2704
-    if  ($width>0) {
2705
-      $string.=  $width.' w';
2704
+    if ($width > 0) {
2705
+      $string .= $width.' w';
2706 2706
     }
2707 2707
 
2708
-    $ca =  array('butt' => 0, 'round' => 1, 'square' => 2);
2708
+    $ca = array('butt' => 0, 'round' => 1, 'square' => 2);
2709 2709
 
2710
-    if  (isset($ca[$cap])) {
2711
-      $string.=  ' '.$ca[$cap].' J';
2710
+    if (isset($ca[$cap])) {
2711
+      $string .= ' '.$ca[$cap].' J';
2712 2712
     }
2713 2713
 
2714
-    $ja =  array('miter' => 0, 'round' => 1, 'bevel' => 2);
2714
+    $ja = array('miter' => 0, 'round' => 1, 'bevel' => 2);
2715 2715
 
2716
-    if  (isset($ja[$join])) {
2717
-      $string.=  ' '.$ja[$join].' j';
2716
+    if (isset($ja[$join])) {
2717
+      $string .= ' '.$ja[$join].' j';
2718 2718
     }
2719 2719
 
2720
-    if  (is_array($dash)) {
2721
-      $string.=  ' [';
2720
+    if (is_array($dash)) {
2721
+      $string .= ' [';
2722 2722
 
2723 2723
       foreach ($dash as  $len) {
2724
-        $string.=  ' '.$len;
2724
+        $string .= ' '.$len;
2725 2725
       }
2726 2726
 
2727
-      $string.=  ' ] '.$phase.' d';
2727
+      $string .= ' ] '.$phase.' d';
2728 2728
     }
2729 2729
 
2730
-    $this->currentLineStyle =  $string;
2731
-    $this->objects[$this->currentContents]['c'].=  "\n".$string;
2730
+    $this->currentLineStyle = $string;
2731
+    $this->objects[$this->currentContents]['c'] .= "\n".$string;
2732 2732
   }
2733 2733
 
2734 2734
 
@@ -2736,18 +2736,18 @@  discard block
 block discarded – undo
2736 2736
   /**
2737 2737
    * draw a polygon, the syntax for this is similar to the GD polygon command
2738 2738
    */
2739
-  function  polygon($p, $np, $f =  0) {
2740
-    $this->objects[$this->currentContents]['c'].=  "\n";
2741
-    $this->objects[$this->currentContents]['c'].=  sprintf('%.3F', $p[0]) .' '.sprintf('%.3F', $p[1]) .' m ';
2739
+  function  polygon($p, $np, $f = 0) {
2740
+    $this->objects[$this->currentContents]['c'] .= "\n";
2741
+    $this->objects[$this->currentContents]['c'] .= sprintf('%.3F', $p[0]).' '.sprintf('%.3F', $p[1]).' m ';
2742 2742
 
2743
-    for  ($i =  2; $i < $np * 2; $i =  $i + 2) {
2744
-      $this->objects[$this->currentContents]['c'].=  sprintf('%.3F', $p[$i]) .' '.sprintf('%.3F', $p[$i+1]) .' l ';
2743
+    for ($i = 2; $i < $np * 2; $i = $i + 2) {
2744
+      $this->objects[$this->currentContents]['c'] .= sprintf('%.3F', $p[$i]).' '.sprintf('%.3F', $p[$i + 1]).' l ';
2745 2745
     }
2746 2746
 
2747
-    if  ($f ==  1) {
2748
-      $this->objects[$this->currentContents]['c'].=  ' f';
2747
+    if ($f == 1) {
2748
+      $this->objects[$this->currentContents]['c'] .= ' f';
2749 2749
     } else {
2750
-      $this->objects[$this->currentContents]['c'].=  ' S';
2750
+      $this->objects[$this->currentContents]['c'] .= ' S';
2751 2751
     }
2752 2752
   }
2753 2753
 
@@ -2757,7 +2757,7 @@  discard block
 block discarded – undo
2757 2757
    * the coordinates of the upper-right corner
2758 2758
    */
2759 2759
   function  filledRectangle($x1, $y1, $width, $height) {
2760
-    $this->objects[$this->currentContents]['c'].=  "\n".sprintf('%.3F', $x1) .' '.sprintf('%.3F', $y1) .' '.sprintf('%.3F', $width) .' '.sprintf('%.3F', $height) .' re f';
2760
+    $this->objects[$this->currentContents]['c'] .= "\n".sprintf('%.3F', $x1).' '.sprintf('%.3F', $y1).' '.sprintf('%.3F', $width).' '.sprintf('%.3F', $height).' re f';
2761 2761
   }
2762 2762
 
2763 2763
 
@@ -2766,7 +2766,7 @@  discard block
 block discarded – undo
2766 2766
    * the coordinates of the upper-right corner
2767 2767
    */
2768 2768
   function  rectangle($x1, $y1, $width, $height) {
2769
-    $this->objects[$this->currentContents]['c'].=  "\n".sprintf('%.3F', $x1) .' '.sprintf('%.3F', $y1) .' '.sprintf('%.3F', $width) .' '.sprintf('%.3F', $height) .' re S';
2769
+    $this->objects[$this->currentContents]['c'] .= "\n".sprintf('%.3F', $x1).' '.sprintf('%.3F', $y1).' '.sprintf('%.3F', $width).' '.sprintf('%.3F', $height).' re S';
2770 2770
   }
2771 2771
 
2772 2772
 
@@ -2774,47 +2774,47 @@  discard block
 block discarded – undo
2774 2774
    * add a new page to the document
2775 2775
    * this also makes the new page the current active object
2776 2776
    */
2777
-  function  newPage($insert =  0, $id =  0, $pos =  'after') {
2777
+  function  newPage($insert = 0, $id = 0, $pos = 'after') {
2778 2778
     // if there is a state saved, then go up the stack closing them
2779 2779
     // then on the new page, re-open them with the right setings
2780 2780
 
2781
-    if  ($this->nStateStack) {
2782
-      for  ($i =  $this->nStateStack;$i >=  1;$i--) {
2781
+    if ($this->nStateStack) {
2782
+      for ($i = $this->nStateStack; $i >= 1; $i--) {
2783 2783
         $this->restoreState($i);
2784 2784
       }
2785 2785
     }
2786 2786
 
2787 2787
     $this->numObj++;
2788 2788
 
2789
-    if  ($insert) {
2789
+    if ($insert) {
2790 2790
       // the id from the ezPdf class is the id of the contents of the page, not the page object itself
2791 2791
       // query that object to find the parent
2792
-      $rid =  $this->objects[$id]['onPage'];
2793
-      $opt =  array('rid' => $rid, 'pos' => $pos);
2792
+      $rid = $this->objects[$id]['onPage'];
2793
+      $opt = array('rid' => $rid, 'pos' => $pos);
2794 2794
       $this->o_page($this->numObj, 'new', $opt);
2795 2795
     } else {
2796 2796
       $this->o_page($this->numObj, 'new');
2797 2797
     }
2798 2798
 
2799 2799
     // if there is a stack saved, then put that onto the page
2800
-    if  ($this->nStateStack) {
2801
-      for  ($i =  1;$i <=  $this->nStateStack;$i++) {
2800
+    if ($this->nStateStack) {
2801
+      for ($i = 1; $i <= $this->nStateStack; $i++) {
2802 2802
         $this->saveState($i);
2803 2803
       }
2804 2804
     }
2805 2805
 
2806 2806
     // and if there has been a stroke or fill colour set, then transfer them
2807
-    if  ($this->currentColour['r'] >=  0) {
2807
+    if ($this->currentColour['r'] >= 0) {
2808 2808
       $this->setColor($this->currentColour['r'], $this->currentColour['g'], $this->currentColour['b'], 1);
2809 2809
     }
2810 2810
 
2811
-    if  ($this->currentStrokeColour['r'] >=  0) {
2811
+    if ($this->currentStrokeColour['r'] >= 0) {
2812 2812
       $this->setStrokeColor($this->currentStrokeColour['r'], $this->currentStrokeColour['g'], $this->currentStrokeColour['b'], 1);
2813 2813
     }
2814 2814
 
2815 2815
     // if there is a line style set, then put this in too
2816
-    if  (mb_strlen($this->currentLineStyle, '8bit')) {
2817
-      $this->objects[$this->currentContents]['c'].=  "\n".$this->currentLineStyle;
2816
+    if (mb_strlen($this->currentLineStyle, '8bit')) {
2817
+      $this->objects[$this->currentContents]['c'] .= "\n".$this->currentLineStyle;
2818 2818
     }
2819 2819
 
2820 2820
     // the call to the o_page object set currentContents to the present page, so this can be returned as the page id
@@ -2826,7 +2826,7 @@  discard block
 block discarded – undo
2826 2826
    * output the pdf code, streaming it to the browser
2827 2827
    * the relevant headers are set so that hopefully the browser will recognise it
2828 2828
    */
2829
-  function  stream($options =  '') {
2829
+  function  stream($options = '') {
2830 2830
     // setting the options allows the adjustment of the headers
2831 2831
     // values at the moment are:
2832 2832
     // 'Content-Disposition' => 'filename'  - sets the filename, though not too sure how well this will
@@ -2836,36 +2836,36 @@  discard block
 block discarded – undo
2836 2836
     //    them, so I am leaving it off by default.
2837 2837
     // 'compress' = > 1 or 0 - apply content stream compression, this is on (1) by default
2838 2838
     // 'Attachment' => 1 or 0 - if 1, force the browser to open a download dialog
2839
-    if  (!is_array($options)) {
2840
-      $options =  array();
2839
+    if (!is_array($options)) {
2840
+      $options = array();
2841 2841
     }
2842 2842
 
2843
-    if  ( headers_sent())
2843
+    if (headers_sent())
2844 2844
       die("Unable to stream pdf: headers already sent");
2845 2845
 
2846
-    if  ( isset($options['compress']) &&  $options['compress'] ==  0) {
2847
-      $tmp =  ltrim($this->output(1));
2846
+    if (isset($options['compress']) && $options['compress'] == 0) {
2847
+      $tmp = ltrim($this->output(1));
2848 2848
     } else {
2849
-      $tmp =  ltrim($this->output());
2849
+      $tmp = ltrim($this->output());
2850 2850
     }
2851 2851
 
2852 2852
     header("Cache-Control: private");
2853 2853
     header("Content-type: application/pdf");
2854 2854
 
2855 2855
     //FIXME: I don't know that this is sufficient for determining content length (i.e. what about transport compression?)
2856
-    header("Content-Length: " . mb_strlen($tmp, '8bit'));
2857
-    $fileName =  (isset($options['Content-Disposition']) ?  $options['Content-Disposition'] :  'file.pdf');
2856
+    header("Content-Length: ".mb_strlen($tmp, '8bit'));
2857
+    $fileName = (isset($options['Content-Disposition']) ? $options['Content-Disposition'] : 'file.pdf');
2858 2858
 
2859
-    if  ( !isset($options["Attachment"]))
2860
-      $options["Attachment"] =  true;
2859
+    if (!isset($options["Attachment"]))
2860
+      $options["Attachment"] = true;
2861 2861
 
2862
-    $attachment =  $options["Attachment"] ?  "attachment" :  "inline";
2862
+    $attachment = $options["Attachment"] ? "attachment" : "inline";
2863 2863
 
2864 2864
     header("Content-Disposition: $attachment; filename=\"$fileName\"");
2865 2865
 
2866
-    if  (isset($options['Accept-Ranges']) &&  $options['Accept-Ranges'] ==  1) {
2866
+    if (isset($options['Accept-Ranges']) && $options['Accept-Ranges'] == 1) {
2867 2867
       //FIXME: Is this the correct value ... spec says 1#range-unit
2868
-      header("Accept-Ranges: " . mb_strlen($tmp, '8bit'));
2868
+      header("Accept-Ranges: ".mb_strlen($tmp, '8bit'));
2869 2869
     }
2870 2870
 
2871 2871
     echo  $tmp;
@@ -2877,12 +2877,12 @@  discard block
 block discarded – undo
2877 2877
    * return the height in units of the current font in the given size
2878 2878
    */
2879 2879
   function  getFontHeight($size) {
2880
-    if  (!$this->numFonts) {
2880
+    if (!$this->numFonts) {
2881 2881
       $this->selectFont($this->defaultFont);
2882 2882
     }
2883 2883
     
2884 2884
     // for the current font, and the given size, what is the height of the font in user units
2885
-    $h =  $this->fonts[$this->currentFont]['FontBBox'][3]-$this->fonts[$this->currentFont]['FontBBox'][1];
2885
+    $h = $this->fonts[$this->currentFont]['FontBBox'][3] - $this->fonts[$this->currentFont]['FontBBox'][1];
2886 2886
 
2887 2887
     // have to adjust by a font offset for Windows fonts.  unfortunately it looks like
2888 2888
     // the bounding box calculations are wrong and I don't know why.
@@ -2894,10 +2894,10 @@  discard block
 block discarded – undo
2894 2894
       // Courier font.
2895 2895
       //
2896 2896
       // Both have been added manually to the .afm and .ufm files.
2897
-      $h += (int)$this->fonts[$this->currentFont]['FontHeightOffset'];
2897
+      $h += (int) $this->fonts[$this->currentFont]['FontHeightOffset'];
2898 2898
     }
2899 2899
 
2900
-    return  $size*$h/1000;
2900
+    return  $size * $h / 1000;
2901 2901
   }
2902 2902
 
2903 2903
 
@@ -2908,14 +2908,14 @@  discard block
 block discarded – undo
2908 2908
    */
2909 2909
   function  getFontDescender($size) {
2910 2910
     // note that this will most likely return a negative value
2911
-    if  (!$this->numFonts) {
2911
+    if (!$this->numFonts) {
2912 2912
       $this->selectFont($this->defaultFont);
2913 2913
     }
2914 2914
 
2915 2915
     //$h = $this->fonts[$this->currentFont]['FontBBox'][1];
2916 2916
     $h = $this->fonts[$this->currentFont]['Descender'];
2917 2917
 
2918
-    return  $size*$h/1000;
2918
+    return  $size * $h / 1000;
2919 2919
   }
2920 2920
 
2921 2921
 
@@ -2933,7 +2933,7 @@  discard block
 block discarded – undo
2933 2933
   	$cf = $this->currentFont;
2934 2934
     if ($this->fonts[$cf]['isUnicode']) {
2935 2935
       $text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');
2936
-      $text =  $this->utf8toUtf16BE($text, $bom);
2936
+      $text = $this->utf8toUtf16BE($text, $bom);
2937 2937
     } else {
2938 2938
       if (in_array('Windows-1252', mb_list_encodings())) {
2939 2939
         $text = mb_convert_encoding($text, 'Windows-1252', 'UTF-8');
@@ -3034,7 +3034,7 @@  discard block
 block discarded – undo
3034 3034
    * @return string UTF-16 result string
3035 3035
    */
3036 3036
   function  utf8toUtf16BE(&$text, $bom = true) {
3037
-    $cf =  $this->currentFont;
3037
+    $cf = $this->currentFont;
3038 3038
     if (!$this->fonts[$cf]['isUnicode']) return $text;
3039 3039
     $out = $bom ? "\xFE\xFF" : '';
3040 3040
     
@@ -3067,15 +3067,15 @@  discard block
 block discarded – undo
3067 3067
    */
3068 3068
   function  PRVTgetTextPosition($x, $y, $angle, $size, $wa, $text) {
3069 3069
     // given this information return an array containing x and y for the end position as elements 0 and 1
3070
-    $w =  $this->getTextWidth($size, $text);
3070
+    $w = $this->getTextWidth($size, $text);
3071 3071
 
3072 3072
     // need to adjust for the number of spaces in this text
3073
-    $words =  explode(' ', $text);
3074
-    $nspaces =  count($words) -1;
3075
-    $w+=  $wa*$nspaces;
3076
-    $a =  deg2rad((float)$angle);
3073
+    $words = explode(' ', $text);
3074
+    $nspaces = count($words) - 1;
3075
+    $w += $wa * $nspaces;
3076
+    $a = deg2rad((float) $angle);
3077 3077
 
3078
-    return  array(cos($a) *$w+$x, -sin($a) *$w+$y);
3078
+    return  array(cos($a) * $w + $x, -sin($a) * $w + $y);
3079 3079
   }
3080 3080
 
3081 3081
 
@@ -3086,8 +3086,8 @@  discard block
 block discarded – undo
3086 3086
    */
3087 3087
   function  PRVTcheckTextDirective(&$text, $i, &$f) {
3088 3088
     return  0;
3089
-    $x =  0;
3090
-    $y =  0;
3089
+    $x = 0;
3090
+    $y = 0;
3091 3091
     return  $this->PRVTcheckTextDirective1($text, $i, $f, 0, $x, $y);
3092 3092
   }
3093 3093
 
@@ -3101,16 +3101,16 @@  discard block
 block discarded – undo
3101 3101
    *
3102 3102
    * @access private
3103 3103
    */
3104
-  function  PRVTcheckTextDirective1(&$text, $i, &$f, $final, &$x, &$y, $size =  0, $angle =  0, $wordSpaceAdjust =  0) {
3104
+  function  PRVTcheckTextDirective1(&$text, $i, &$f, $final, &$x, &$y, $size = 0, $angle = 0, $wordSpaceAdjust = 0) {
3105 3105
     return  0;
3106
-    $directive =  0;
3107
-    $j =  $i;
3108
-    if  ($text[$j] === '<') {
3106
+    $directive = 0;
3107
+    $j = $i;
3108
+    if ($text[$j] === '<') {
3109 3109
       $j++;
3110 3110
       switch ($text[$j]) {
3111 3111
       case  '/':
3112 3112
         $j++;
3113
-        if  (mb_strlen($text) <=  $j) {
3113
+        if (mb_strlen($text) <= $j) {
3114 3114
           return  $directive;
3115 3115
         }
3116 3116
 
@@ -3118,60 +3118,60 @@  discard block
 block discarded – undo
3118 3118
         case  'b':
3119 3119
         case  'i':
3120 3120
           $j++;
3121
-          if  ($text[$j] === '>') {
3122
-            $p =  mb_strrpos($this->currentTextState, $text[$j-1]);
3121
+          if ($text[$j] === '>') {
3122
+            $p = mb_strrpos($this->currentTextState, $text[$j - 1]);
3123 3123
 
3124
-            if  ($p !==  false) {
3124
+            if ($p !== false) {
3125 3125
               // then there is one to remove
3126
-              $this->currentTextState =  mb_substr($this->currentTextState, 0, $p) .substr($this->currentTextState, $p+1);
3126
+              $this->currentTextState = mb_substr($this->currentTextState, 0, $p).substr($this->currentTextState, $p + 1);
3127 3127
             }
3128 3128
 
3129
-            $directive =  $j-$i+1;
3129
+            $directive = $j - $i + 1;
3130 3130
           }
3131 3131
           break;
3132 3132
 
3133 3133
         case  'c':
3134 3134
           // this this might be a callback function
3135 3135
           $j++;
3136
-          $k =  mb_strpos($text, '>', $j);
3136
+          $k = mb_strpos($text, '>', $j);
3137 3137
 
3138
-          if  ($k !==  false &&  $text[$j] === ':') {
3138
+          if ($k !== false && $text[$j] === ':') {
3139 3139
             // then this will be treated as a callback directive
3140
-            $directive =  $k-$i+1;
3141
-            $f =  0;
3140
+            $directive = $k - $i + 1;
3141
+            $f = 0;
3142 3142
             // split the remainder on colons to get the function name and the paramater
3143
-            $tmp =  mb_substr($text, $j+1, $k-$j-1);
3144
-            $b1 =  mb_strpos($tmp, ':');
3143
+            $tmp = mb_substr($text, $j + 1, $k - $j - 1);
3144
+            $b1 = mb_strpos($tmp, ':');
3145 3145
 
3146
-            if  ($b1 !==  false) {
3147
-              $func =  mb_substr($tmp, 0, $b1);
3148
-              $parm =  mb_substr($tmp, $b1+1);
3146
+            if ($b1 !== false) {
3147
+              $func = mb_substr($tmp, 0, $b1);
3148
+              $parm = mb_substr($tmp, $b1 + 1);
3149 3149
             } else {
3150
-              $func =  $tmp;
3151
-              $parm =  '';
3150
+              $func = $tmp;
3151
+              $parm = '';
3152 3152
             }
3153 3153
 
3154
-            if  (!isset($func) ||  !mb_strlen(trim($func), '8bit')) {
3155
-              $directive =  0;
3154
+            if (!isset($func) || !mb_strlen(trim($func), '8bit')) {
3155
+              $directive = 0;
3156 3156
             } else {
3157 3157
               // only call the function if this is the final call
3158
-              if  ($final) {
3158
+              if ($final) {
3159 3159
                 // need to assess the text position, calculate the text width to this point
3160 3160
                 // can use getTextWidth to find the text width I think
3161
-                $tmp =  $this->PRVTgetTextPosition($x, $y, $angle, $size, $wordSpaceAdjust, mb_substr($text, 0, $i));
3161
+                $tmp = $this->PRVTgetTextPosition($x, $y, $angle, $size, $wordSpaceAdjust, mb_substr($text, 0, $i));
3162 3162
 
3163
-                $info =  array('x' => $tmp[0], 'y' => $tmp[1], 'angle' => $angle, 'status' => 'end', 'p' => $parm, 'nCallback' => $this->nCallback);
3164
-                $x =  $tmp[0];
3165
-                $y =  $tmp[1];
3166
-                $ret =  $this->$func($info);
3163
+                $info = array('x' => $tmp[0], 'y' => $tmp[1], 'angle' => $angle, 'status' => 'end', 'p' => $parm, 'nCallback' => $this->nCallback);
3164
+                $x = $tmp[0];
3165
+                $y = $tmp[1];
3166
+                $ret = $this->$func($info);
3167 3167
 
3168
-                if  (is_array($ret)) {
3168
+                if (is_array($ret)) {
3169 3169
                   // then the return from the callback function could set the position, to start with, later will do font colour, and font
3170
-                  foreach($ret as  $rk => $rv) {
3170
+                  foreach ($ret as  $rk => $rv) {
3171 3171
                     switch ($rk) {
3172 3172
                     case  'x':
3173 3173
                     case  'y':
3174
-                      $$rk =  $rv;
3174
+                      $$rk = $rv;
3175 3175
                       break;
3176 3176
                     }
3177 3177
                   }
@@ -3180,8 +3180,8 @@  discard block
 block discarded – undo
3180 3180
                 // also remove from to the stack
3181 3181
                 // for simplicity, just take from the end, fix this another day
3182 3182
                 $this->nCallback--;
3183
-                if  ($this->nCallback<0) {
3184
-                  $this->nCallBack =  0;
3183
+                if ($this->nCallback < 0) {
3184
+                  $this->nCallBack = 0;
3185 3185
                 }
3186 3186
               }
3187 3187
             }
@@ -3193,49 +3193,49 @@  discard block
 block discarded – undo
3193 3193
       case  'b':
3194 3194
       case  'i':
3195 3195
         $j++;
3196
-        if  ($text[$j] === '>') {
3197
-          $this->currentTextState.=  $text[$j-1];
3198
-          $directive =  $j-$i+1;
3196
+        if ($text[$j] === '>') {
3197
+          $this->currentTextState .= $text[$j - 1];
3198
+          $directive = $j - $i + 1;
3199 3199
         }
3200 3200
         break;
3201 3201
 
3202 3202
       case  'C':
3203
-        $noClose =  1;
3203
+        $noClose = 1;
3204 3204
       case  'c':
3205 3205
         // this this might be a callback function
3206 3206
         $j++;
3207
-        $k =  mb_strpos($text, '>', $j);
3207
+        $k = mb_strpos($text, '>', $j);
3208 3208
 
3209
-        if  ($k !==  false &&  $text[$j] ===  ':') {
3209
+        if ($k !== false && $text[$j] === ':') {
3210 3210
           // then this will be treated as a callback directive
3211
-          $directive =  $k-$i+1;
3211
+          $directive = $k - $i + 1;
3212 3212
 
3213
-          $f =  0;
3213
+          $f = 0;
3214 3214
 
3215 3215
           // split the remainder on colons to get the function name and the paramater
3216 3216
           //          $bits = explode(':',substr($text,$j+1,$k-$j-1));
3217
-          $tmp =  mb_substr($text, $j+1, $k-$j-1);
3218
-          $b1 =  mb_strpos($tmp, ':');
3217
+          $tmp = mb_substr($text, $j + 1, $k - $j - 1);
3218
+          $b1 = mb_strpos($tmp, ':');
3219 3219
 
3220
-          if  ($b1 !==  false) {
3221
-            $func =  mb_substr($tmp, 0, $b1);
3222
-            $parm =  mb_substr($tmp, $b1+1);
3220
+          if ($b1 !== false) {
3221
+            $func = mb_substr($tmp, 0, $b1);
3222
+            $parm = mb_substr($tmp, $b1 + 1);
3223 3223
           } else {
3224
-            $func =  $tmp;
3225
-            $parm =  '';
3224
+            $func = $tmp;
3225
+            $parm = '';
3226 3226
           }
3227 3227
 
3228
-          if  (!isset($func) ||  !mb_strlen(trim($func), '8bit')) {
3229
-            $directive =  0;
3228
+          if (!isset($func) || !mb_strlen(trim($func), '8bit')) {
3229
+            $directive = 0;
3230 3230
           } else {
3231 3231
             // only call the function if this is the final call, ie, the one actually doing printing, not measurement
3232
-            if  ($final) {
3232
+            if ($final) {
3233 3233
               // need to assess the text position, calculate the text width to this point
3234 3234
               // can use getTextWidth to find the text width I think
3235 3235
               // also add the text height and descender
3236
-              $tmp =  $this->PRVTgetTextPosition($x, $y, $angle, $size, $wordSpaceAdjust, mb_substr($text, 0, $i));
3236
+              $tmp = $this->PRVTgetTextPosition($x, $y, $angle, $size, $wordSpaceAdjust, mb_substr($text, 0, $i));
3237 3237
 
3238
-              $info =  array(
3238
+              $info = array(
3239 3239
                 'x' => $tmp[0], 
3240 3240
                 'y' => $tmp[1], 
3241 3241
                 'angle' => $angle, 
@@ -3245,24 +3245,24 @@  discard block
 block discarded – undo
3245 3245
                 'height' => $this->getFontHeight($size), 
3246 3246
                 'descender' => $this->getFontDescender($size)
3247 3247
               );
3248
-              $x =  $tmp[0];
3249
-              $y =  $tmp[1];
3248
+              $x = $tmp[0];
3249
+              $y = $tmp[1];
3250 3250
 
3251
-              if  (!isset($noClose) ||  !$noClose) {
3251
+              if (!isset($noClose) || !$noClose) {
3252 3252
                 // only add to the stack if this is a small 'c', therefore is a start-stop pair
3253 3253
                 $this->nCallback++;
3254
-                $info['nCallback'] =  $this->nCallback;
3255
-                $this->callback[$this->nCallback] =  $info;
3254
+                $info['nCallback'] = $this->nCallback;
3255
+                $this->callback[$this->nCallback] = $info;
3256 3256
               }
3257 3257
 
3258
-              $ret =  $this->$func($info);
3259
-              if  (is_array($ret)) {
3258
+              $ret = $this->$func($info);
3259
+              if (is_array($ret)) {
3260 3260
                 // then the return from the callback function could set the position, to start with, later will do font colour, and font
3261
-                foreach($ret as  $rk => $rv) {
3261
+                foreach ($ret as  $rk => $rv) {
3262 3262
                   switch ($rk) {
3263 3263
                   case  'x':
3264 3264
                   case  'y':
3265
-                    $$rk =  $rv;
3265
+                    $$rk = $rv;
3266 3266
                     break;
3267 3267
                   }
3268 3268
                 }
@@ -3281,16 +3281,16 @@  discard block
 block discarded – undo
3281 3281
   /**
3282 3282
    * add text to the document, at a specified location, size and angle on the page
3283 3283
    */
3284
-  function  addText($x, $y, $size, $text, $angle =  0, $wordSpaceAdjust =  0) {
3285
-    if  (!$this->numFonts) {
3284
+  function  addText($x, $y, $size, $text, $angle = 0, $wordSpaceAdjust = 0) {
3285
+    if (!$this->numFonts) {
3286 3286
       $this->selectFont($this->defaultFont);
3287 3287
     }
3288 3288
 
3289 3289
     // if there are any open callbacks, then they should be called, to show the start of the line
3290
-    if  ($this->nCallback>0) {
3291
-      for  ($i =  $this->nCallback;$i>0;$i--) {
3290
+    if ($this->nCallback > 0) {
3291
+      for ($i = $this->nCallback; $i > 0; $i--) {
3292 3292
         // call each function
3293
-        $info =  array('x' => $x,
3293
+        $info = array('x' => $x,
3294 3294
                        'y' => $y,
3295 3295
                        'angle' => $angle,
3296 3296
                        'status' => 'sol',
@@ -3299,28 +3299,28 @@  discard block
 block discarded – undo
3299 3299
                        'height' => $this->callback[$i]['height'],
3300 3300
                        'descender' => $this->callback[$i]['descender']);
3301 3301
 
3302
-        $func =  $this->callback[$i]['f'];
3302
+        $func = $this->callback[$i]['f'];
3303 3303
         $this->$func($info);
3304 3304
       }
3305 3305
     }
3306 3306
 
3307
-    if  ($angle ==  0) {
3308
-      $this->objects[$this->currentContents]['c'].=  "\n".'BT '.sprintf('%.3F', $x) .' '.sprintf('%.3F', $y) .' Td';
3307
+    if ($angle == 0) {
3308
+      $this->objects[$this->currentContents]['c'] .= "\n".'BT '.sprintf('%.3F', $x).' '.sprintf('%.3F', $y).' Td';
3309 3309
     } else {
3310
-      $a =  deg2rad((float)$angle);
3311
-      $tmp =  "\n".'BT ';
3312
-      $tmp.=  sprintf('%.3F', cos($a)) .' '.sprintf('%.3F', (-1.0*sin($a))) .' '.sprintf('%.3F', sin($a)) .' '.sprintf('%.3F', cos($a)) .' ';
3313
-      $tmp.=  sprintf('%.3F', $x) .' '.sprintf('%.3F', $y) .' Tm';
3314
-      $this->objects[$this->currentContents]['c'].=  $tmp;
3310
+      $a = deg2rad((float) $angle);
3311
+      $tmp = "\n".'BT ';
3312
+      $tmp .= sprintf('%.3F', cos($a)).' '.sprintf('%.3F', (-1.0 * sin($a))).' '.sprintf('%.3F', sin($a)).' '.sprintf('%.3F', cos($a)).' ';
3313
+      $tmp .= sprintf('%.3F', $x).' '.sprintf('%.3F', $y).' Tm';
3314
+      $this->objects[$this->currentContents]['c'] .= $tmp;
3315 3315
     }
3316 3316
 
3317
-    if  ($wordSpaceAdjust !=  0 ||  $wordSpaceAdjust !=  $this->wordSpaceAdjust) {
3318
-      $this->wordSpaceAdjust =  $wordSpaceAdjust;
3319
-      $this->objects[$this->currentContents]['c'].=  ' '.sprintf('%.3F', $wordSpaceAdjust) .' Tw';
3317
+    if ($wordSpaceAdjust != 0 || $wordSpaceAdjust != $this->wordSpaceAdjust) {
3318
+      $this->wordSpaceAdjust = $wordSpaceAdjust;
3319
+      $this->objects[$this->currentContents]['c'] .= ' '.sprintf('%.3F', $wordSpaceAdjust).' Tw';
3320 3320
     }
3321 3321
 
3322
-    $len =  mb_strlen($text);
3323
-    $start =  0;
3322
+    $len = mb_strlen($text);
3323
+    $start = 0;
3324 3324
 
3325 3325
     /*
3326 3326
      for ($i = 0;$i<$len;$i++){
@@ -3365,20 +3365,20 @@  discard block
 block discarded – undo
3365 3365
 
3366 3366
      }
3367 3367
     */
3368
-    if  ($start < $len) {
3369
-      $part =  $text; // OAR - Don't need this anymore, given that $start always equals zero.  substr($text, $start);
3370
-      $this->objects[$this->currentContents]['c'].=  ' /F'.$this->currentFontNum.' '.sprintf('%.1F', $size) .' Tf ';
3371
-      $this->objects[$this->currentContents]['c'].=  ' ('.$this->filterText($part, false) .') Tj';
3368
+    if ($start < $len) {
3369
+      $part = $text; // OAR - Don't need this anymore, given that $start always equals zero.  substr($text, $start);
3370
+      $this->objects[$this->currentContents]['c'] .= ' /F'.$this->currentFontNum.' '.sprintf('%.1F', $size).' Tf ';
3371
+      $this->objects[$this->currentContents]['c'] .= ' ('.$this->filterText($part, false).') Tj';
3372 3372
     }
3373 3373
 
3374
-    $this->objects[$this->currentContents]['c'].=  ' ET';
3374
+    $this->objects[$this->currentContents]['c'] .= ' ET';
3375 3375
 
3376 3376
     // if there are any open callbacks, then they should be called, to show the end of the line
3377
-    if  ($this->nCallback>0) {
3378
-      for  ($i =  $this->nCallback;$i>0;$i--) {
3377
+    if ($this->nCallback > 0) {
3378
+      for ($i = $this->nCallback; $i > 0; $i--) {
3379 3379
         // call each function
3380
-        $tmp =  $this->PRVTgetTextPosition($x, $y, $angle, $size, $wordSpaceAdjust, $text);
3381
-        $info =  array(
3380
+        $tmp = $this->PRVTgetTextPosition($x, $y, $angle, $size, $wordSpaceAdjust, $text);
3381
+        $info = array(
3382 3382
           'x' => $tmp[0], 
3383 3383
           'y' => $tmp[1], 
3384 3384
           'angle' => $angle,
@@ -3388,7 +3388,7 @@  discard block
 block discarded – undo
3388 3388
           'height' => $this->callback[$i]['height'], 
3389 3389
           'descender' => $this->callback[$i]['descender']
3390 3390
         );
3391
-        $func =  $this->callback[$i]['f'];
3391
+        $func = $this->callback[$i]['f'];
3392 3392
         $this->$func($info);
3393 3393
       }
3394 3394
     }
@@ -3399,68 +3399,68 @@  discard block
 block discarded – undo
3399 3399
    * calculate how wide a given text string will be on a page, at a given size.
3400 3400
    * this can be called externally, but is alse used by the other class functions
3401 3401
    */
3402
-  function  getTextWidth($size, $text, $spacing =  0) {
3402
+  function  getTextWidth($size, $text, $spacing = 0) {
3403 3403
     // this function should not change any of the settings, though it will need to
3404 3404
     // track any directives which change during calculation, so copy them at the start
3405 3405
     // and put them back at the end.
3406
-    $store_currentTextState =  $this->currentTextState;
3406
+    $store_currentTextState = $this->currentTextState;
3407 3407
 
3408
-    if  (!$this->numFonts) {
3408
+    if (!$this->numFonts) {
3409 3409
       $this->selectFont($this->defaultFont);
3410 3410
     }
3411 3411
 
3412 3412
     // converts a number or a float to a string so it can get the width
3413
-    $text =  "$text";
3413
+    $text = "$text";
3414 3414
 
3415 3415
     // hmm, this is where it all starts to get tricky - use the font information to
3416 3416
     // calculate the width of each character, add them up and convert to user units
3417
-    $w =  0;
3418
-    $cf =  $this->currentFont;
3419
-    $space_scale =  1000 / $size;
3420
-    if ( $this->fonts[$cf]['isUnicode']) {
3417
+    $w = 0;
3418
+    $cf = $this->currentFont;
3419
+    $space_scale = 1000 / $size;
3420
+    if ($this->fonts[$cf]['isUnicode']) {
3421 3421
       // for Unicode, use the code points array to calculate width rather
3422 3422
       // than just the string itself
3423
-      $unicode =  $this->utf8toCodePointsArray($text);
3423
+      $unicode = $this->utf8toCodePointsArray($text);
3424 3424
 
3425 3425
       foreach ($unicode as $char) {
3426 3426
         // check if we have to replace character
3427
-      if  ( isset($this->fonts[$cf]['differences'][$char])) {
3428
-          $char =  $this->fonts[$cf]['differences'][$char];
3427
+      if (isset($this->fonts[$cf]['differences'][$char])) {
3428
+          $char = $this->fonts[$cf]['differences'][$char];
3429 3429
         }
3430 3430
         // add the character width
3431
-        if  ( isset($this->fonts[$cf]['C'][$char]['WX'])) {
3432
-          $w+=  $this->fonts[$cf]['C'][$char]['WX'];
3431
+        if (isset($this->fonts[$cf]['C'][$char]['WX'])) {
3432
+          $w += $this->fonts[$cf]['C'][$char]['WX'];
3433 3433
         }
3434 3434
         // add additional padding for space
3435
-        if  ( $char ==  32) {  // Space
3436
-          $w+=  $spacing * $space_scale;
3435
+        if ($char == 32) {  // Space
3436
+          $w += $spacing * $space_scale;
3437 3437
         }
3438 3438
       }
3439 3439
 
3440 3440
     } else {
3441
-      $len =  mb_strlen($text, 'Windows-1252');
3441
+      $len = mb_strlen($text, 'Windows-1252');
3442 3442
 
3443
-      for  ($i =  0; $i < $len; $i++) {
3444
-        $char =  ord($text[$i]);
3443
+      for ($i = 0; $i < $len; $i++) {
3444
+        $char = ord($text[$i]);
3445 3445
         // check if we have to replace character
3446
-        if  ( isset($this->fonts[$cf]['differences'][$char])) {
3447
-          $char =  $this->fonts[$cf]['differences'][$char];
3446
+        if (isset($this->fonts[$cf]['differences'][$char])) {
3447
+          $char = $this->fonts[$cf]['differences'][$char];
3448 3448
         }
3449 3449
         // add the character width
3450
-        if  ( isset($this->fonts[$cf]['C'][$char]['WX'])) {
3451
-        $w+=  $this->fonts[$cf]['C'][$char]['WX'];
3450
+        if (isset($this->fonts[$cf]['C'][$char]['WX'])) {
3451
+        $w += $this->fonts[$cf]['C'][$char]['WX'];
3452 3452
         }
3453 3453
         // add additional padding for space
3454
-        if  ( $char ==  32) {  // Space
3455
-          $w+=  $spacing * $space_scale;
3454
+        if ($char == 32) {  // Space
3455
+          $w += $spacing * $space_scale;
3456 3456
         }
3457 3457
       }
3458 3458
     }
3459 3459
 
3460
-    $this->currentTextState =  $store_currentTextState;
3460
+    $this->currentTextState = $store_currentTextState;
3461 3461
     $this->setCurrentFont();
3462 3462
 
3463
-    return  $w*$size/1000;
3463
+    return  $w * $size / 1000;
3464 3464
   }
3465 3465
 
3466 3466
 
@@ -3470,28 +3470,28 @@  discard block
 block discarded – undo
3470 3470
    * @access private
3471 3471
    */
3472 3472
   function  PRVTadjustWrapText($text, $actual, $width, &$x, &$adjust, $justification) {
3473
-    switch  ($justification) {
3473
+    switch ($justification) {
3474 3474
     case  'left':
3475 3475
       return;
3476 3476
 
3477 3477
     case  'right':
3478
-      $x+=  $width-$actual;
3478
+      $x += $width - $actual;
3479 3479
       break;
3480 3480
 
3481 3481
     case  'center':
3482 3482
     case  'centre':
3483
-      $x+=  ($width-$actual) /2;
3483
+      $x += ($width - $actual) / 2;
3484 3484
       break;
3485 3485
 
3486 3486
     case  'full':
3487 3487
       // count the number of words
3488
-      $words =  explode(' ', $text);
3489
-      $nspaces =  count($words) -1;
3488
+      $words = explode(' ', $text);
3489
+      $nspaces = count($words) - 1;
3490 3490
 
3491
-      if  ($nspaces>0) {
3492
-        $adjust =  ($width-$actual) /$nspaces;
3491
+      if ($nspaces > 0) {
3492
+        $adjust = ($width - $actual) / $nspaces;
3493 3493
       } else {
3494
-        $adjust =  0;
3494
+        $adjust = 0;
3495 3495
       }
3496 3496
       break;
3497 3497
     }
@@ -3504,9 +3504,9 @@  discard block
 block discarded – undo
3504 3504
    * and return the remainder.
3505 3505
    * justification and angle can also be specified for the text
3506 3506
    */
3507
-  function  addTextWrap($x, $y, $width, $size, $text, $justification =  'left', $angle =  0, $test =  0) {
3507
+  function  addTextWrap($x, $y, $width, $size, $text, $justification = 'left', $angle = 0, $test = 0) {
3508 3508
   	// TODO - need to support Unicode
3509
-    $cf =  $this->currentFont;
3509
+    $cf = $this->currentFont;
3510 3510
     if ($this->fonts[$cf]['isUnicode']) {
3511 3511
         die("addTextWrap does not support Unicode yet!");
3512 3512
     }
@@ -3518,89 +3518,89 @@  discard block
 block discarded – undo
3518 3518
 
3519 3519
     // need to store the initial text state, as this will change during the width calculation
3520 3520
     // but will need to be re-set before printing, so that the chars work out right
3521
-    $store_currentTextState =  $this->currentTextState;
3521
+    $store_currentTextState = $this->currentTextState;
3522 3522
 
3523
-    if  (!$this->numFonts) {
3523
+    if (!$this->numFonts) {
3524 3524
       $this->selectFont($this->defaultFont);
3525 3525
     }
3526 3526
 
3527
-    if  ($width <=  0) {
3527
+    if ($width <= 0) {
3528 3528
       // error, pretend it printed ok, otherwise risking a loop
3529 3529
       return  '';
3530 3530
     }
3531 3531
 
3532
-    $w =  0;
3533
-    $break =  0;
3534
-    $breakWidth =  0;
3535
-    $len =  mb_strlen($text);
3536
-    $cf =  $this->currentFont;
3537
-    $tw =  $width/$size*1000;
3532
+    $w = 0;
3533
+    $break = 0;
3534
+    $breakWidth = 0;
3535
+    $len = mb_strlen($text);
3536
+    $cf = $this->currentFont;
3537
+    $tw = $width / $size * 1000;
3538 3538
 
3539
-    for  ($i =  0;$i<$len;$i++) {
3540
-      $f =  1;
3541
-      $directive =  0;
3539
+    for ($i = 0; $i < $len; $i++) {
3540
+      $f = 1;
3541
+      $directive = 0;
3542 3542
       //$this->PRVTcheckTextDirective($text,$i,$f);
3543
-      if  ($directive) {
3544
-        if  ($f) {
3543
+      if ($directive) {
3544
+        if ($f) {
3545 3545
           $this->setCurrentFont();
3546
-          $cf =  $this->currentFont;
3546
+          $cf = $this->currentFont;
3547 3547
         }
3548 3548
 
3549
-        $i =  $i+$directive-1;
3549
+        $i = $i + $directive - 1;
3550 3550
       } else {
3551
-        $cOrd =  ord($text[$i]);
3551
+        $cOrd = ord($text[$i]);
3552 3552
 
3553
-        if  (isset($this->fonts[$cf]['differences'][$cOrd])) {
3553
+        if (isset($this->fonts[$cf]['differences'][$cOrd])) {
3554 3554
           // then this character is being replaced by another
3555
-          $cOrd2 =  $this->fonts[$cf]['differences'][$cOrd];
3555
+          $cOrd2 = $this->fonts[$cf]['differences'][$cOrd];
3556 3556
         } else {
3557
-          $cOrd2 =  $cOrd;
3557
+          $cOrd2 = $cOrd;
3558 3558
         }
3559 3559
 
3560
-        if  (isset($this->fonts[$cf]['C'][$cOrd2]['WX'])) {
3561
-          $w+=  $this->fonts[$cf]['C'][$cOrd2]['WX'];
3560
+        if (isset($this->fonts[$cf]['C'][$cOrd2]['WX'])) {
3561
+          $w += $this->fonts[$cf]['C'][$cOrd2]['WX'];
3562 3562
         }
3563 3563
 
3564
-        if  ($w>$tw) {
3564
+        if ($w > $tw) {
3565 3565
           // then we need to truncate this line
3566
-          if  ($break>0) {
3566
+          if ($break > 0) {
3567 3567
             // then we have somewhere that we can split :)
3568
-            if  ($text[$break] ===  ' ') {
3569
-              $tmp =  mb_substr($text, 0, $break);
3568
+            if ($text[$break] === ' ') {
3569
+              $tmp = mb_substr($text, 0, $break);
3570 3570
             } else {
3571
-              $tmp =  mb_substr($text, 0, $break+1);
3571
+              $tmp = mb_substr($text, 0, $break + 1);
3572 3572
             }
3573 3573
 
3574
-            $adjust =  0;
3574
+            $adjust = 0;
3575 3575
             $this->PRVTadjustWrapText($tmp, $breakWidth, $width, $x, $adjust, $justification);
3576 3576
 
3577 3577
             // reset the text state
3578
-            $this->currentTextState =  $store_currentTextState;
3578
+            $this->currentTextState = $store_currentTextState;
3579 3579
             $this->setCurrentFont();
3580 3580
 
3581
-            if  (!$test) {
3581
+            if (!$test) {
3582 3582
               $this->addText($x, $y, $size, $tmp, $angle, $adjust);
3583 3583
             }
3584 3584
 
3585
-            return  mb_substr($text, $break+1);
3585
+            return  mb_substr($text, $break + 1);
3586 3586
           } else {
3587 3587
             // just split before the current character
3588
-            $tmp =  mb_substr($text, 0, $i);
3589
-            $adjust =  0;
3590
-            $ctmp =  ord($text[$i]);
3588
+            $tmp = mb_substr($text, 0, $i);
3589
+            $adjust = 0;
3590
+            $ctmp = ord($text[$i]);
3591 3591
 
3592
-            if  (isset($this->fonts[$cf]['differences'][$ctmp])) {
3593
-              $ctmp =  $this->fonts[$cf]['differences'][$ctmp];
3592
+            if (isset($this->fonts[$cf]['differences'][$ctmp])) {
3593
+              $ctmp = $this->fonts[$cf]['differences'][$ctmp];
3594 3594
             }
3595 3595
 
3596
-            $tmpw =  ($w-$this->fonts[$cf]['C'][$ctmp]['WX']) *$size/1000;
3596
+            $tmpw = ($w - $this->fonts[$cf]['C'][$ctmp]['WX']) * $size / 1000;
3597 3597
             $this->PRVTadjustWrapText($tmp, $tmpw, $width, $x, $adjust, $justification);
3598 3598
 
3599 3599
             // reset the text state
3600
-            $this->currentTextState =  $store_currentTextState;
3600
+            $this->currentTextState = $store_currentTextState;
3601 3601
             $this->setCurrentFont();
3602 3602
 
3603
-            if  (!$test) {
3603
+            if (!$test) {
3604 3604
               $this->addText($x, $y, $size, $tmp, $angle, $adjust);
3605 3605
             }
3606 3606
 
@@ -3608,39 +3608,39 @@  discard block
 block discarded – undo
3608 3608
           }
3609 3609
         }
3610 3610
 
3611
-        if  ($text[$i] ===  '-') {
3612
-          $break =  $i;
3613
-          $breakWidth =  $w*$size/1000;
3611
+        if ($text[$i] === '-') {
3612
+          $break = $i;
3613
+          $breakWidth = $w * $size / 1000;
3614 3614
         }
3615 3615
 
3616
-        if  ($text[$i] ===  ' ') {
3617
-          $break =  $i;
3618
-          $ctmp =  ord($text[$i]);
3616
+        if ($text[$i] === ' ') {
3617
+          $break = $i;
3618
+          $ctmp = ord($text[$i]);
3619 3619
 
3620
-          if  (isset($this->fonts[$cf]['differences'][$ctmp])) {
3621
-            $ctmp =  $this->fonts[$cf]['differences'][$ctmp];
3620
+          if (isset($this->fonts[$cf]['differences'][$ctmp])) {
3621
+            $ctmp = $this->fonts[$cf]['differences'][$ctmp];
3622 3622
           }
3623 3623
 
3624
-          $breakWidth =  ($w-$this->fonts[$cf]['C'][$ctmp]['WX']) *$size/1000;
3624
+          $breakWidth = ($w - $this->fonts[$cf]['C'][$ctmp]['WX']) * $size / 1000;
3625 3625
         }
3626 3626
       }
3627 3627
     }
3628 3628
 
3629 3629
     // then there was no need to break this line
3630
-    if  ($justification ===  'full') {
3631
-      $justification =  'left';
3630
+    if ($justification === 'full') {
3631
+      $justification = 'left';
3632 3632
     }
3633 3633
 
3634
-    $adjust =  0;
3635
-    $tmpw =  $w*$size/1000;
3634
+    $adjust = 0;
3635
+    $tmpw = $w * $size / 1000;
3636 3636
 
3637 3637
     $this->PRVTadjustWrapText($text, $tmpw, $width, $x, $adjust, $justification);
3638 3638
 
3639 3639
     // reset the text state
3640
-    $this->currentTextState =  $store_currentTextState;
3640
+    $this->currentTextState = $store_currentTextState;
3641 3641
     $this->setCurrentFont();
3642 3642
 
3643
-    if  (!$test) {
3643
+    if (!$test) {
3644 3644
       $this->addText($x, $y, $size, $text, $angle, $adjust, $angle);
3645 3645
     }
3646 3646
 
@@ -3654,45 +3654,45 @@  discard block
 block discarded – undo
3654 3654
    * This is to get around not being able to have open 'q' across pages
3655 3655
    *
3656 3656
    */
3657
-  function  saveState($pageEnd =  0) {
3658
-    if  ($pageEnd) {
3657
+  function  saveState($pageEnd = 0) {
3658
+    if ($pageEnd) {
3659 3659
       // this will be called at a new page to return the state to what it was on the
3660 3660
       // end of the previous page, before the stack was closed down
3661 3661
       // This is to get around not being able to have open 'q' across pages
3662
-      $opt =  $this->stateStack[$pageEnd];
3662
+      $opt = $this->stateStack[$pageEnd];
3663 3663
       // ok to use this as stack starts numbering at 1
3664 3664
       $this->setColor($opt['col']['r'], $opt['col']['g'], $opt['col']['b'], 1);
3665 3665
       $this->setStrokeColor($opt['str']['r'], $opt['str']['g'], $opt['str']['b'], 1);
3666
-      $this->objects[$this->currentContents]['c'].=  "\n".$opt['lin'];
3666
+      $this->objects[$this->currentContents]['c'] .= "\n".$opt['lin'];
3667 3667
       //    $this->currentLineStyle = $opt['lin'];
3668 3668
     } else {
3669 3669
       $this->nStateStack++;
3670
-      $this->stateStack[$this->nStateStack] =  array(
3670
+      $this->stateStack[$this->nStateStack] = array(
3671 3671
         'col' => $this->currentColour, 
3672 3672
         'str' => $this->currentStrokeColour, 
3673 3673
         'lin' => $this->currentLineStyle
3674 3674
       );
3675 3675
     }
3676 3676
 
3677
-    $this->objects[$this->currentContents]['c'].=  "\nq";
3677
+    $this->objects[$this->currentContents]['c'] .= "\nq";
3678 3678
   }
3679 3679
 
3680 3680
 
3681 3681
   /**
3682 3682
    * restore a previously saved state
3683 3683
    */
3684
-  function  restoreState($pageEnd =  0) {
3685
-    if  (!$pageEnd) {
3686
-      $n =  $this->nStateStack;
3687
-      $this->currentColour =  $this->stateStack[$n]['col'];
3688
-      $this->currentStrokeColour =  $this->stateStack[$n]['str'];
3689
-      $this->objects[$this->currentContents]['c'].=  "\n".$this->stateStack[$n]['lin'];
3690
-      $this->currentLineStyle =  $this->stateStack[$n]['lin'];
3684
+  function  restoreState($pageEnd = 0) {
3685
+    if (!$pageEnd) {
3686
+      $n = $this->nStateStack;
3687
+      $this->currentColour = $this->stateStack[$n]['col'];
3688
+      $this->currentStrokeColour = $this->stateStack[$n]['str'];
3689
+      $this->objects[$this->currentContents]['c'] .= "\n".$this->stateStack[$n]['lin'];
3690
+      $this->currentLineStyle = $this->stateStack[$n]['lin'];
3691 3691
       unset($this->stateStack[$n]);
3692 3692
       $this->nStateStack--;
3693 3693
     }
3694 3694
     
3695
-    $this->objects[$this->currentContents]['c'].=  "\nQ";
3695
+    $this->objects[$this->currentContents]['c'] .= "\nQ";
3696 3696
   }
3697 3697
 
3698 3698
 
@@ -3704,12 +3704,12 @@  discard block
 block discarded – undo
3704 3704
    */
3705 3705
   function  openObject() {
3706 3706
     $this->nStack++;
3707
-    $this->stack[$this->nStack] =  array('c' => $this->currentContents, 'p' => $this->currentPage);
3707
+    $this->stack[$this->nStack] = array('c' => $this->currentContents, 'p' => $this->currentPage);
3708 3708
     // add a new object of the content type, to hold the data flow
3709 3709
     $this->numObj++;
3710 3710
     $this->o_contents($this->numObj, 'new');
3711
-    $this->currentContents =  $this->numObj;
3712
-    $this->looseObjects[$this->numObj] =  1;
3711
+    $this->currentContents = $this->numObj;
3712
+    $this->looseObjects[$this->numObj] = 1;
3713 3713
 
3714 3714
     return  $this->numObj;
3715 3715
   }
@@ -3720,12 +3720,12 @@  discard block
 block discarded – undo
3720 3720
    */
3721 3721
   function  reopenObject($id) {
3722 3722
     $this->nStack++;
3723
-    $this->stack[$this->nStack] =  array('c' => $this->currentContents, 'p' => $this->currentPage);
3724
-    $this->currentContents =  $id;
3723
+    $this->stack[$this->nStack] = array('c' => $this->currentContents, 'p' => $this->currentPage);
3724
+    $this->currentContents = $id;
3725 3725
 
3726 3726
     // also if this object is the primary contents for a page, then set the current page to its parent
3727
-    if  (isset($this->objects[$id]['onPage'])) {
3728
-      $this->currentPage =  $this->objects[$id]['onPage'];
3727
+    if (isset($this->objects[$id]['onPage'])) {
3728
+      $this->currentPage = $this->objects[$id]['onPage'];
3729 3729
     }
3730 3730
   }
3731 3731
 
@@ -3736,9 +3736,9 @@  discard block
 block discarded – undo
3736 3736
   function  closeObject() {
3737 3737
     // close the object, as long as there was one open in the first place, which will be indicated by
3738 3738
     // an objectId on the stack.
3739
-    if  ($this->nStack>0) {
3740
-      $this->currentContents =  $this->stack[$this->nStack]['c'];
3741
-      $this->currentPage =  $this->stack[$this->nStack]['p'];
3739
+    if ($this->nStack > 0) {
3740
+      $this->currentContents = $this->stack[$this->nStack]['c'];
3741
+      $this->currentPage = $this->stack[$this->nStack]['p'];
3742 3742
       $this->nStack--;
3743 3743
       // easier to probably not worry about removing the old entries, they will be overwritten
3744 3744
       // if there are new ones.
@@ -3752,8 +3752,8 @@  discard block
 block discarded – undo
3752 3752
   function  stopObject($id) {
3753 3753
     // if an object has been appearing on pages up to now, then stop it, this page will
3754 3754
     // be the last one that could contian it.
3755
-    if  (isset($this->addLooseObjects[$id])) {
3756
-      $this->addLooseObjects[$id] =  '';
3755
+    if (isset($this->addLooseObjects[$id])) {
3756
+      $this->addLooseObjects[$id] = '';
3757 3757
     }
3758 3758
   }
3759 3759
 
@@ -3761,18 +3761,18 @@  discard block
 block discarded – undo
3761 3761
   /**
3762 3762
    * after an object has been created, it wil only show if it has been added, using this function.
3763 3763
    */
3764
-  function  addObject($id, $options =  'add') {
3764
+  function  addObject($id, $options = 'add') {
3765 3765
     // add the specified object to the page
3766
-    if  (isset($this->looseObjects[$id]) &&  $this->currentContents !=  $id) {
3766
+    if (isset($this->looseObjects[$id]) && $this->currentContents != $id) {
3767 3767
       // then it is a valid object, and it is not being added to itself
3768 3768
       switch ($options) {
3769 3769
       case  'all':
3770 3770
         // then this object is to be added to this page (done in the next block) and
3771 3771
         // all future new pages.
3772
-        $this->addLooseObjects[$id] =  'all';
3772
+        $this->addLooseObjects[$id] = 'all';
3773 3773
 
3774 3774
       case  'add':
3775
-        if  (isset($this->objects[$this->currentContents]['onPage'])) {
3775
+        if (isset($this->objects[$this->currentContents]['onPage'])) {
3776 3776
           // then the destination contents is the primary for the page
3777 3777
           // (though this object is actually added to that page)
3778 3778
           $this->o_page($this->objects[$this->currentContents]['onPage'], 'content', $id);
@@ -3780,33 +3780,33 @@  discard block
 block discarded – undo
3780 3780
         break;
3781 3781
 
3782 3782
       case  'even':
3783
-        $this->addLooseObjects[$id] =  'even';
3784
-        $pageObjectId =  $this->objects[$this->currentContents]['onPage'];
3785
-        if  ($this->objects[$pageObjectId]['info']['pageNum']%2 ==  0) {
3783
+        $this->addLooseObjects[$id] = 'even';
3784
+        $pageObjectId = $this->objects[$this->currentContents]['onPage'];
3785
+        if ($this->objects[$pageObjectId]['info']['pageNum'] % 2 == 0) {
3786 3786
           $this->addObject($id);
3787 3787
           // hacky huh :)
3788 3788
         }
3789 3789
         break;
3790 3790
 
3791 3791
       case  'odd':
3792
-        $this->addLooseObjects[$id] =  'odd';
3793
-        $pageObjectId =  $this->objects[$this->currentContents]['onPage'];
3794
-        if  ($this->objects[$pageObjectId]['info']['pageNum']%2 ==  1) {
3792
+        $this->addLooseObjects[$id] = 'odd';
3793
+        $pageObjectId = $this->objects[$this->currentContents]['onPage'];
3794
+        if ($this->objects[$pageObjectId]['info']['pageNum'] % 2 == 1) {
3795 3795
           $this->addObject($id);
3796 3796
           // hacky huh :)
3797 3797
         }
3798 3798
         break;
3799 3799
 
3800 3800
       case  'next':
3801
-        $this->addLooseObjects[$id] =  'all';
3801
+        $this->addLooseObjects[$id] = 'all';
3802 3802
         break;
3803 3803
 
3804 3804
       case  'nexteven':
3805
-        $this->addLooseObjects[$id] =  'even';
3805
+        $this->addLooseObjects[$id] = 'even';
3806 3806
         break;
3807 3807
 
3808 3808
       case  'nextodd':
3809
-        $this->addLooseObjects[$id] =  'odd';
3809
+        $this->addLooseObjects[$id] = 'odd';
3810 3810
         break;
3811 3811
       }
3812 3812
     }
@@ -3817,8 +3817,8 @@  discard block
 block discarded – undo
3817 3817
    * return a storable representation of a specific object
3818 3818
    */
3819 3819
   function  serializeObject($id) {
3820
-    if  ( array_key_exists($id,  $this->objects))
3821
-      return  var_export($this->objects[$id],  true);
3820
+    if (array_key_exists($id, $this->objects))
3821
+      return  var_export($this->objects[$id], true);
3822 3822
   }
3823 3823
 
3824 3824
 
@@ -3826,8 +3826,8 @@  discard block
 block discarded – undo
3826 3826
    * restore an object from its stored representation.  returns its new object id.
3827 3827
    */
3828 3828
   function  restoreSerializedObject($obj) {
3829
-    $obj_id =  $this->openObject();
3830
-    eval('$this->objects[$obj_id] = ' . $obj . ';');
3829
+    $obj_id = $this->openObject();
3830
+    eval('$this->objects[$obj_id] = '.$obj.';');
3831 3831
     $this->closeObject();
3832 3832
     return  $obj_id;
3833 3833
   }
@@ -3836,12 +3836,12 @@  discard block
 block discarded – undo
3836 3836
   /**
3837 3837
    * add content to the documents info object
3838 3838
    */
3839
-  function  addInfo($label, $value =  0) {
3839
+  function  addInfo($label, $value = 0) {
3840 3840
     // this will only work if the label is one of the valid ones.
3841 3841
     // modify this so that arrays can be passed as well.
3842 3842
     // if $label is an array then assume that it is key => value pairs
3843 3843
     // else assume that they are both scalar, anything else will probably error
3844
-    if  (is_array($label)) {
3844
+    if (is_array($label)) {
3845 3845
       foreach ($label as  $l => $v) {
3846 3846
         $this->o_info($this->infoObject, $l, $v);
3847 3847
       }
@@ -3854,9 +3854,9 @@  discard block
 block discarded – undo
3854 3854
   /**
3855 3855
    * set the viewer preferences of the document, it is up to the browser to obey these.
3856 3856
    */
3857
-  function  setPreferences($label, $value =  0) {
3857
+  function  setPreferences($label, $value = 0) {
3858 3858
     // this will only work if the label is one of the valid ones.
3859
-    if  (is_array($label)) {
3859
+    if (is_array($label)) {
3860 3860
       foreach ($label as  $l => $v) {
3861 3861
         $this->o_catalog($this->catalogId, 'viewerPreferences', array($l => $v));
3862 3862
       }
@@ -3873,10 +3873,10 @@  discard block
 block discarded – undo
3873 3873
    */
3874 3874
   function  PRVT_getBytes(&$data, $pos, $num) {
3875 3875
     // return the integer represented by $num bytes from $pos within $data
3876
-    $ret =  0;
3877
-    for  ($i =  0;$i<$num;$i++) {
3878
-      $ret =  $ret*256;
3879
-      $ret+=  ord($data[$pos+$i]);
3876
+    $ret = 0;
3877
+    for ($i = 0; $i < $num; $i++) {
3878
+      $ret = $ret * 256;
3879
+      $ret += ord($data[$pos + $i]);
3880 3880
     }
3881 3881
 
3882 3882
     return  $ret;
@@ -3887,9 +3887,9 @@  discard block
 block discarded – undo
3887 3887
    * add a PNG image into the document, from a GD object
3888 3888
    * this should work with remote files
3889 3889
    */
3890
-  function addImagePng($file, $x, $y, $w =  0, $h =  0, &$img) {
3890
+  function addImagePng($file, $x, $y, $w = 0, $h = 0, &$img) {
3891 3891
     //if already cached, need not to read again
3892
-	if ( isset($this->imagelist[$file]) ) {
3892
+	if (isset($this->imagelist[$file])) {
3893 3893
 	  $data = null;
3894 3894
 	} else {
3895 3895
   	  // Example for transparency handling on new image. Retain for current image
@@ -3905,7 +3905,7 @@  discard block
 block discarded – undo
3905 3905
 	  //default, but explicitely set to ensure pdf compatibility
3906 3906
       imagesavealpha($img, false);
3907 3907
       
3908
-      $error =  0;
3908
+      $error = 0;
3909 3909
       //DEBUG_IMG_TEMP
3910 3910
       //debugpng
3911 3911
       if (DEBUGPNG) print '[addImagePng '.$file.']';
@@ -3923,7 +3923,7 @@  discard block
 block discarded – undo
3923 3923
         if (DEBUGPNG) print 'trouble writing file from GD';
3924 3924
 	  }
3925 3925
 
3926
-      if  ($error) {
3926
+      if ($error) {
3927 3927
         $this->addMessage('PNG error - ('.$file.') '.$errormsg);
3928 3928
         return;
3929 3929
       }
@@ -3937,9 +3937,9 @@  discard block
 block discarded – undo
3937 3937
    * add a PNG image into the document, from a file
3938 3938
    * this should work with remote files
3939 3939
    */
3940
-  function  addPngFromFile($file, $x, $y, $w =  0, $h =  0) {
3940
+  function  addPngFromFile($file, $x, $y, $w = 0, $h = 0) {
3941 3941
     //if already cached, need not to read again
3942
-	if ( isset($this->imagelist[$file]) ) {
3942
+	if (isset($this->imagelist[$file])) {
3943 3943
 	  $img = null;
3944 3944
 	} else {
3945 3945
       //png files typically contain an alpha channel.
@@ -3958,18 +3958,18 @@  discard block
 block discarded – undo
3958 3958
       }
3959 3959
       $sx = imagesx($imgtmp);
3960 3960
       $sy = imagesy($imgtmp);
3961
-      $img = imagecreatetruecolor($sx,$sy);
3961
+      $img = imagecreatetruecolor($sx, $sy);
3962 3962
       imagealphablending($img, true);
3963 3963
   	  $ti = imagecolortransparent($imgtmp);
3964 3964
 	  if ($ti >= 0) {
3965
-	    $tc = imagecolorsforindex($imgtmp,$ti);
3966
-        $ti = imagecolorallocate($img,$tc['red'],$tc['green'],$tc['blue']);
3967
-        imagefill($img,0,0,$ti);
3965
+	    $tc = imagecolorsforindex($imgtmp, $ti);
3966
+        $ti = imagecolorallocate($img, $tc['red'], $tc['green'], $tc['blue']);
3967
+        imagefill($img, 0, 0, $ti);
3968 3968
         imagecolortransparent($img, $ti);
3969 3969
       } else {
3970
-        imagefill($img,1,1,imagecolorallocate($img,255,255,255));
3970
+        imagefill($img, 1, 1, imagecolorallocate($img, 255, 255, 255));
3971 3971
       }
3972
-      imagecopy($img,$imgtmp,0,0,0,0,$sx,$sy);
3972
+      imagecopy($img, $imgtmp, 0, 0, 0, 0, $sx, $sy);
3973 3973
       imagedestroy($imgtmp);
3974 3974
     }
3975 3975
     $this->addImagePng($file, $x, $y, $w, $h, $img);
@@ -3979,8 +3979,8 @@  discard block
 block discarded – undo
3979 3979
   /**
3980 3980
    * add a PNG image into the document, from a memory buffer of the file
3981 3981
    */
3982
-  function  addPngFromBuf($file, $x, $y, $w =  0, $h =  0, &$data) {
3983
-	if ( isset($this->imagelist[$file]) ) {
3982
+  function  addPngFromBuf($file, $x, $y, $w = 0, $h = 0, &$data) {
3983
+	if (isset($this->imagelist[$file])) {
3984 3984
       //debugpng
3985 3985
       //if (DEBUGPNG) print '[addPngFromBuf Duplicate '.$file.']';
3986 3986
 	  $data = null;
@@ -3995,81 +3995,81 @@  discard block
 block discarded – undo
3995 3995
       }
3996 3996
       //debugpng
3997 3997
       //if (DEBUGPNG) print '[addPngFromBuf file='.$file.']';
3998
-    $error =  0;
3998
+    $error = 0;
3999 3999
 
4000
-    if  (!$error) {
4001
-      $header =  chr(137) .chr(80) .chr(78) .chr(71) .chr(13) .chr(10) .chr(26) .chr(10);
4002
-      if  (mb_substr($data, 0, 8, '8bit') !=  $header) {
4003
-        $error =  1;
4000
+    if (!$error) {
4001
+      $header = chr(137).chr(80).chr(78).chr(71).chr(13).chr(10).chr(26).chr(10);
4002
+      if (mb_substr($data, 0, 8, '8bit') != $header) {
4003
+        $error = 1;
4004 4004
         //debugpng
4005 4005
         if (DEBUGPNG) print '[addPngFromFile this file does not have a valid header '.$file.']';
4006 4006
 
4007
-        $errormsg =  'this file does not have a valid header';
4007
+        $errormsg = 'this file does not have a valid header';
4008 4008
       }
4009 4009
     }
4010 4010
 
4011 4011
 
4012
-    if  (!$error) {
4012
+    if (!$error) {
4013 4013
       // set pointer
4014
-      $p =  8;
4015
-      $len =  mb_strlen($data, '8bit');
4014
+      $p = 8;
4015
+      $len = mb_strlen($data, '8bit');
4016 4016
 
4017 4017
       // cycle through the file, identifying chunks
4018
-      $haveHeader =  0;
4019
-      $info =  array();
4020
-      $idata =  '';
4021
-      $pdata =  '';
4022
-
4023
-      while  ($p < $len) {
4024
-        $chunkLen =  $this->PRVT_getBytes($data, $p, 4);
4025
-        $chunkType =  mb_substr($data, $p+4, 4, '8bit');
4018
+      $haveHeader = 0;
4019
+      $info = array();
4020
+      $idata = '';
4021
+      $pdata = '';
4022
+
4023
+      while ($p < $len) {
4024
+        $chunkLen = $this->PRVT_getBytes($data, $p, 4);
4025
+        $chunkType = mb_substr($data, $p + 4, 4, '8bit');
4026 4026
         //      echo $chunkType.' - '.$chunkLen.'<br>';
4027 4027
         switch ($chunkType) {
4028 4028
         case  'IHDR':
4029 4029
           // this is where all the file information comes from
4030
-          $info['width'] =  $this->PRVT_getBytes($data, $p+8, 4);
4031
-          $info['height'] =  $this->PRVT_getBytes($data, $p+12, 4);
4032
-          $info['bitDepth'] =  ord($data[$p+16]);
4033
-          $info['colorType'] =  ord($data[$p+17]);
4034
-          $info['compressionMethod'] =  ord($data[$p+18]);
4035
-          $info['filterMethod'] =  ord($data[$p+19]);
4036
-          $info['interlaceMethod'] =  ord($data[$p+20]);
4030
+          $info['width'] = $this->PRVT_getBytes($data, $p + 8, 4);
4031
+          $info['height'] = $this->PRVT_getBytes($data, $p + 12, 4);
4032
+          $info['bitDepth'] = ord($data[$p + 16]);
4033
+          $info['colorType'] = ord($data[$p + 17]);
4034
+          $info['compressionMethod'] = ord($data[$p + 18]);
4035
+          $info['filterMethod'] = ord($data[$p + 19]);
4036
+          $info['interlaceMethod'] = ord($data[$p + 20]);
4037 4037
 
4038 4038
           //print_r($info);
4039
-          $haveHeader =  1;
4040
-          if  ($info['compressionMethod'] !=  0) {
4041
-            $error =  1;
4039
+          $haveHeader = 1;
4040
+          if ($info['compressionMethod'] != 0) {
4041
+            $error = 1;
4042 4042
 
4043 4043
             //debugpng
4044 4044
             if (DEBUGPNG) print '[addPngFromFile unsupported compression method '.$file.']';
4045 4045
 
4046
-            $errormsg =  'unsupported compression method';
4046
+            $errormsg = 'unsupported compression method';
4047 4047
           }
4048 4048
 
4049
-          if  ($info['filterMethod'] !=  0) {
4050
-            $error =  1;
4049
+          if ($info['filterMethod'] != 0) {
4050
+            $error = 1;
4051 4051
 
4052 4052
             //debugpng
4053 4053
             if (DEBUGPNG) print '[addPngFromFile unsupported filter method '.$file.']';
4054 4054
 
4055
-            $errormsg =  'unsupported filter method';
4055
+            $errormsg = 'unsupported filter method';
4056 4056
           }
4057 4057
           break;
4058 4058
 
4059 4059
         case  'PLTE':
4060
-          $pdata.=  mb_substr($data, $p+8, $chunkLen, '8bit');
4060
+          $pdata .= mb_substr($data, $p + 8, $chunkLen, '8bit');
4061 4061
           break;
4062 4062
 
4063 4063
         case  'IDAT':
4064
-          $idata.=  mb_substr($data, $p+8, $chunkLen, '8bit');
4064
+          $idata .= mb_substr($data, $p + 8, $chunkLen, '8bit');
4065 4065
           break;
4066 4066
 
4067 4067
         case  'tRNS':
4068 4068
           //this chunk can only occur once and it must occur after the PLTE chunk and before IDAT chunk
4069 4069
           //print "tRNS found, color type = ".$info['colorType']."\n";
4070
-          $transparency =  array();
4070
+          $transparency = array();
4071 4071
 
4072
-          if  ($info['colorType'] ==  3) {
4072
+          if ($info['colorType'] == 3) {
4073 4073
             // indexed color, rbg
4074 4074
             /* corresponding to entries in the plte chunk
4075 4075
              Alpha for palette index 0: 1 byte
@@ -4078,38 +4078,38 @@  discard block
 block discarded – undo
4078 4078
             */
4079 4079
             // there will be one entry for each palette entry. up until the last non-opaque entry.
4080 4080
             // set up an array, stretching over all palette entries which will be o (opaque) or 1 (transparent)
4081
-            $transparency['type'] =  'indexed';
4082
-            $numPalette =  mb_strlen($pdata, '8bit')/3;
4083
-            $trans =  0;
4081
+            $transparency['type'] = 'indexed';
4082
+            $numPalette = mb_strlen($pdata, '8bit') / 3;
4083
+            $trans = 0;
4084 4084
 
4085
-            for  ($i =  $chunkLen;$i >=  0;$i--) {
4086
-              if  (ord($data[$p+8+$i]) ==  0) {
4087
-                $trans =  $i;
4085
+            for ($i = $chunkLen; $i >= 0; $i--) {
4086
+              if (ord($data[$p + 8 + $i]) == 0) {
4087
+                $trans = $i;
4088 4088
               }
4089 4089
             }
4090 4090
 
4091
-            $transparency['data'] =  $trans;
4092
-          } elseif ($info['colorType'] ==  0) {
4091
+            $transparency['data'] = $trans;
4092
+          } elseif ($info['colorType'] == 0) {
4093 4093
             // grayscale
4094 4094
             /* corresponding to entries in the plte chunk
4095 4095
              Gray: 2 bytes, range 0 .. (2^bitdepth)-1
4096 4096
             */
4097 4097
             //            $transparency['grayscale'] = $this->PRVT_getBytes($data,$p+8,2); // g = grayscale
4098
-            $transparency['type'] =  'indexed';
4098
+            $transparency['type'] = 'indexed';
4099 4099
 
4100
-            $transparency['data'] =  ord($data[$p+8+1]);
4101
-          } elseif ($info['colorType'] ==  2) {
4100
+            $transparency['data'] = ord($data[$p + 8 + 1]);
4101
+          } elseif ($info['colorType'] == 2) {
4102 4102
             // truecolor
4103 4103
             /* corresponding to entries in the plte chunk
4104 4104
              Red: 2 bytes, range 0 .. (2^bitdepth)-1
4105 4105
              Green: 2 bytes, range 0 .. (2^bitdepth)-1
4106 4106
              Blue: 2 bytes, range 0 .. (2^bitdepth)-1
4107 4107
             */
4108
-            $transparency['r'] =  $this->PRVT_getBytes($data, $p+8, 2);
4108
+            $transparency['r'] = $this->PRVT_getBytes($data, $p + 8, 2);
4109 4109
             // r from truecolor
4110
-            $transparency['g'] =  $this->PRVT_getBytes($data, $p+10, 2);
4110
+            $transparency['g'] = $this->PRVT_getBytes($data, $p + 10, 2);
4111 4111
             // g from truecolor
4112
-            $transparency['b'] =  $this->PRVT_getBytes($data, $p+12, 2);
4112
+            $transparency['b'] = $this->PRVT_getBytes($data, $p + 12, 2);
4113 4113
             // b from truecolor
4114 4114
 
4115 4115
             $transparency['type'] = 'color-key';
@@ -4126,67 +4126,67 @@  discard block
 block discarded – undo
4126 4126
           break;
4127 4127
         }
4128 4128
 
4129
-        $p+=  $chunkLen+12;
4129
+        $p += $chunkLen + 12;
4130 4130
       }
4131 4131
 
4132 4132
 
4133 4133
       if (!$haveHeader) {
4134
-        $error =  1;
4134
+        $error = 1;
4135 4135
 
4136 4136
         //debugpng
4137 4137
         if (DEBUGPNG) print '[addPngFromFile information header is missing '.$file.']';
4138 4138
 
4139
-        $errormsg =  'information header is missing';
4139
+        $errormsg = 'information header is missing';
4140 4140
       }
4141 4141
 
4142
-      if  (isset($info['interlaceMethod']) &&  $info['interlaceMethod']) {
4143
-        $error =  1;
4142
+      if (isset($info['interlaceMethod']) && $info['interlaceMethod']) {
4143
+        $error = 1;
4144 4144
 
4145 4145
         //debugpng
4146 4146
         if (DEBUGPNG) print '[addPngFromFile no support for interlaced images in pdf '.$file.']';
4147 4147
 
4148
-        $errormsg =  'There appears to be no support for interlaced images in pdf.';
4148
+        $errormsg = 'There appears to be no support for interlaced images in pdf.';
4149 4149
       }
4150 4150
     }
4151 4151
 
4152
-    if  (!$error &&  $info['bitDepth'] > 8) {
4153
-      $error =  1;
4152
+    if (!$error && $info['bitDepth'] > 8) {
4153
+      $error = 1;
4154 4154
 
4155 4155
       //debugpng
4156 4156
       if (DEBUGPNG) print '[addPngFromFile bit depth of 8 or less is supported '.$file.']';
4157 4157
 
4158
-      $errormsg =  'only bit depth of 8 or less is supported';
4158
+      $errormsg = 'only bit depth of 8 or less is supported';
4159 4159
     }
4160 4160
 
4161
-    if  (!$error) {
4162
-      if  ($info['colorType'] !=  2 &&  $info['colorType'] !=  0 &&  $info['colorType'] !=  3) {
4163
-        $error =  1;
4161
+    if (!$error) {
4162
+      if ($info['colorType'] != 2 && $info['colorType'] != 0 && $info['colorType'] != 3) {
4163
+        $error = 1;
4164 4164
 
4165 4165
         //debugpng
4166 4166
         if (DEBUGPNG) print '[addPngFromFile alpha channel not supported: '.$info['colorType'].' '.$file.']';
4167 4167
 
4168
-        $errormsg =  'transparancey alpha channel not supported, transparency only supported for palette images.';
4168
+        $errormsg = 'transparancey alpha channel not supported, transparency only supported for palette images.';
4169 4169
       } else {
4170
-        switch  ($info['colorType']) {
4170
+        switch ($info['colorType']) {
4171 4171
         case  3:
4172
-          $color =  'DeviceRGB';
4173
-          $ncolor =  1;
4172
+          $color = 'DeviceRGB';
4173
+          $ncolor = 1;
4174 4174
           break;
4175 4175
 
4176 4176
         case  2:
4177
-          $color =  'DeviceRGB';
4178
-          $ncolor =  3;
4177
+          $color = 'DeviceRGB';
4178
+          $ncolor = 3;
4179 4179
           break;
4180 4180
 
4181 4181
         case  0:
4182
-          $color =  'DeviceGray';
4183
-          $ncolor =  1;
4182
+          $color = 'DeviceGray';
4183
+          $ncolor = 1;
4184 4184
           break;
4185 4185
         }
4186 4186
       }
4187 4187
     }
4188 4188
 
4189
-    if  ($error) {
4189
+    if ($error) {
4190 4190
       $this->addMessage('PNG error - ('.$file.') '.$errormsg);
4191 4191
       return;
4192 4192
     }
@@ -4194,84 +4194,84 @@  discard block
 block discarded – undo
4194 4194
       //print_r($info);
4195 4195
       // so this image is ok... add it in.
4196 4196
       $this->numImages++;
4197
-      $im =  $this->numImages;
4198
-      $label =  'I'.$im;
4197
+      $im = $this->numImages;
4198
+      $label = 'I'.$im;
4199 4199
       $this->numObj++;
4200 4200
 
4201 4201
       //  $this->o_image($this->numObj,'new',array('label' => $label,'data' => $idata,'iw' => $w,'ih' => $h,'type' => 'png','ic' => $info['width']));
4202
-      $options =  array('label' => $label, 'data' => $idata, 'bitsPerComponent' => $info['bitDepth'], 'pdata' => $pdata, 'iw' => $info['width'], 'ih' => $info['height'], 'type' => 'png', 'color' => $color, 'ncolor' => $ncolor);
4202
+      $options = array('label' => $label, 'data' => $idata, 'bitsPerComponent' => $info['bitDepth'], 'pdata' => $pdata, 'iw' => $info['width'], 'ih' => $info['height'], 'type' => 'png', 'color' => $color, 'ncolor' => $ncolor);
4203 4203
 
4204
-      if  (isset($transparency)) {
4205
-        $options['transparency'] =  $transparency;
4204
+      if (isset($transparency)) {
4205
+        $options['transparency'] = $transparency;
4206 4206
       }
4207 4207
 
4208 4208
       $this->o_image($this->numObj, 'new', $options);
4209 4209
       $this->imagelist[$file] = array('label' =>$label, 'w' => $info['width'], 'h' => $info['height']);
4210 4210
     }
4211 4211
 
4212
-    if  ($w <=  0 && $h <=  0) {
4213
-      $w =  $info['width'];
4214
-      $h =  $info['height'];
4212
+    if ($w <= 0 && $h <= 0) {
4213
+      $w = $info['width'];
4214
+      $h = $info['height'];
4215 4215
     }
4216 4216
 
4217
-    if  ($w <=  0) {
4218
-      $w =  $h/$info['height']*$info['width'];
4217
+    if ($w <= 0) {
4218
+      $w = $h / $info['height'] * $info['width'];
4219 4219
     }
4220 4220
 
4221
-    if  ($h <=  0) {
4222
-      $h =  $w*$info['height']/$info['width'];
4221
+    if ($h <= 0) {
4222
+      $h = $w * $info['height'] / $info['width'];
4223 4223
     }
4224 4224
 
4225
-    $this->objects[$this->currentContents]['c'].=  "\nq";
4226
-    $this->objects[$this->currentContents]['c'].=  "\n".sprintf('%.3F', $w) ." 0 0 ".sprintf('%.3F', $h) ." ".sprintf('%.3F', $x) ." ".sprintf('%.3F', $y) ." cm";
4227
-    $this->objects[$this->currentContents]['c'].=  "\n/".$label.' Do';
4228
-    $this->objects[$this->currentContents]['c'].=  "\nQ";
4225
+    $this->objects[$this->currentContents]['c'] .= "\nq";
4226
+    $this->objects[$this->currentContents]['c'] .= "\n".sprintf('%.3F', $w)." 0 0 ".sprintf('%.3F', $h)." ".sprintf('%.3F', $x)." ".sprintf('%.3F', $y)." cm";
4227
+    $this->objects[$this->currentContents]['c'] .= "\n/".$label.' Do';
4228
+    $this->objects[$this->currentContents]['c'] .= "\nQ";
4229 4229
   }
4230 4230
 
4231 4231
 
4232 4232
   /**
4233 4233
    * add a JPEG image into the document, from a file
4234 4234
    */
4235
-  function  addJpegFromFile($img, $x, $y, $w =  0, $h =  0) {
4235
+  function  addJpegFromFile($img, $x, $y, $w = 0, $h = 0) {
4236 4236
     // attempt to add a jpeg image straight from a file, using no GD commands
4237 4237
     // note that this function is unable to operate on a remote file.
4238 4238
 
4239
-    if  (!file_exists($img)) {
4239
+    if (!file_exists($img)) {
4240 4240
       return;
4241 4241
     }
4242 4242
 
4243
-	if ( isset($this->imagelist[$img]) ) {
4243
+	if (isset($this->imagelist[$img])) {
4244 4244
 	  $data = null;
4245 4245
       $imageWidth = $this->imagelist[$img]['w'];
4246 4246
       $imageHeight = $this->imagelist[$img]['h'];
4247
-      $channels =  $this->imagelist[$img]['c'];
4247
+      $channels = $this->imagelist[$img]['c'];
4248 4248
 	} else {
4249
-      $tmp =  getimagesize($img);
4250
-      $imageWidth =  $tmp[0];
4251
-      $imageHeight =  $tmp[1];
4249
+      $tmp = getimagesize($img);
4250
+      $imageWidth = $tmp[0];
4251
+      $imageHeight = $tmp[1];
4252 4252
 
4253
-      if  (isset($tmp['channels'])) {
4254
-        $channels =  $tmp['channels'];
4253
+      if (isset($tmp['channels'])) {
4254
+        $channels = $tmp['channels'];
4255 4255
       } else {
4256
-        $channels =  3;
4256
+        $channels = 3;
4257 4257
       }
4258 4258
 
4259 4259
       //$fp = fopen($img,'rb');
4260
-      $data =  file_get_contents($img);
4260
+      $data = file_get_contents($img);
4261 4261
       //fread($fp,filesize($img));
4262 4262
       //fclose($fp);
4263 4263
     }
4264 4264
 
4265
-    if  ($w <=  0 &&  $h <=  0) {
4266
-      $w =  $imageWidth;
4265
+    if ($w <= 0 && $h <= 0) {
4266
+      $w = $imageWidth;
4267 4267
     }
4268 4268
 
4269
-    if  ($w ==  0) {
4270
-      $w =  $h/$imageHeight*$imageWidth;
4269
+    if ($w == 0) {
4270
+      $w = $h / $imageHeight * $imageWidth;
4271 4271
     }
4272 4272
 
4273
-    if  ($h ==  0) {
4274
-      $h =  $w*$imageHeight/$imageWidth;
4273
+    if ($h == 0) {
4274
+      $h = $w * $imageHeight / $imageWidth;
4275 4275
     }
4276 4276
 
4277 4277
     $this->addJpegImage_common($data, $x, $y, $w, $h, $imageWidth, $imageHeight, $channels, $img);
@@ -4283,7 +4283,7 @@  discard block
 block discarded – undo
4283 4283
    * this function is not all that reliable, and I would probably encourage people to use
4284 4284
    * the file based functions
4285 4285
    */
4286
-  function  addImage(&$img, $x, $y, $w =  0, $h =  0, $quality =  75) {
4286
+  function  addImage(&$img, $x, $y, $w = 0, $h = 0, $quality = 75) {
4287 4287
     /* Todo:
4288 4288
      * Pass in original filename as $imgname
4289 4289
      * If already cached like image_iscached(), allow empty $img
@@ -4302,25 +4302,25 @@  discard block
 block discarded – undo
4302 4302
 
4303 4303
     // there seems to be some problem here in that images that have quality set above 75 do not appear
4304 4304
     // not too sure why this is, but in the meantime I have restricted this to 75.
4305
-    if  ($quality>75) {
4306
-      $quality =  75;
4305
+    if ($quality > 75) {
4306
+      $quality = 75;
4307 4307
     }
4308 4308
 
4309 4309
     // if the width or height are set to zero, then set the other one based on keeping the image
4310 4310
     // height/width ratio the same, if they are both zero, then give up :)
4311
-    $imageWidth =  imagesx($img);
4312
-    $imageHeight =  imagesy($img);
4311
+    $imageWidth = imagesx($img);
4312
+    $imageHeight = imagesy($img);
4313 4313
 
4314
-    if  ($w <=  0 &&  $h <=  0) {
4314
+    if ($w <= 0 && $h <= 0) {
4315 4315
       return;
4316 4316
     }
4317 4317
 
4318
-    if  ($w ==  0) {
4319
-      $w =  $h/$imageHeight*$imageWidth;
4318
+    if ($w == 0) {
4319
+      $w = $h / $imageHeight * $imageWidth;
4320 4320
     }
4321 4321
 
4322
-    if  ($h ==  0) {
4323
-      $h =  $w*$imageHeight/$imageWidth;
4322
+    if ($h == 0) {
4323
+      $h = $w * $imageHeight / $imageWidth;
4324 4324
     }
4325 4325
 
4326 4326
     // gotta get the data out of the img..
@@ -4346,8 +4346,8 @@  discard block
 block discarded – undo
4346 4346
    *
4347 4347
    * @access private
4348 4348
    */
4349
-  function  addJpegImage_common(&$data, $x, $y, $w =  0, $h =  0, $imageWidth, $imageHeight, $channels =  3, $imgname) {
4350
-    if ( isset($this->imagelist[$imgname]) ) {
4349
+  function  addJpegImage_common(&$data, $x, $y, $w = 0, $h = 0, $imageWidth, $imageHeight, $channels = 3, $imgname) {
4350
+    if (isset($this->imagelist[$imgname])) {
4351 4351
       $label = $this->imagelist[$imgname]['label'];
4352 4352
       //debugpng
4353 4353
       //if (DEBUGPNG) print '[addJpegImage_common Duplicate '.$imgname.']';
@@ -4361,24 +4361,24 @@  discard block
 block discarded – undo
4361 4361
       // note that this function is not to be called externally
4362 4362
       // it is just the common code between the GD and the file options
4363 4363
       $this->numImages++;
4364
-      $im =  $this->numImages;
4365
-      $label =  'I'.$im;
4364
+      $im = $this->numImages;
4365
+      $label = 'I'.$im;
4366 4366
       $this->numObj++;
4367 4367
       $this->o_image($this->numObj, 'new', array('label' => $label, 'data' => &$data, 'iw' => $imageWidth, 'ih' => $imageHeight, 'channels' => $channels));
4368
-      $this->imagelist[$imgname] = array('label' =>$label, 'w' => $imageWidth, 'h' => $imageHeight, 'c'=> $channels );
4368
+      $this->imagelist[$imgname] = array('label' =>$label, 'w' => $imageWidth, 'h' => $imageHeight, 'c'=> $channels);
4369 4369
     }
4370 4370
 
4371
-    $this->objects[$this->currentContents]['c'].=  "\nq";
4372
-    $this->objects[$this->currentContents]['c'].=  "\n".sprintf('%.3F', $w) ." 0 0 ".sprintf('%.3F', $h) ." ".sprintf('%.3F', $x) ." ".sprintf('%.3F', $y) ." cm";
4373
-    $this->objects[$this->currentContents]['c'].=  "\n/".$label.' Do';
4374
-    $this->objects[$this->currentContents]['c'].=  "\nQ";
4371
+    $this->objects[$this->currentContents]['c'] .= "\nq";
4372
+    $this->objects[$this->currentContents]['c'] .= "\n".sprintf('%.3F', $w)." 0 0 ".sprintf('%.3F', $h)." ".sprintf('%.3F', $x)." ".sprintf('%.3F', $y)." cm";
4373
+    $this->objects[$this->currentContents]['c'] .= "\n/".$label.' Do';
4374
+    $this->objects[$this->currentContents]['c'] .= "\nQ";
4375 4375
   }
4376 4376
 
4377 4377
 
4378 4378
   /**
4379 4379
    * specify where the document should open when it first starts
4380 4380
    */
4381
-  function  openHere($style, $a =  0, $b =  0, $c =  0) {
4381
+  function  openHere($style, $a = 0, $b = 0, $c = 0) {
4382 4382
     // this function will open the document at a specified page, in a specified style
4383 4383
     // the values for style, and the required paramters are:
4384 4384
     // 'XYZ'  left, top, zoom
@@ -4391,7 +4391,7 @@  discard block
 block discarded – undo
4391 4391
     // 'FitBV' left
4392 4392
     $this->numObj++;
4393 4393
     $this->o_destination($this->numObj, 'new', array('page' => $this->currentPage, 'type' => $style, 'p1' => $a, 'p2' => $b, 'p3' => $c));
4394
-    $id =  $this->catalogId;
4394
+    $id = $this->catalogId;
4395 4395
     $this->o_catalog($id, 'openHere', $this->numObj);
4396 4396
   }
4397 4397
   
@@ -4403,16 +4403,16 @@  discard block
 block discarded – undo
4403 4403
   /**
4404 4404
    * create a labelled destination within the document
4405 4405
    */
4406
-  function  addDestination($label, $style, $a =  0, $b =  0, $c =  0) {
4406
+  function  addDestination($label, $style, $a = 0, $b = 0, $c = 0) {
4407 4407
     // associates the given label with the destination, it is done this way so that a destination can be specified after
4408 4408
     // it has been linked to
4409 4409
     // styles are the same as the 'openHere' function
4410 4410
     $this->numObj++;
4411 4411
     $this->o_destination($this->numObj, 'new', array('page' => $this->currentPage, 'type' => $style, 'p1' => $a, 'p2' => $b, 'p3' => $c));
4412
-    $id =  $this->numObj;
4412
+    $id = $this->numObj;
4413 4413
 
4414 4414
     // store the label->idf relationship, note that this means that labels can be used only once
4415
-    $this->destinations["$label"] =  $id;
4415
+    $this->destinations["$label"] = $id;
4416 4416
   }
4417 4417
 
4418 4418
 
@@ -4421,9 +4421,9 @@  discard block
 block discarded – undo
4421 4421
    * and for the user to add new ones for their fonts. The default bahavious can be overridden should
4422 4422
    * that be desired.
4423 4423
    */
4424
-  function  setFontFamily($family, $options =  '') {
4425
-    if  (!is_array($options)) {
4426
-      if  ($family ===  'init') {
4424
+  function  setFontFamily($family, $options = '') {
4425
+    if (!is_array($options)) {
4426
+      if ($family === 'init') {
4427 4427
         // set the known family groups
4428 4428
         // these font families will be used to enable bold and italic markers to be included
4429 4429
         // within text streams. html forms will be used... <b></b> <i></i>
@@ -4449,8 +4449,8 @@  discard block
 block discarded – undo
4449 4449
 
4450 4450
       // the user is trying to set a font family
4451 4451
       // note that this can also be used to set the base ones to something else
4452
-      if  (mb_strlen($family)) {
4453
-        $this->fontFamilies[$family] =  $options;
4452
+      if (mb_strlen($family)) {
4453
+        $this->fontFamilies[$family] = $options;
4454 4454
       }
4455 4455
     }
4456 4456
   }
@@ -4460,7 +4460,7 @@  discard block
 block discarded – undo
4460 4460
    * used to add messages for use in debugging
4461 4461
    */
4462 4462
   function  addMessage($message) {
4463
-    $this->messages.=  $message."\n";
4463
+    $this->messages .= $message."\n";
4464 4464
   }
4465 4465
 
4466 4466
 
@@ -4468,33 +4468,33 @@  discard block
 block discarded – undo
4468 4468
    * a few functions which should allow the document to be treated transactionally.
4469 4469
    */
4470 4470
   function  transaction($action) {
4471
-    switch  ($action) {
4471
+    switch ($action) {
4472 4472
     case  'start':
4473 4473
       // store all the data away into the checkpoint variable
4474
-      $data =  get_object_vars($this);
4475
-      $this->checkpoint =  $data;
4474
+      $data = get_object_vars($this);
4475
+      $this->checkpoint = $data;
4476 4476
       unset($data);
4477 4477
       break;
4478 4478
 
4479 4479
     case  'commit':
4480
-      if  (is_array($this->checkpoint) &&  isset($this->checkpoint['checkpoint'])) {
4481
-        $tmp =  $this->checkpoint['checkpoint'];
4482
-        $this->checkpoint =  $tmp;
4480
+      if (is_array($this->checkpoint) && isset($this->checkpoint['checkpoint'])) {
4481
+        $tmp = $this->checkpoint['checkpoint'];
4482
+        $this->checkpoint = $tmp;
4483 4483
         unset($tmp);
4484 4484
       } else {
4485
-        $this->checkpoint =  '';
4485
+        $this->checkpoint = '';
4486 4486
       }
4487 4487
       break;
4488 4488
 
4489 4489
     case  'rewind':
4490 4490
       // do not destroy the current checkpoint, but move us back to the state then, so that we can try again
4491
-      if  (is_array($this->checkpoint)) {
4491
+      if (is_array($this->checkpoint)) {
4492 4492
         // can only abort if were inside a checkpoint
4493
-        $tmp =  $this->checkpoint;
4493
+        $tmp = $this->checkpoint;
4494 4494
 
4495 4495
         foreach ($tmp as  $k => $v) {
4496
-          if  ($k !==  'checkpoint') {
4497
-            $this->$k =  $v;
4496
+          if ($k !== 'checkpoint') {
4497
+            $this->$k = $v;
4498 4498
           }
4499 4499
         }
4500 4500
         unset($tmp);
@@ -4502,11 +4502,11 @@  discard block
 block discarded – undo
4502 4502
       break;
4503 4503
 
4504 4504
     case  'abort':
4505
-      if  (is_array($this->checkpoint)) {
4505
+      if (is_array($this->checkpoint)) {
4506 4506
         // can only abort if were inside a checkpoint
4507
-        $tmp =  $this->checkpoint;
4507
+        $tmp = $this->checkpoint;
4508 4508
         foreach ($tmp as  $k => $v) {
4509
-          $this->$k =  $v;
4509
+          $this->$k = $v;
4510 4510
         }
4511 4511
         unset($tmp);
4512 4512
       }
Please login to merge, or discard this patch.