@@ -266,32 +266,32 @@ |
||
| 266 | 266 | |
| 267 | 267 | switch ($type) { |
| 268 | 268 | |
| 269 | - default: |
|
| 270 | - case "decimal": |
|
| 271 | - return $this->_counters[$id]; |
|
| 269 | + default: |
|
| 270 | + case "decimal": |
|
| 271 | + return $this->_counters[$id]; |
|
| 272 | 272 | |
| 273 | - case "decimal-leading-zero": |
|
| 274 | - return str_pad($this->_counters[$id], 2, "0"); |
|
| 273 | + case "decimal-leading-zero": |
|
| 274 | + return str_pad($this->_counters[$id], 2, "0"); |
|
| 275 | 275 | |
| 276 | - case "lower-roman": |
|
| 277 | - return dec2roman($this->_counters[$id]); |
|
| 276 | + case "lower-roman": |
|
| 277 | + return dec2roman($this->_counters[$id]); |
|
| 278 | 278 | |
| 279 | - case "upper-roman": |
|
| 280 | - return mb_strtoupper(dec2roman($this->_counters[$id])); |
|
| 279 | + case "upper-roman": |
|
| 280 | + return mb_strtoupper(dec2roman($this->_counters[$id])); |
|
| 281 | 281 | |
| 282 | - case "lower-latin": |
|
| 283 | - case "lower-alpha": |
|
| 284 | - return chr( ($this->_counters[$id] % 26) + ord('a') - 1); |
|
| 282 | + case "lower-latin": |
|
| 283 | + case "lower-alpha": |
|
| 284 | + return chr( ($this->_counters[$id] % 26) + ord('a') - 1); |
|
| 285 | 285 | |
| 286 | - case "upper-latin": |
|
| 287 | - case "upper-alpha": |
|
| 288 | - return chr( ($this->_counters[$id] % 26) + ord('A') - 1); |
|
| 286 | + case "upper-latin": |
|
| 287 | + case "upper-alpha": |
|
| 288 | + return chr( ($this->_counters[$id] % 26) + ord('A') - 1); |
|
| 289 | 289 | |
| 290 | - case "lower-greek": |
|
| 291 | - return chr($this->_counters[$id] + 944); |
|
| 290 | + case "lower-greek": |
|
| 291 | + return chr($this->_counters[$id] + 944); |
|
| 292 | 292 | |
| 293 | - case "upper-greek": |
|
| 294 | - return chr($this->_counters[$id] + 912); |
|
| 293 | + case "upper-greek": |
|
| 294 | + return chr($this->_counters[$id] + 912); |
|
| 295 | 295 | } |
| 296 | 296 | } |
| 297 | 297 | } |
@@ -592,130 +592,130 @@ discard block |
||
| 592 | 592 | // Handle colour names |
| 593 | 593 | switch ($colour) { |
| 594 | 594 | |
| 595 | - case "maroon": |
|
| 596 | - $r = 0x80; |
|
| 597 | - break; |
|
| 598 | - |
|
| 599 | - case "red": |
|
| 600 | - $r = 0xff; |
|
| 601 | - break; |
|
| 602 | - |
|
| 603 | - case "orange": |
|
| 604 | - $r = 0xff; |
|
| 605 | - $g = 0xa5; |
|
| 606 | - break; |
|
| 607 | - |
|
| 608 | - case "yellow": |
|
| 609 | - $r = 0xff; |
|
| 610 | - $g = 0xff; |
|
| 611 | - break; |
|
| 612 | - |
|
| 613 | - case "olive": |
|
| 614 | - $r = 0x80; |
|
| 615 | - $g = 0x80; |
|
| 616 | - break; |
|
| 617 | - |
|
| 618 | - case "purple": |
|
| 619 | - $r = 0x80; |
|
| 620 | - $b = 0x80; |
|
| 621 | - break; |
|
| 622 | - |
|
| 623 | - case "fuchsia": |
|
| 624 | - $r = 0xff; |
|
| 625 | - $b = 0xff; |
|
| 626 | - break; |
|
| 627 | - |
|
| 628 | - case "white": |
|
| 629 | - $r = $g = $b = 0xff; |
|
| 630 | - break; |
|
| 631 | - |
|
| 632 | - case "lime": |
|
| 633 | - $g = 0xff; |
|
| 634 | - break; |
|
| 635 | - |
|
| 636 | - case "green": |
|
| 637 | - $g = 0x80; |
|
| 638 | - break; |
|
| 639 | - |
|
| 640 | - case "navy": |
|
| 641 | - $b = 0x80; |
|
| 642 | - break; |
|
| 643 | - |
|
| 644 | - case "blue": |
|
| 645 | - $b = 0xff; |
|
| 646 | - break; |
|
| 647 | - |
|
| 648 | - case "aqua": |
|
| 649 | - $g = 0xff; |
|
| 650 | - $b = 0xff; |
|
| 651 | - break; |
|
| 652 | - |
|
| 653 | - case "teal": |
|
| 654 | - $g = 0x80; |
|
| 655 | - $b = 0x80; |
|
| 656 | - break; |
|
| 657 | - |
|
| 658 | - case "black": |
|
| 659 | - break; |
|
| 660 | - |
|
| 661 | - case "sliver": |
|
| 662 | - $r = $g = $b = 0xc0; |
|
| 663 | - break; |
|
| 664 | - |
|
| 665 | - case "gray": |
|
| 666 | - case "grey": |
|
| 667 | - $r = $g = $b = 0x80; |
|
| 668 | - break; |
|
| 669 | - |
|
| 670 | - case "transparent": |
|
| 671 | - return "transparent"; |
|
| 595 | + case "maroon": |
|
| 596 | + $r = 0x80; |
|
| 597 | + break; |
|
| 598 | + |
|
| 599 | + case "red": |
|
| 600 | + $r = 0xff; |
|
| 601 | + break; |
|
| 602 | + |
|
| 603 | + case "orange": |
|
| 604 | + $r = 0xff; |
|
| 605 | + $g = 0xa5; |
|
| 606 | + break; |
|
| 607 | + |
|
| 608 | + case "yellow": |
|
| 609 | + $r = 0xff; |
|
| 610 | + $g = 0xff; |
|
| 611 | + break; |
|
| 612 | + |
|
| 613 | + case "olive": |
|
| 614 | + $r = 0x80; |
|
| 615 | + $g = 0x80; |
|
| 616 | + break; |
|
| 617 | + |
|
| 618 | + case "purple": |
|
| 619 | + $r = 0x80; |
|
| 620 | + $b = 0x80; |
|
| 621 | + break; |
|
| 622 | + |
|
| 623 | + case "fuchsia": |
|
| 624 | + $r = 0xff; |
|
| 625 | + $b = 0xff; |
|
| 626 | + break; |
|
| 627 | + |
|
| 628 | + case "white": |
|
| 629 | + $r = $g = $b = 0xff; |
|
| 630 | + break; |
|
| 631 | + |
|
| 632 | + case "lime": |
|
| 633 | + $g = 0xff; |
|
| 634 | + break; |
|
| 635 | + |
|
| 636 | + case "green": |
|
| 637 | + $g = 0x80; |
|
| 638 | + break; |
|
| 639 | + |
|
| 640 | + case "navy": |
|
| 641 | + $b = 0x80; |
|
| 642 | + break; |
|
| 643 | + |
|
| 644 | + case "blue": |
|
| 645 | + $b = 0xff; |
|
| 646 | + break; |
|
| 647 | + |
|
| 648 | + case "aqua": |
|
| 649 | + $g = 0xff; |
|
| 650 | + $b = 0xff; |
|
| 651 | + break; |
|
| 652 | + |
|
| 653 | + case "teal": |
|
| 654 | + $g = 0x80; |
|
| 655 | + $b = 0x80; |
|
| 656 | + break; |
|
| 657 | + |
|
| 658 | + case "black": |
|
| 659 | + break; |
|
| 660 | + |
|
| 661 | + case "sliver": |
|
| 662 | + $r = $g = $b = 0xc0; |
|
| 663 | + break; |
|
| 664 | + |
|
| 665 | + case "gray": |
|
| 666 | + case "grey": |
|
| 667 | + $r = $g = $b = 0x80; |
|
| 668 | + break; |
|
| 669 | + |
|
| 670 | + case "transparent": |
|
| 671 | + return "transparent"; |
|
| 672 | 672 | |
| 673 | - default: |
|
| 674 | - if ( mb_strlen($colour) == 4 && $colour[0] === "#" ) { |
|
| 675 | - // #rgb format |
|
| 676 | - $r = hexdec($colour[1] . $colour[1]); |
|
| 677 | - $g = hexdec($colour[2] . $colour[2]); |
|
| 678 | - $b = hexdec($colour[3] . $colour[3]); |
|
| 679 | - |
|
| 680 | - } else if ( mb_strlen($colour) == 7 && $colour[0] === "#" ) { |
|
| 681 | - // #rrggbb format |
|
| 682 | - $r = hexdec(mb_substr($colour, 1, 2)); |
|
| 683 | - $g = hexdec(mb_substr($colour, 3, 2)); |
|
| 684 | - $b = hexdec(mb_substr($colour, 5, 2)); |
|
| 685 | - |
|
| 686 | - } else if ( mb_strpos($colour, "rgb") !== false ) { |
|
| 687 | - // rgb( r,g,b ) format |
|
| 688 | - $i = mb_strpos($colour, "("); |
|
| 689 | - $j = mb_strpos($colour, ")"); |
|
| 673 | + default: |
|
| 674 | + if ( mb_strlen($colour) == 4 && $colour[0] === "#" ) { |
|
| 675 | + // #rgb format |
|
| 676 | + $r = hexdec($colour[1] . $colour[1]); |
|
| 677 | + $g = hexdec($colour[2] . $colour[2]); |
|
| 678 | + $b = hexdec($colour[3] . $colour[3]); |
|
| 679 | + |
|
| 680 | + } else if ( mb_strlen($colour) == 7 && $colour[0] === "#" ) { |
|
| 681 | + // #rrggbb format |
|
| 682 | + $r = hexdec(mb_substr($colour, 1, 2)); |
|
| 683 | + $g = hexdec(mb_substr($colour, 3, 2)); |
|
| 684 | + $b = hexdec(mb_substr($colour, 5, 2)); |
|
| 685 | + |
|
| 686 | + } else if ( mb_strpos($colour, "rgb") !== false ) { |
|
| 687 | + // rgb( r,g,b ) format |
|
| 688 | + $i = mb_strpos($colour, "("); |
|
| 689 | + $j = mb_strpos($colour, ")"); |
|
| 690 | 690 | |
| 691 | - // Bad colour value |
|
| 692 | - if ($i === false || $j === false) |
|
| 693 | - return null; |
|
| 691 | + // Bad colour value |
|
| 692 | + if ($i === false || $j === false) |
|
| 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 | - if (count($triplet) != 3) |
|
| 698 | - return null; |
|
| 697 | + if (count($triplet) != 3) |
|
| 698 | + return null; |
|
| 699 | 699 | |
| 700 | - foreach (array_keys($triplet) as $c) { |
|
| 701 | - $triplet[$c] = trim($triplet[$c]); |
|
| 700 | + foreach (array_keys($triplet) as $c) { |
|
| 701 | + $triplet[$c] = trim($triplet[$c]); |
|
| 702 | 702 | |
| 703 | - if ( $triplet[$c]{mb_strlen($triplet[$c]) - 1} === "%" ) |
|
| 704 | - $triplet[$c] = round($triplet[$c] * 0.255); |
|
| 705 | - } |
|
| 703 | + if ( $triplet[$c]{mb_strlen($triplet[$c]) - 1} === "%" ) |
|
| 704 | + $triplet[$c] = round($triplet[$c] * 0.255); |
|
| 705 | + } |
|
| 706 | 706 | |
| 707 | - list($r, $g, $b) = $triplet; |
|
| 707 | + list($r, $g, $b) = $triplet; |
|
| 708 | 708 | |
| 709 | - } else { |
|
| 710 | - // Who knows? |
|
| 711 | - return null; |
|
| 712 | - } |
|
| 709 | + } else { |
|
| 710 | + // Who knows? |
|
| 711 | + return null; |
|
| 712 | + } |
|
| 713 | 713 | |
| 714 | - // Clip to 0 - 1 |
|
| 715 | - $r = $r < 0 ? 0 : ($r > 255 ? 255 : $r); |
|
| 716 | - $g = $g < 0 ? 0 : ($g > 255 ? 255 : $g); |
|
| 717 | - $b = $b < 0 ? 0 : ($b > 255 ? 255 : $b); |
|
| 718 | - break; |
|
| 714 | + // Clip to 0 - 1 |
|
| 715 | + $r = $r < 0 ? 0 : ($r > 255 ? 255 : $r); |
|
| 716 | + $g = $g < 0 ? 0 : ($g > 255 ? 255 : $g); |
|
| 717 | + $b = $b < 0 ? 0 : ($b > 255 ? 255 : $b); |
|
| 718 | + break; |
|
| 719 | 719 | |
| 720 | 720 | } |
| 721 | 721 | |
@@ -941,38 +941,38 @@ discard block |
||
| 941 | 941 | |
| 942 | 942 | switch ($fs) { |
| 943 | 943 | |
| 944 | - case "xx-small": |
|
| 945 | - $fs = 3/5 * $this->_parent_font_size; |
|
| 946 | - break; |
|
| 947 | - |
|
| 948 | - case "x-small": |
|
| 949 | - $fs = 3/4 * $this->_parent_font_size; |
|
| 950 | - break; |
|
| 951 | - |
|
| 952 | - case "smaller": |
|
| 953 | - case "small": |
|
| 954 | - $fs = 8/9 * $this->_parent_font_size; |
|
| 955 | - break; |
|
| 956 | - |
|
| 957 | - case "medium": |
|
| 958 | - $fs = $this->_parent_font_size; |
|
| 959 | - break; |
|
| 960 | - |
|
| 961 | - case "larger": |
|
| 962 | - case "large": |
|
| 963 | - $fs = 6/5 * $this->_parent_font_size; |
|
| 964 | - break; |
|
| 965 | - |
|
| 966 | - case "x-large": |
|
| 967 | - $fs = 3/2 * $this->_parent_font_size; |
|
| 968 | - break; |
|
| 969 | - |
|
| 970 | - case "xx-large": |
|
| 971 | - $fs = 2/1 * $this->_parent_font_size; |
|
| 972 | - break; |
|
| 973 | - |
|
| 974 | - default: |
|
| 975 | - break; |
|
| 944 | + case "xx-small": |
|
| 945 | + $fs = 3/5 * $this->_parent_font_size; |
|
| 946 | + break; |
|
| 947 | + |
|
| 948 | + case "x-small": |
|
| 949 | + $fs = 3/4 * $this->_parent_font_size; |
|
| 950 | + break; |
|
| 951 | + |
|
| 952 | + case "smaller": |
|
| 953 | + case "small": |
|
| 954 | + $fs = 8/9 * $this->_parent_font_size; |
|
| 955 | + break; |
|
| 956 | + |
|
| 957 | + case "medium": |
|
| 958 | + $fs = $this->_parent_font_size; |
|
| 959 | + break; |
|
| 960 | + |
|
| 961 | + case "larger": |
|
| 962 | + case "large": |
|
| 963 | + $fs = 6/5 * $this->_parent_font_size; |
|
| 964 | + break; |
|
| 965 | + |
|
| 966 | + case "x-large": |
|
| 967 | + $fs = 3/2 * $this->_parent_font_size; |
|
| 968 | + break; |
|
| 969 | + |
|
| 970 | + case "xx-large": |
|
| 971 | + $fs = 2/1 * $this->_parent_font_size; |
|
| 972 | + break; |
|
| 973 | + |
|
| 974 | + default: |
|
| 975 | + break; |
|
| 976 | 976 | } |
| 977 | 977 | |
| 978 | 978 | // Ensure relative sizes resolve to something |
@@ -1058,61 +1058,61 @@ discard block |
||
| 1058 | 1058 | |
| 1059 | 1059 | switch ($tmp[0]) { |
| 1060 | 1060 | |
| 1061 | - case "left": |
|
| 1062 | - $x = "0%"; |
|
| 1063 | - break; |
|
| 1061 | + case "left": |
|
| 1062 | + $x = "0%"; |
|
| 1063 | + break; |
|
| 1064 | 1064 | |
| 1065 | - case "right": |
|
| 1066 | - $x = "100%"; |
|
| 1067 | - break; |
|
| 1065 | + case "right": |
|
| 1066 | + $x = "100%"; |
|
| 1067 | + break; |
|
| 1068 | 1068 | |
| 1069 | - case "top": |
|
| 1070 | - $y = "0%"; |
|
| 1071 | - break; |
|
| 1069 | + case "top": |
|
| 1070 | + $y = "0%"; |
|
| 1071 | + break; |
|
| 1072 | 1072 | |
| 1073 | - case "bottom": |
|
| 1074 | - $y = "100%"; |
|
| 1075 | - break; |
|
| 1073 | + case "bottom": |
|
| 1074 | + $y = "100%"; |
|
| 1075 | + break; |
|
| 1076 | 1076 | |
| 1077 | - case "center": |
|
| 1078 | - $x = "50%"; |
|
| 1079 | - $y = "50%"; |
|
| 1080 | - break; |
|
| 1077 | + case "center": |
|
| 1078 | + $x = "50%"; |
|
| 1079 | + $y = "50%"; |
|
| 1080 | + break; |
|
| 1081 | 1081 | |
| 1082 | - default: |
|
| 1083 | - $x = $tmp[0]; |
|
| 1084 | - break; |
|
| 1082 | + default: |
|
| 1083 | + $x = $tmp[0]; |
|
| 1084 | + break; |
|
| 1085 | 1085 | } |
| 1086 | 1086 | |
| 1087 | 1087 | if ( isset($tmp[1]) ) { |
| 1088 | 1088 | |
| 1089 | 1089 | switch ($tmp[1]) { |
| 1090 | - case "left": |
|
| 1091 | - $x = "0%"; |
|
| 1092 | - break; |
|
| 1090 | + case "left": |
|
| 1091 | + $x = "0%"; |
|
| 1092 | + break; |
|
| 1093 | 1093 | |
| 1094 | - case "right": |
|
| 1095 | - $x = "100%"; |
|
| 1096 | - break; |
|
| 1094 | + case "right": |
|
| 1095 | + $x = "100%"; |
|
| 1096 | + break; |
|
| 1097 | 1097 | |
| 1098 | - case "top": |
|
| 1099 | - $y = "0%"; |
|
| 1100 | - break; |
|
| 1098 | + case "top": |
|
| 1099 | + $y = "0%"; |
|
| 1100 | + break; |
|
| 1101 | 1101 | |
| 1102 | - case "bottom": |
|
| 1103 | - $y = "100%"; |
|
| 1104 | - break; |
|
| 1102 | + case "bottom": |
|
| 1103 | + $y = "100%"; |
|
| 1104 | + break; |
|
| 1105 | 1105 | |
| 1106 | - case "center": |
|
| 1107 | - if ( $tmp[0] === "left" || $tmp[0] === "right" || $tmp[0] === "center" ) |
|
| 1108 | - $y = "50%"; |
|
| 1109 | - else |
|
| 1110 | - $x = "50%"; |
|
| 1111 | - break; |
|
| 1106 | + case "center": |
|
| 1107 | + if ( $tmp[0] === "left" || $tmp[0] === "right" || $tmp[0] === "center" ) |
|
| 1108 | + $y = "50%"; |
|
| 1109 | + else |
|
| 1110 | + $x = "50%"; |
|
| 1111 | + break; |
|
| 1112 | 1112 | |
| 1113 | - default: |
|
| 1114 | - $y = $tmp[1]; |
|
| 1115 | - break; |
|
| 1113 | + default: |
|
| 1114 | + $y = $tmp[1]; |
|
| 1115 | + break; |
|
| 1116 | 1116 | } |
| 1117 | 1117 | |
| 1118 | 1118 | } else { |
@@ -1384,20 +1384,20 @@ discard block |
||
| 1384 | 1384 | protected function _set_style_type($style,$type,$val,$important) { |
| 1385 | 1385 | $arr = explode(" ", $val); |
| 1386 | 1386 | switch (count($arr)) { |
| 1387 | - case 1: |
|
| 1388 | - $this->_set_style_sides_type($style,$arr[0],$arr[0],$arr[0],$arr[0],$type,$important); |
|
| 1389 | - break; |
|
| 1390 | - case 2: |
|
| 1391 | - $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[0],$arr[1],$type,$important); |
|
| 1392 | - break; |
|
| 1393 | - case 3: |
|
| 1394 | - $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[1],$arr[2],$type,$important); |
|
| 1395 | - break; |
|
| 1396 | - case 4: |
|
| 1397 | - $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[2],$arr[3],$type,$important); |
|
| 1398 | - break; |
|
| 1399 | - default: |
|
| 1400 | - break; |
|
| 1387 | + case 1: |
|
| 1388 | + $this->_set_style_sides_type($style,$arr[0],$arr[0],$arr[0],$arr[0],$type,$important); |
|
| 1389 | + break; |
|
| 1390 | + case 2: |
|
| 1391 | + $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[0],$arr[1],$type,$important); |
|
| 1392 | + break; |
|
| 1393 | + case 3: |
|
| 1394 | + $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[1],$arr[2],$type,$important); |
|
| 1395 | + break; |
|
| 1396 | + case 4: |
|
| 1397 | + $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[2],$arr[3],$type,$important); |
|
| 1398 | + break; |
|
| 1399 | + default: |
|
| 1400 | + break; |
|
| 1401 | 1401 | } |
| 1402 | 1402 | //see __set and __get, on all assignments clear cache! |
| 1403 | 1403 | $this->_prop_cache[$style.$type] = null; |
@@ -354,30 +354,30 @@ discard block |
||
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | switch ($action) { |
| 357 | - case 'new': |
|
| 358 | - $this->objects[$id] = array('t'=>'destination', 'info'=>array()); |
|
| 359 | - $tmp = ''; |
|
| 360 | - switch ($options['type']) { |
|
| 361 | - case 'XYZ': |
|
| 362 | - case 'FitR': |
|
| 363 | - $tmp = ' '.$options['p3'].$tmp; |
|
| 364 | - case 'FitH': |
|
| 365 | - case 'FitV': |
|
| 366 | - case 'FitBH': |
|
| 367 | - case 'FitBV': |
|
| 368 | - $tmp = ' '.$options['p1'].' '.$options['p2'].$tmp; |
|
| 369 | - case 'Fit': |
|
| 370 | - case 'FitB': |
|
| 371 | - $tmp = $options['type'].$tmp; |
|
| 372 | - $this->objects[$id]['info']['string'] = $tmp; |
|
| 373 | - $this->objects[$id]['info']['page'] = $options['page']; |
|
| 374 | - } |
|
| 357 | + case 'new': |
|
| 358 | + $this->objects[$id] = array('t'=>'destination', 'info'=>array()); |
|
| 359 | + $tmp = ''; |
|
| 360 | + switch ($options['type']) { |
|
| 361 | + case 'XYZ': |
|
| 362 | + case 'FitR': |
|
| 363 | + $tmp = ' '.$options['p3'].$tmp; |
|
| 364 | + case 'FitH': |
|
| 365 | + case 'FitV': |
|
| 366 | + case 'FitBH': |
|
| 367 | + case 'FitBV': |
|
| 368 | + $tmp = ' '.$options['p1'].' '.$options['p2'].$tmp; |
|
| 369 | + case 'Fit': |
|
| 370 | + case 'FitB': |
|
| 371 | + $tmp = $options['type'].$tmp; |
|
| 372 | + $this->objects[$id]['info']['string'] = $tmp; |
|
| 373 | + $this->objects[$id]['info']['page'] = $options['page']; |
|
| 374 | + } |
|
| 375 | 375 | break; |
| 376 | 376 | |
| 377 | - case 'out': |
|
| 378 | - $tmp = $o['info']; |
|
| 379 | - $res = "\n".$id." 0 obj\n".'['.$tmp['page'].' 0 R /'.$tmp['string']."]\nendobj"; |
|
| 380 | - return $res; |
|
| 377 | + case 'out': |
|
| 378 | + $tmp = $o['info']; |
|
| 379 | + $res = "\n".$id." 0 obj\n".'['.$tmp['page'].' 0 R /'.$tmp['string']."]\nendobj"; |
|
| 380 | + return $res; |
|
| 381 | 381 | } |
| 382 | 382 | } |
| 383 | 383 | |
@@ -391,33 +391,33 @@ discard block |
||
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | switch ($action) { |
| 394 | - case 'new': |
|
| 395 | - $this->objects[$id] = array('t'=>'viewerPreferences', 'info'=>array()); |
|
| 396 | - break; |
|
| 397 | - |
|
| 398 | - case 'add': |
|
| 399 | - foreach($options as $k=>$v) { |
|
| 400 | - switch ($k) { |
|
| 401 | - case 'HideToolbar': |
|
| 402 | - case 'HideMenubar': |
|
| 403 | - case 'HideWindowUI': |
|
| 404 | - case 'FitWindow': |
|
| 405 | - case 'CenterWindow': |
|
| 406 | - case 'NonFullScreenPageMode': |
|
| 407 | - case 'Direction': |
|
| 408 | - $o['info'][$k] = $v; |
|
| 394 | + case 'new': |
|
| 395 | + $this->objects[$id] = array('t'=>'viewerPreferences', 'info'=>array()); |
|
| 409 | 396 | break; |
| 410 | - } |
|
| 397 | + |
|
| 398 | + case 'add': |
|
| 399 | + foreach($options as $k=>$v) { |
|
| 400 | + switch ($k) { |
|
| 401 | + case 'HideToolbar': |
|
| 402 | + case 'HideMenubar': |
|
| 403 | + case 'HideWindowUI': |
|
| 404 | + case 'FitWindow': |
|
| 405 | + case 'CenterWindow': |
|
| 406 | + case 'NonFullScreenPageMode': |
|
| 407 | + case 'Direction': |
|
| 408 | + $o['info'][$k] = $v; |
|
| 409 | + break; |
|
| 410 | + } |
|
| 411 | 411 | } |
| 412 | 412 | break; |
| 413 | 413 | |
| 414 | - case 'out': |
|
| 415 | - $res = "\n".$id." 0 obj\n".'<< '; |
|
| 416 | - foreach($o['info'] as $k=>$v) { |
|
| 417 | - $res.= "\n/".$k.' '.$v; |
|
| 418 | - } |
|
| 419 | - $res.= "\n>>\n"; |
|
| 420 | - return $res; |
|
| 414 | + case 'out': |
|
| 415 | + $res = "\n".$id." 0 obj\n".'<< '; |
|
| 416 | + foreach($o['info'] as $k=>$v) { |
|
| 417 | + $res.= "\n/".$k.' '.$v; |
|
| 418 | + } |
|
| 419 | + $res.= "\n>>\n"; |
|
| 420 | + return $res; |
|
| 421 | 421 | } |
| 422 | 422 | } |
| 423 | 423 | |
@@ -431,55 +431,55 @@ discard block |
||
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | switch ($action) { |
| 434 | - case 'new': |
|
| 435 | - $this->objects[$id] = array('t'=>'catalog', 'info'=>array()); |
|
| 436 | - $this->catalogId = $id; |
|
| 437 | - break; |
|
| 434 | + case 'new': |
|
| 435 | + $this->objects[$id] = array('t'=>'catalog', 'info'=>array()); |
|
| 436 | + $this->catalogId = $id; |
|
| 437 | + break; |
|
| 438 | 438 | |
| 439 | - case 'outlines': |
|
| 440 | - case 'pages': |
|
| 441 | - case 'openHere': |
|
| 442 | - case 'javascript': |
|
| 443 | - $o['info'][$action] = $options; |
|
| 444 | - break; |
|
| 439 | + case 'outlines': |
|
| 440 | + case 'pages': |
|
| 441 | + case 'openHere': |
|
| 442 | + case 'javascript': |
|
| 443 | + $o['info'][$action] = $options; |
|
| 444 | + break; |
|
| 445 | 445 | |
| 446 | - case 'viewerPreferences': |
|
| 447 | - if (!isset($o['info']['viewerPreferences'])) { |
|
| 448 | - $this->numObj++; |
|
| 449 | - $this->o_viewerPreferences($this->numObj, 'new'); |
|
| 450 | - $o['info']['viewerPreferences'] = $this->numObj; |
|
| 451 | - } |
|
| 446 | + case 'viewerPreferences': |
|
| 447 | + if (!isset($o['info']['viewerPreferences'])) { |
|
| 448 | + $this->numObj++; |
|
| 449 | + $this->o_viewerPreferences($this->numObj, 'new'); |
|
| 450 | + $o['info']['viewerPreferences'] = $this->numObj; |
|
| 451 | + } |
|
| 452 | 452 | |
| 453 | - $vp = $o['info']['viewerPreferences']; |
|
| 454 | - $this->o_viewerPreferences($vp, 'add', $options); |
|
| 453 | + $vp = $o['info']['viewerPreferences']; |
|
| 454 | + $this->o_viewerPreferences($vp, 'add', $options); |
|
| 455 | 455 | |
| 456 | - break; |
|
| 456 | + break; |
|
| 457 | 457 | |
| 458 | - case 'out': |
|
| 459 | - $res = "\n".$id." 0 obj\n".'<< /Type /Catalog'; |
|
| 458 | + case 'out': |
|
| 459 | + $res = "\n".$id." 0 obj\n".'<< /Type /Catalog'; |
|
| 460 | 460 | |
| 461 | - foreach($o['info'] as $k=>$v) { |
|
| 462 | - switch ($k) { |
|
| 463 | - case 'outlines': |
|
| 464 | - $res.= "\n".'/Outlines '.$v.' 0 R'; |
|
| 465 | - break; |
|
| 461 | + foreach($o['info'] as $k=>$v) { |
|
| 462 | + switch ($k) { |
|
| 463 | + case 'outlines': |
|
| 464 | + $res.= "\n".'/Outlines '.$v.' 0 R'; |
|
| 465 | + break; |
|
| 466 | 466 | |
| 467 | - case 'pages': |
|
| 468 | - $res.= "\n".'/Pages '.$v.' 0 R'; |
|
| 469 | - break; |
|
| 467 | + case 'pages': |
|
| 468 | + $res.= "\n".'/Pages '.$v.' 0 R'; |
|
| 469 | + break; |
|
| 470 | 470 | |
| 471 | - case 'viewerPreferences': |
|
| 472 | - $res.= "\n".'/ViewerPreferences '.$v.' 0 R'; |
|
| 473 | - break; |
|
| 471 | + case 'viewerPreferences': |
|
| 472 | + $res.= "\n".'/ViewerPreferences '.$v.' 0 R'; |
|
| 473 | + break; |
|
| 474 | 474 | |
| 475 | - case 'openHere': |
|
| 476 | - $res.= "\n".'/OpenAction '.$v.' 0 R'; |
|
| 477 | - break; |
|
| 475 | + case 'openHere': |
|
| 476 | + $res.= "\n".'/OpenAction '.$v.' 0 R'; |
|
| 477 | + break; |
|
| 478 | 478 | |
| 479 | - case 'javascript': |
|
| 480 | - $res.= "\n".'/Names <</JavaScript '.$v.' 0 R>>'; |
|
| 481 | - break; |
|
| 482 | - } |
|
| 479 | + case 'javascript': |
|
| 480 | + $res.= "\n".'/Names <</JavaScript '.$v.' 0 R>>'; |
|
| 481 | + break; |
|
| 482 | + } |
|
| 483 | 483 | } |
| 484 | 484 | |
| 485 | 485 | $res.= " >>\nendobj"; |
@@ -497,37 +497,37 @@ discard block |
||
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | switch ($action) { |
| 500 | - case 'new': |
|
| 501 | - $this->objects[$id] = array('t'=>'pages', 'info'=>array()); |
|
| 502 | - $this->o_catalog($this->catalogId, 'pages', $id); |
|
| 503 | - break; |
|
| 500 | + case 'new': |
|
| 501 | + $this->objects[$id] = array('t'=>'pages', 'info'=>array()); |
|
| 502 | + $this->o_catalog($this->catalogId, 'pages', $id); |
|
| 503 | + break; |
|
| 504 | 504 | |
| 505 | - case 'page': |
|
| 506 | - if (!is_array($options)) { |
|
| 507 | - // then it will just be the id of the new page |
|
| 508 | - $o['info']['pages'][] = $options; |
|
| 509 | - } else { |
|
| 510 | - // then it should be an array having 'id','rid','pos', where rid=the page to which this one will be placed relative |
|
| 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']) { |
|
| 515 | - |
|
| 516 | - // then there is a match |
|
| 517 | - // make a space |
|
| 518 | - switch ($options['pos']) { |
|
| 519 | - case 'before': |
|
| 520 | - $k = $i; |
|
| 521 | - break; |
|
| 505 | + case 'page': |
|
| 506 | + if (!is_array($options)) { |
|
| 507 | + // then it will just be the id of the new page |
|
| 508 | + $o['info']['pages'][] = $options; |
|
| 509 | + } else { |
|
| 510 | + // then it should be an array having 'id','rid','pos', where rid=the page to which this one will be placed relative |
|
| 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']) { |
|
| 515 | + |
|
| 516 | + // then there is a match |
|
| 517 | + // make a space |
|
| 518 | + switch ($options['pos']) { |
|
| 519 | + case 'before': |
|
| 520 | + $k = $i; |
|
| 521 | + break; |
|
| 522 | 522 | |
| 523 | - case 'after': |
|
| 524 | - $k = $i+1; |
|
| 525 | - break; |
|
| 523 | + case 'after': |
|
| 524 | + $k = $i+1; |
|
| 525 | + break; |
|
| 526 | 526 | |
| 527 | - default: |
|
| 528 | - $k = -1; |
|
| 529 | - break; |
|
| 530 | - } |
|
| 527 | + default: |
|
| 528 | + $k = -1; |
|
| 529 | + break; |
|
| 530 | + } |
|
| 531 | 531 | |
| 532 | 532 | if ($k >= 0) { |
| 533 | 533 | for ($j = count($o['info']['pages']) -1;$j >= $k;$j--) { |
@@ -541,82 +541,82 @@ discard block |
||
| 541 | 541 | } |
| 542 | 542 | break; |
| 543 | 543 | |
| 544 | - case 'procset': |
|
| 545 | - $o['info']['procset'] = $options; |
|
| 546 | - break; |
|
| 544 | + case 'procset': |
|
| 545 | + $o['info']['procset'] = $options; |
|
| 546 | + break; |
|
| 547 | 547 | |
| 548 | - case 'mediaBox': |
|
| 549 | - $o['info']['mediaBox'] = $options; |
|
| 550 | - // which should be an array of 4 numbers |
|
| 551 | - break; |
|
| 548 | + case 'mediaBox': |
|
| 549 | + $o['info']['mediaBox'] = $options; |
|
| 550 | + // which should be an array of 4 numbers |
|
| 551 | + break; |
|
| 552 | 552 | |
| 553 | - case 'font': |
|
| 554 | - $o['info']['fonts'][] = array('objNum'=>$options['objNum'], 'fontNum'=>$options['fontNum']); |
|
| 555 | - break; |
|
| 553 | + case 'font': |
|
| 554 | + $o['info']['fonts'][] = array('objNum'=>$options['objNum'], 'fontNum'=>$options['fontNum']); |
|
| 555 | + break; |
|
| 556 | 556 | |
| 557 | - case 'extGState': |
|
| 558 | - $o['info']['extGStates'][] = array('objNum' => $options['objNum'], 'stateNum' => $options['stateNum']); |
|
| 559 | - break; |
|
| 557 | + case 'extGState': |
|
| 558 | + $o['info']['extGStates'][] = array('objNum' => $options['objNum'], 'stateNum' => $options['stateNum']); |
|
| 559 | + break; |
|
| 560 | 560 | |
| 561 | - case 'xObject': |
|
| 562 | - $o['info']['xObjects'][] = array('objNum'=>$options['objNum'], 'label'=>$options['label']); |
|
| 563 | - break; |
|
| 561 | + case 'xObject': |
|
| 562 | + $o['info']['xObjects'][] = array('objNum'=>$options['objNum'], 'label'=>$options['label']); |
|
| 563 | + break; |
|
| 564 | 564 | |
| 565 | - case 'out': |
|
| 566 | - if (count($o['info']['pages'])) { |
|
| 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"; |
|
| 570 | - } |
|
| 565 | + case 'out': |
|
| 566 | + if (count($o['info']['pages'])) { |
|
| 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"; |
|
| 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'])) || |
|
| 575 | - isset($o['info']['procset']) || |
|
| 576 | - (isset($o['info']['extGStates']) && count($o['info']['extGStates']))) { |
|
| 577 | - $res.= "\n/Resources <<"; |
|
| 574 | + if ( (isset($o['info']['fonts']) && count($o['info']['fonts'])) || |
|
| 575 | + isset($o['info']['procset']) || |
|
| 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"; |
|
| 581 | - } |
|
| 579 | + if (isset($o['info']['procset'])) { |
|
| 580 | + $res.= "\n/ProcSet ".$o['info']['procset']." 0 R"; |
|
| 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"; |
|
| 587 | - } |
|
| 588 | - $res.= "\n>>"; |
|
| 589 | - } |
|
| 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 | + } |
|
| 588 | + $res.= "\n>>"; |
|
| 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"; |
|
| 595 | - } |
|
| 596 | - $res.= "\n>>"; |
|
| 597 | - } |
|
| 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 | + } |
|
| 596 | + $res.= "\n>>"; |
|
| 597 | + } |
|
| 598 | 598 | |
| 599 | - if ( isset($o['info']['extGStates']) && count($o['info']['extGStates'])) { |
|
| 600 | - $res.= "\n/ExtGState << "; |
|
| 601 | - foreach ($o['info']['extGStates'] as $gstate) { |
|
| 602 | - $res.= "\n/GS" . $gstate['stateNum'] . " " . $gstate['objNum'] . " 0 R"; |
|
| 599 | + if ( isset($o['info']['extGStates']) && count($o['info']['extGStates'])) { |
|
| 600 | + $res.= "\n/ExtGState << "; |
|
| 601 | + foreach ($o['info']['extGStates'] as $gstate) { |
|
| 602 | + $res.= "\n/GS" . $gstate['stateNum'] . " " . $gstate['objNum'] . " 0 R"; |
|
| 603 | + } |
|
| 604 | + $res.= "\n>>"; |
|
| 605 | + } |
|
| 606 | + |
|
| 607 | + $res.= "\n>>"; |
|
| 608 | + if (isset($o['info']['mediaBox'])) { |
|
| 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]) .']'; |
|
| 611 | + } |
|
| 603 | 612 | } |
| 604 | - $res.= "\n>>"; |
|
| 605 | - } |
|
| 606 | 613 | |
| 607 | - $res.= "\n>>"; |
|
| 608 | - if (isset($o['info']['mediaBox'])) { |
|
| 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]) .']'; |
|
| 614 | + $res.= "\n >>\nendobj"; |
|
| 615 | + } else { |
|
| 616 | + $res = "\n".$id." 0 obj\n<< /Type /Pages\n/Count 0\n>>\nendobj"; |
|
| 611 | 617 | } |
| 612 | - } |
|
| 613 | 618 | |
| 614 | - $res.= "\n >>\nendobj"; |
|
| 615 | - } else { |
|
| 616 | - $res = "\n".$id." 0 obj\n<< /Type /Pages\n/Count 0\n>>\nendobj"; |
|
| 617 | - } |
|
| 618 | - |
|
| 619 | - return $res; |
|
| 619 | + return $res; |
|
| 620 | 620 | } |
| 621 | 621 | } |
| 622 | 622 | |
@@ -630,28 +630,28 @@ discard block |
||
| 630 | 630 | } |
| 631 | 631 | |
| 632 | 632 | switch ($action) { |
| 633 | - case 'new': |
|
| 634 | - $this->objects[$id] = array('t'=>'outlines', 'info'=>array('outlines'=>array())); |
|
| 635 | - $this->o_catalog($this->catalogId, 'outlines', $id); |
|
| 636 | - break; |
|
| 633 | + case 'new': |
|
| 634 | + $this->objects[$id] = array('t'=>'outlines', 'info'=>array('outlines'=>array())); |
|
| 635 | + $this->o_catalog($this->catalogId, 'outlines', $id); |
|
| 636 | + break; |
|
| 637 | 637 | |
| 638 | - case 'outline': |
|
| 639 | - $o['info']['outlines'][] = $options; |
|
| 640 | - break; |
|
| 638 | + case 'outline': |
|
| 639 | + $o['info']['outlines'][] = $options; |
|
| 640 | + break; |
|
| 641 | 641 | |
| 642 | - case 'out': |
|
| 643 | - if (count($o['info']['outlines'])) { |
|
| 644 | - $res = "\n".$id." 0 obj\n<< /Type /Outlines /Kids ["; |
|
| 645 | - foreach($o['info']['outlines'] as $k=>$v) { |
|
| 646 | - $res.= $v." 0 R "; |
|
| 647 | - } |
|
| 642 | + case 'out': |
|
| 643 | + if (count($o['info']['outlines'])) { |
|
| 644 | + $res = "\n".$id." 0 obj\n<< /Type /Outlines /Kids ["; |
|
| 645 | + foreach($o['info']['outlines'] as $k=>$v) { |
|
| 646 | + $res.= $v." 0 R "; |
|
| 647 | + } |
|
| 648 | 648 | |
| 649 | - $res.= "] /Count ".count($o['info']['outlines']) ." >>\nendobj"; |
|
| 650 | - } else { |
|
| 651 | - $res = "\n".$id." 0 obj\n<< /Type /Outlines /Count 0 >>\nendobj"; |
|
| 652 | - } |
|
| 649 | + $res.= "] /Count ".count($o['info']['outlines']) ." >>\nendobj"; |
|
| 650 | + } else { |
|
| 651 | + $res = "\n".$id." 0 obj\n<< /Type /Outlines /Count 0 >>\nendobj"; |
|
| 652 | + } |
|
| 653 | 653 | |
| 654 | - return $res; |
|
| 654 | + return $res; |
|
| 655 | 655 | } |
| 656 | 656 | } |
| 657 | 657 | |
@@ -665,33 +665,33 @@ discard block |
||
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | switch ($action) { |
| 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; |
|
| 672 | - |
|
| 673 | - // deal with the encoding and the differences |
|
| 674 | - if (isset($options['differences'])) { |
|
| 675 | - // then we'll need an encoding dictionary |
|
| 676 | - $this->numObj++; |
|
| 677 | - $this->o_fontEncoding($this->numObj, 'new', $options); |
|
| 678 | - $this->objects[$id]['info']['encodingDictionary'] = $this->numObj; |
|
| 679 | - } else if (isset($options['encoding'])) { |
|
| 680 | - // we can specify encoding here |
|
| 681 | - switch ($options['encoding']) { |
|
| 682 | - case 'WinAnsiEncoding': |
|
| 683 | - case 'MacRomanEncoding': |
|
| 684 | - case 'MacExpertEncoding': |
|
| 685 | - $this->objects[$id]['info']['encoding'] = $options['encoding']; |
|
| 686 | - break; |
|
| 687 | - |
|
| 688 | - case 'none': |
|
| 689 | - break; |
|
| 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; |
|
| 690 | 672 | |
| 691 | - default: |
|
| 692 | - $this->objects[$id]['info']['encoding'] = 'WinAnsiEncoding'; |
|
| 693 | - break; |
|
| 694 | - } |
|
| 673 | + // deal with the encoding and the differences |
|
| 674 | + if (isset($options['differences'])) { |
|
| 675 | + // then we'll need an encoding dictionary |
|
| 676 | + $this->numObj++; |
|
| 677 | + $this->o_fontEncoding($this->numObj, 'new', $options); |
|
| 678 | + $this->objects[$id]['info']['encodingDictionary'] = $this->numObj; |
|
| 679 | + } else if (isset($options['encoding'])) { |
|
| 680 | + // we can specify encoding here |
|
| 681 | + switch ($options['encoding']) { |
|
| 682 | + case 'WinAnsiEncoding': |
|
| 683 | + case 'MacRomanEncoding': |
|
| 684 | + case 'MacExpertEncoding': |
|
| 685 | + $this->objects[$id]['info']['encoding'] = $options['encoding']; |
|
| 686 | + break; |
|
| 687 | + |
|
| 688 | + case 'none': |
|
| 689 | + break; |
|
| 690 | + |
|
| 691 | + default: |
|
| 692 | + $this->objects[$id]['info']['encoding'] = 'WinAnsiEncoding'; |
|
| 693 | + break; |
|
| 694 | + } |
|
| 695 | 695 | } else { |
| 696 | 696 | $this->objects[$id]['info']['encoding'] = 'WinAnsiEncoding'; |
| 697 | 697 | } |
@@ -744,21 +744,21 @@ discard block |
||
| 744 | 744 | $this->o_pages($this->currentNode, 'font', array('fontNum' => $fontNum, 'objNum' => $id)); |
| 745 | 745 | break; |
| 746 | 746 | |
| 747 | - case 'add': |
|
| 748 | - foreach ($options as $k => $v) { |
|
| 749 | - switch ($k) { |
|
| 750 | - case 'BaseFont': |
|
| 751 | - $o['info']['name'] = $v; |
|
| 752 | - break; |
|
| 753 | - case 'FirstChar': |
|
| 754 | - case 'LastChar': |
|
| 755 | - case 'Widths': |
|
| 756 | - case 'FontDescriptor': |
|
| 757 | - case 'SubType': |
|
| 758 | - $this->addMessage('o_font '.$k." : ".$v); |
|
| 759 | - $o['info'][$k] = $v; |
|
| 760 | - break; |
|
| 761 | - } |
|
| 747 | + case 'add': |
|
| 748 | + foreach ($options as $k => $v) { |
|
| 749 | + switch ($k) { |
|
| 750 | + case 'BaseFont': |
|
| 751 | + $o['info']['name'] = $v; |
|
| 752 | + break; |
|
| 753 | + case 'FirstChar': |
|
| 754 | + case 'LastChar': |
|
| 755 | + case 'Widths': |
|
| 756 | + case 'FontDescriptor': |
|
| 757 | + case 'SubType': |
|
| 758 | + $this->addMessage('o_font '.$k." : ".$v); |
|
| 759 | + $o['info'][$k] = $v; |
|
| 760 | + break; |
|
| 761 | + } |
|
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | // pass values down to descendent font |
@@ -767,60 +767,60 @@ discard block |
||
| 767 | 767 | } |
| 768 | 768 | break; |
| 769 | 769 | |
| 770 | - case 'out': |
|
| 771 | - if ($this->fonts[$this->objects[$id]['info']['fontFileName']]['isUnicode']) { |
|
| 772 | - // For Unicode fonts, we need to incorporate font data into |
|
| 773 | - // sub-sections that are linked from the primary font section. |
|
| 774 | - // Look at o_fontGIDtoCID and o_fontDescendentCID functions |
|
| 775 | - // for more informaiton. |
|
| 776 | - // |
|
| 777 | - // All of this code is adapted from the excellent changes made to |
|
| 778 | - // transform FPDF to TCPDF (http://tcpdf.sourceforge.net/) |
|
| 779 | - |
|
| 780 | - $res = "\n".$id." 0 obj\n<</Type /Font\n/Subtype /Type0\n"; |
|
| 781 | - $res.= "/BaseFont /".$o['info']['name']."\n"; |
|
| 782 | - |
|
| 783 | - // The horizontal identity mapping for 2-byte CIDs; may be used |
|
| 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"; |
|
| 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"; |
|
| 794 | - |
|
| 795 | - if (isset($o['info']['encodingDictionary'])) { |
|
| 796 | - // then place a reference to the dictionary |
|
| 797 | - $res.= "/Encoding ".$o['info']['encodingDictionary']." 0 R\n"; |
|
| 798 | - } else if (isset($o['info']['encoding'])) { |
|
| 799 | - // use the specified encoding |
|
| 800 | - $res.= "/Encoding /".$o['info']['encoding']."\n"; |
|
| 801 | - } |
|
| 770 | + case 'out': |
|
| 771 | + if ($this->fonts[$this->objects[$id]['info']['fontFileName']]['isUnicode']) { |
|
| 772 | + // For Unicode fonts, we need to incorporate font data into |
|
| 773 | + // sub-sections that are linked from the primary font section. |
|
| 774 | + // Look at o_fontGIDtoCID and o_fontDescendentCID functions |
|
| 775 | + // for more informaiton. |
|
| 776 | + // |
|
| 777 | + // All of this code is adapted from the excellent changes made to |
|
| 778 | + // transform FPDF to TCPDF (http://tcpdf.sourceforge.net/) |
|
| 779 | + |
|
| 780 | + $res = "\n".$id." 0 obj\n<</Type /Font\n/Subtype /Type0\n"; |
|
| 781 | + $res.= "/BaseFont /".$o['info']['name']."\n"; |
|
| 782 | + |
|
| 783 | + // The horizontal identity mapping for 2-byte CIDs; may be used |
|
| 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"; |
|
| 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"; |
|
| 794 | + |
|
| 795 | + if (isset($o['info']['encodingDictionary'])) { |
|
| 796 | + // then place a reference to the dictionary |
|
| 797 | + $res.= "/Encoding ".$o['info']['encodingDictionary']." 0 R\n"; |
|
| 798 | + } else if (isset($o['info']['encoding'])) { |
|
| 799 | + // use the specified encoding |
|
| 800 | + $res.= "/Encoding /".$o['info']['encoding']."\n"; |
|
| 801 | + } |
|
| 802 | 802 | |
| 803 | - if (isset($o['info']['FirstChar'])) { |
|
| 804 | - $res.= "/FirstChar ".$o['info']['FirstChar']."\n"; |
|
| 805 | - } |
|
| 803 | + if (isset($o['info']['FirstChar'])) { |
|
| 804 | + $res.= "/FirstChar ".$o['info']['FirstChar']."\n"; |
|
| 805 | + } |
|
| 806 | 806 | |
| 807 | - if (isset($o['info']['LastChar'])) { |
|
| 808 | - $res.= "/LastChar ".$o['info']['LastChar']."\n"; |
|
| 809 | - } |
|
| 807 | + if (isset($o['info']['LastChar'])) { |
|
| 808 | + $res.= "/LastChar ".$o['info']['LastChar']."\n"; |
|
| 809 | + } |
|
| 810 | 810 | |
| 811 | - if (isset($o['info']['Widths'])) { |
|
| 812 | - $res.= "/Widths ".$o['info']['Widths']." 0 R\n"; |
|
| 813 | - } |
|
| 811 | + if (isset($o['info']['Widths'])) { |
|
| 812 | + $res.= "/Widths ".$o['info']['Widths']." 0 R\n"; |
|
| 813 | + } |
|
| 814 | 814 | |
| 815 | - if (isset($o['info']['FontDescriptor'])) { |
|
| 816 | - $res.= "/FontDescriptor ".$o['info']['FontDescriptor']." 0 R\n"; |
|
| 817 | - } |
|
| 815 | + if (isset($o['info']['FontDescriptor'])) { |
|
| 816 | + $res.= "/FontDescriptor ".$o['info']['FontDescriptor']." 0 R\n"; |
|
| 817 | + } |
|
| 818 | 818 | |
| 819 | - $res.= ">>\n"; |
|
| 820 | - $res.= "endobj"; |
|
| 821 | - } |
|
| 819 | + $res.= ">>\n"; |
|
| 820 | + $res.= "endobj"; |
|
| 821 | + } |
|
| 822 | 822 | |
| 823 | - return $res; |
|
| 823 | + return $res; |
|
| 824 | 824 | } |
| 825 | 825 | } |
| 826 | 826 | |
@@ -834,46 +834,46 @@ discard block |
||
| 834 | 834 | } |
| 835 | 835 | |
| 836 | 836 | switch ($action) { |
| 837 | - case 'new': |
|
| 838 | - $this->objects[$id] = array('t'=>'fontDescriptor', 'info'=>$options); |
|
| 839 | - break; |
|
| 837 | + case 'new': |
|
| 838 | + $this->objects[$id] = array('t'=>'fontDescriptor', 'info'=>$options); |
|
| 839 | + break; |
|
| 840 | 840 | |
| 841 | - case 'out': |
|
| 842 | - $res = "\n".$id." 0 obj\n<< /Type /FontDescriptor\n"; |
|
| 843 | - foreach ($o['info'] as $label => $value) { |
|
| 844 | - switch ($label) { |
|
| 845 | - case 'Ascent': |
|
| 846 | - case 'CapHeight': |
|
| 847 | - case 'Descent': |
|
| 848 | - case 'Flags': |
|
| 849 | - case 'ItalicAngle': |
|
| 850 | - case 'StemV': |
|
| 851 | - case 'AvgWidth': |
|
| 852 | - case 'Leading': |
|
| 853 | - case 'MaxWidth': |
|
| 854 | - case 'MissingWidth': |
|
| 855 | - case 'StemH': |
|
| 856 | - case 'XHeight': |
|
| 857 | - case 'CharSet': |
|
| 858 | - if (mb_strlen($value, '8bit')) { |
|
| 859 | - $res.= '/'.$label.' '.$value."\n"; |
|
| 860 | - } |
|
| 841 | + case 'out': |
|
| 842 | + $res = "\n".$id." 0 obj\n<< /Type /FontDescriptor\n"; |
|
| 843 | + foreach ($o['info'] as $label => $value) { |
|
| 844 | + switch ($label) { |
|
| 845 | + case 'Ascent': |
|
| 846 | + case 'CapHeight': |
|
| 847 | + case 'Descent': |
|
| 848 | + case 'Flags': |
|
| 849 | + case 'ItalicAngle': |
|
| 850 | + case 'StemV': |
|
| 851 | + case 'AvgWidth': |
|
| 852 | + case 'Leading': |
|
| 853 | + case 'MaxWidth': |
|
| 854 | + case 'MissingWidth': |
|
| 855 | + case 'StemH': |
|
| 856 | + case 'XHeight': |
|
| 857 | + case 'CharSet': |
|
| 858 | + if (mb_strlen($value, '8bit')) { |
|
| 859 | + $res.= '/'.$label.' '.$value."\n"; |
|
| 860 | + } |
|
| 861 | 861 | |
| 862 | - break; |
|
| 863 | - case 'FontFile': |
|
| 864 | - case 'FontFile2': |
|
| 865 | - case 'FontFile3': |
|
| 866 | - $res.= '/'.$label.' '.$value." 0 R\n"; |
|
| 867 | - break; |
|
| 862 | + break; |
|
| 863 | + case 'FontFile': |
|
| 864 | + case 'FontFile2': |
|
| 865 | + case 'FontFile3': |
|
| 866 | + $res.= '/'.$label.' '.$value." 0 R\n"; |
|
| 867 | + break; |
|
| 868 | 868 | |
| 869 | - case 'FontBBox': |
|
| 870 | - $res.= '/'.$label.' ['.$value[0].' '.$value[1].' '.$value[2].' '.$value[3]."]\n"; |
|
| 871 | - break; |
|
| 869 | + case 'FontBBox': |
|
| 870 | + $res.= '/'.$label.' ['.$value[0].' '.$value[1].' '.$value[2].' '.$value[3]."]\n"; |
|
| 871 | + break; |
|
| 872 | 872 | |
| 873 | - case 'FontName': |
|
| 874 | - $res.= '/'.$label.' /'.$value."\n"; |
|
| 875 | - break; |
|
| 876 | - } |
|
| 873 | + case 'FontName': |
|
| 874 | + $res.= '/'.$label.' /'.$value."\n"; |
|
| 875 | + break; |
|
| 876 | + } |
|
| 877 | 877 | } |
| 878 | 878 | |
| 879 | 879 | $res.= ">>\nendobj"; |
@@ -892,38 +892,38 @@ discard block |
||
| 892 | 892 | } |
| 893 | 893 | |
| 894 | 894 | switch ($action) { |
| 895 | - case 'new': |
|
| 896 | - // the options array should contain 'differences' and maybe 'encoding' |
|
| 897 | - $this->objects[$id] = array('t'=>'fontEncoding', 'info'=>$options); |
|
| 898 | - break; |
|
| 895 | + case 'new': |
|
| 896 | + // the options array should contain 'differences' and maybe 'encoding' |
|
| 897 | + $this->objects[$id] = array('t'=>'fontEncoding', 'info'=>$options); |
|
| 898 | + break; |
|
| 899 | 899 | |
| 900 | - case 'out': |
|
| 901 | - $res = "\n".$id." 0 obj\n<< /Type /Encoding\n"; |
|
| 902 | - if (!isset($o['info']['encoding'])) { |
|
| 903 | - $o['info']['encoding'] = 'WinAnsiEncoding'; |
|
| 904 | - } |
|
| 900 | + case 'out': |
|
| 901 | + $res = "\n".$id." 0 obj\n<< /Type /Encoding\n"; |
|
| 902 | + if (!isset($o['info']['encoding'])) { |
|
| 903 | + $o['info']['encoding'] = 'WinAnsiEncoding'; |
|
| 904 | + } |
|
| 905 | 905 | |
| 906 | - if ($o['info']['encoding'] !== 'none') { |
|
| 907 | - $res.= "/BaseEncoding /".$o['info']['encoding']."\n"; |
|
| 908 | - } |
|
| 906 | + if ($o['info']['encoding'] !== 'none') { |
|
| 907 | + $res.= "/BaseEncoding /".$o['info']['encoding']."\n"; |
|
| 908 | + } |
|
| 909 | 909 | |
| 910 | - $res.= "/Differences \n["; |
|
| 910 | + $res.= "/Differences \n["; |
|
| 911 | 911 | |
| 912 | - $onum = -100; |
|
| 912 | + $onum = -100; |
|
| 913 | 913 | |
| 914 | - foreach($o['info']['differences'] as $num=>$label) { |
|
| 915 | - if ($num != $onum+1) { |
|
| 916 | - // we cannot make use of consecutive numbering |
|
| 917 | - $res.= "\n".$num." /".$label; |
|
| 918 | - } else { |
|
| 919 | - $res.= " /".$label; |
|
| 920 | - } |
|
| 914 | + foreach($o['info']['differences'] as $num=>$label) { |
|
| 915 | + if ($num != $onum+1) { |
|
| 916 | + // we cannot make use of consecutive numbering |
|
| 917 | + $res.= "\n".$num." /".$label; |
|
| 918 | + } else { |
|
| 919 | + $res.= " /".$label; |
|
| 920 | + } |
|
| 921 | 921 | |
| 922 | - $onum = $num; |
|
| 923 | - } |
|
| 922 | + $onum = $num; |
|
| 923 | + } |
|
| 924 | 924 | |
| 925 | - $res.= "\n]\n>>\nendobj"; |
|
| 926 | - return $res; |
|
| 925 | + $res.= "\n]\n>>\nendobj"; |
|
| 926 | + return $res; |
|
| 927 | 927 | } |
| 928 | 928 | } |
| 929 | 929 | |
@@ -937,82 +937,82 @@ discard block |
||
| 937 | 937 | } |
| 938 | 938 | |
| 939 | 939 | switch ($action) { |
| 940 | - case 'new': |
|
| 941 | - $this->objects[$id] = array('t'=>'fontDescendentCID', 'info'=>$options); |
|
| 942 | - |
|
| 943 | - // we need a CID system info section |
|
| 944 | - $cidSystemInfoId = ++$this->numObj; |
|
| 945 | - $this->o_contents($cidSystemInfoId, 'new', 'raw'); |
|
| 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.= ">>"; |
|
| 951 | - $this->objects[$cidSystemInfoId]['c'] = $res; |
|
| 952 | - |
|
| 953 | - // and a CID to GID map |
|
| 954 | - $cidToGidMapId = ++$this->numObj; |
|
| 955 | - $this->o_fontGIDtoCIDMap($cidToGidMapId, 'new', $options); |
|
| 956 | - $this->objects[$id]['info']['cidToGidMap'] = $cidToGidMapId; |
|
| 957 | - break; |
|
| 958 | - |
|
| 959 | - case 'add': |
|
| 960 | - foreach ($options as $k => $v) { |
|
| 961 | - switch ($k) { |
|
| 962 | - case 'BaseFont': |
|
| 963 | - $o['info']['name'] = $v; |
|
| 940 | + case 'new': |
|
| 941 | + $this->objects[$id] = array('t'=>'fontDescendentCID', 'info'=>$options); |
|
| 942 | + |
|
| 943 | + // we need a CID system info section |
|
| 944 | + $cidSystemInfoId = ++$this->numObj; |
|
| 945 | + $this->o_contents($cidSystemInfoId, 'new', 'raw'); |
|
| 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.= ">>"; |
|
| 951 | + $this->objects[$cidSystemInfoId]['c'] = $res; |
|
| 952 | + |
|
| 953 | + // and a CID to GID map |
|
| 954 | + $cidToGidMapId = ++$this->numObj; |
|
| 955 | + $this->o_fontGIDtoCIDMap($cidToGidMapId, 'new', $options); |
|
| 956 | + $this->objects[$id]['info']['cidToGidMap'] = $cidToGidMapId; |
|
| 964 | 957 | break; |
| 965 | 958 | |
| 966 | - case 'FirstChar': |
|
| 967 | - case 'LastChar': |
|
| 968 | - case 'MissingWidth': |
|
| 969 | - case 'FontDescriptor': |
|
| 970 | - case 'SubType': |
|
| 971 | - $this->addMessage('o_fontDescendentCID '.$k." : ".$v); |
|
| 972 | - $o['info'][$k] = $v; |
|
| 973 | - break; |
|
| 974 | - } |
|
| 959 | + case 'add': |
|
| 960 | + foreach ($options as $k => $v) { |
|
| 961 | + switch ($k) { |
|
| 962 | + case 'BaseFont': |
|
| 963 | + $o['info']['name'] = $v; |
|
| 964 | + break; |
|
| 965 | + |
|
| 966 | + case 'FirstChar': |
|
| 967 | + case 'LastChar': |
|
| 968 | + case 'MissingWidth': |
|
| 969 | + case 'FontDescriptor': |
|
| 970 | + case 'SubType': |
|
| 971 | + $this->addMessage('o_fontDescendentCID '.$k." : ".$v); |
|
| 972 | + $o['info'][$k] = $v; |
|
| 973 | + break; |
|
| 974 | + } |
|
| 975 | 975 | } |
| 976 | 976 | |
| 977 | 977 | // pass values down to cid to gid map |
| 978 | 978 | $this->o_fontGIDtoCIDMap($o['info']['cidToGidMap'], 'add', $options); |
| 979 | 979 | break; |
| 980 | 980 | |
| 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"; |
|
| 987 | -// if (isset($o['info']['FirstChar'])) { |
|
| 988 | -// $res.= "/FirstChar ".$o['info']['FirstChar']."\n"; |
|
| 989 | -// } |
|
| 990 | - |
|
| 991 | -// if (isset($o['info']['LastChar'])) { |
|
| 992 | -// $res.= "/LastChar ".$o['info']['LastChar']."\n"; |
|
| 993 | -// } |
|
| 994 | - if (isset($o['info']['FontDescriptor'])) { |
|
| 995 | - $res.= "/FontDescriptor ".$o['info']['FontDescriptor']." 0 R\n"; |
|
| 996 | - } |
|
| 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"; |
|
| 987 | + // if (isset($o['info']['FirstChar'])) { |
|
| 988 | + // $res.= "/FirstChar ".$o['info']['FirstChar']."\n"; |
|
| 989 | + // } |
|
| 990 | + |
|
| 991 | + // if (isset($o['info']['LastChar'])) { |
|
| 992 | + // $res.= "/LastChar ".$o['info']['LastChar']."\n"; |
|
| 993 | + // } |
|
| 994 | + if (isset($o['info']['FontDescriptor'])) { |
|
| 995 | + $res.= "/FontDescriptor ".$o['info']['FontDescriptor']." 0 R\n"; |
|
| 996 | + } |
|
| 997 | 997 | |
| 998 | - if (isset($o['info']['MissingWidth'])) { |
|
| 999 | - $res.= "/DW ".$o['info']['MissingWidth']."\n"; |
|
| 1000 | - } |
|
| 998 | + if (isset($o['info']['MissingWidth'])) { |
|
| 999 | + $res.= "/DW ".$o['info']['MissingWidth']."\n"; |
|
| 1000 | + } |
|
| 1001 | 1001 | |
| 1002 | - if (isset($o['info']['fontFileName']) && isset($this->fonts[$o['info']['fontFileName']]['CIDWidths'])) { |
|
| 1003 | - $cid_widths = &$this->fonts[$o['info']['fontFileName']]['CIDWidths']; |
|
| 1004 | - $w = ''; |
|
| 1005 | - foreach ($cid_widths as $cid => $width) { |
|
| 1006 | - $w .= $cid.' ['.$width.'] '; |
|
| 1007 | - } |
|
| 1008 | - $res.= "/W [".$w."]\n"; |
|
| 1009 | - } |
|
| 1002 | + if (isset($o['info']['fontFileName']) && isset($this->fonts[$o['info']['fontFileName']]['CIDWidths'])) { |
|
| 1003 | + $cid_widths = &$this->fonts[$o['info']['fontFileName']]['CIDWidths']; |
|
| 1004 | + $w = ''; |
|
| 1005 | + foreach ($cid_widths as $cid => $width) { |
|
| 1006 | + $w .= $cid.' ['.$width.'] '; |
|
| 1007 | + } |
|
| 1008 | + $res.= "/W [".$w."]\n"; |
|
| 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 | - return $res; |
|
| 1015 | + return $res; |
|
| 1016 | 1016 | } |
| 1017 | 1017 | } |
| 1018 | 1018 | |
@@ -1026,35 +1026,35 @@ discard block |
||
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | 1028 | switch ($action) { |
| 1029 | - case 'new': |
|
| 1030 | - $this->objects[$id] = array('t'=>'fontGIDtoCIDMap', 'info'=>$options); |
|
| 1031 | - break; |
|
| 1029 | + case 'new': |
|
| 1030 | + $this->objects[$id] = array('t'=>'fontGIDtoCIDMap', 'info'=>$options); |
|
| 1031 | + break; |
|
| 1032 | 1032 | |
| 1033 | - case 'out': |
|
| 1034 | - $res = "\n".$id." 0 obj\n"; |
|
| 1035 | - $tmp = $this->fonts[$o['info']['fontFileName']]['CIDtoGID'] = base64_decode($this->fonts[$o['info']['fontFileName']]['CIDtoGID']); |
|
| 1036 | - $compressed = isset($this->fonts[$o['info']['fontFileName']]['CIDtoGID_Compressed']) && |
|
| 1037 | - $this->fonts[$o['info']['fontFileName']]['CIDtoGID_Compressed']; |
|
| 1033 | + case 'out': |
|
| 1034 | + $res = "\n".$id." 0 obj\n"; |
|
| 1035 | + $tmp = $this->fonts[$o['info']['fontFileName']]['CIDtoGID'] = base64_decode($this->fonts[$o['info']['fontFileName']]['CIDtoGID']); |
|
| 1036 | + $compressed = isset($this->fonts[$o['info']['fontFileName']]['CIDtoGID_Compressed']) && |
|
| 1037 | + $this->fonts[$o['info']['fontFileName']]['CIDtoGID_Compressed']; |
|
| 1038 | 1038 | |
| 1039 | - if (!$compressed && isset($o['raw'])) { |
|
| 1040 | - $res.= $tmp; |
|
| 1041 | - } else { |
|
| 1042 | - $res.= "<<"; |
|
| 1039 | + if (!$compressed && isset($o['raw'])) { |
|
| 1040 | + $res.= $tmp; |
|
| 1041 | + } else { |
|
| 1042 | + $res.= "<<"; |
|
| 1043 | 1043 | |
| 1044 | - if (!$compressed && function_exists('gzcompress') && $this->options['compression']) { |
|
| 1045 | - // then implement ZLIB based compression on this content stream |
|
| 1046 | - $compressed = true; |
|
| 1047 | - $tmp = gzcompress($tmp, 6); |
|
| 1048 | - } |
|
| 1049 | - if ($compressed) { |
|
| 1050 | - $res.= "\n/Filter /FlateDecode"; |
|
| 1051 | - } |
|
| 1044 | + if (!$compressed && function_exists('gzcompress') && $this->options['compression']) { |
|
| 1045 | + // then implement ZLIB based compression on this content stream |
|
| 1046 | + $compressed = true; |
|
| 1047 | + $tmp = gzcompress($tmp, 6); |
|
| 1048 | + } |
|
| 1049 | + if ($compressed) { |
|
| 1050 | + $res.= "\n/Filter /FlateDecode"; |
|
| 1051 | + } |
|
| 1052 | 1052 | |
| 1053 | - $res.= "\n/Length ".mb_strlen($tmp, '8bit') .">>\nstream\n".$tmp."\nendstream"; |
|
| 1054 | - } |
|
| 1053 | + $res.= "\n/Length ".mb_strlen($tmp, '8bit') .">>\nstream\n".$tmp."\nendstream"; |
|
| 1054 | + } |
|
| 1055 | 1055 | |
| 1056 | - $res.= "\nendobj"; |
|
| 1057 | - return $res; |
|
| 1056 | + $res.= "\nendobj"; |
|
| 1057 | + return $res; |
|
| 1058 | 1058 | } |
| 1059 | 1059 | } |
| 1060 | 1060 | |
@@ -1068,31 +1068,31 @@ discard block |
||
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | 1070 | switch ($action) { |
| 1071 | - case 'new': |
|
| 1072 | - $this->objects[$id] = array('t'=>'procset', 'info'=>array('PDF'=>1, 'Text'=>1)); |
|
| 1073 | - $this->o_pages($this->currentNode, 'procset', $id); |
|
| 1074 | - $this->procsetObjectId = $id; |
|
| 1075 | - break; |
|
| 1071 | + case 'new': |
|
| 1072 | + $this->objects[$id] = array('t'=>'procset', 'info'=>array('PDF'=>1, 'Text'=>1)); |
|
| 1073 | + $this->o_pages($this->currentNode, 'procset', $id); |
|
| 1074 | + $this->procsetObjectId = $id; |
|
| 1075 | + break; |
|
| 1076 | 1076 | |
| 1077 | - case 'add': |
|
| 1078 | - // this is to add new items to the procset list, despite the fact that this is considered |
|
| 1079 | - // obselete, the items are required for printing to some postscript printers |
|
| 1080 | - switch ($options) { |
|
| 1081 | - case 'ImageB': |
|
| 1082 | - case 'ImageC': |
|
| 1083 | - case 'ImageI': |
|
| 1084 | - $o['info'][$options] = 1; |
|
| 1085 | - break; |
|
| 1086 | - } |
|
| 1077 | + case 'add': |
|
| 1078 | + // this is to add new items to the procset list, despite the fact that this is considered |
|
| 1079 | + // obselete, the items are required for printing to some postscript printers |
|
| 1080 | + switch ($options) { |
|
| 1081 | + case 'ImageB': |
|
| 1082 | + case 'ImageC': |
|
| 1083 | + case 'ImageI': |
|
| 1084 | + $o['info'][$options] = 1; |
|
| 1085 | + break; |
|
| 1086 | + } |
|
| 1087 | 1087 | break; |
| 1088 | 1088 | |
| 1089 | - case 'out': |
|
| 1090 | - $res = "\n".$id." 0 obj\n["; |
|
| 1091 | - foreach ($o['info'] as $label=>$val) { |
|
| 1092 | - $res.= '/'.$label.' '; |
|
| 1093 | - } |
|
| 1094 | - $res.= "]\nendobj"; |
|
| 1095 | - return $res; |
|
| 1089 | + case 'out': |
|
| 1090 | + $res = "\n".$id." 0 obj\n["; |
|
| 1091 | + foreach ($o['info'] as $label=>$val) { |
|
| 1092 | + $res.= '/'.$label.' '; |
|
| 1093 | + } |
|
| 1094 | + $res.= "]\nendobj"; |
|
| 1095 | + return $res; |
|
| 1096 | 1096 | } |
| 1097 | 1097 | } |
| 1098 | 1098 | |
@@ -1106,45 +1106,45 @@ discard block |
||
| 1106 | 1106 | } |
| 1107 | 1107 | |
| 1108 | 1108 | switch ($action) { |
| 1109 | - case 'new': |
|
| 1110 | - $this->infoObject = $id; |
|
| 1111 | - $date = 'D:'.@date('Ymd'); |
|
| 1112 | - $this->objects[$id] = array('t'=>'info', 'info'=>array('Creator'=>'R and OS php pdf writer, http://www.ros.co.nz', 'CreationDate'=>$date)); |
|
| 1113 | - break; |
|
| 1114 | - case 'Title': |
|
| 1115 | - case 'Author': |
|
| 1116 | - case 'Subject': |
|
| 1117 | - case 'Keywords': |
|
| 1118 | - case 'Creator': |
|
| 1119 | - case 'Producer': |
|
| 1120 | - case 'CreationDate': |
|
| 1121 | - case 'ModDate': |
|
| 1122 | - case 'Trapped': |
|
| 1123 | - $o['info'][$action] = $options; |
|
| 1124 | - break; |
|
| 1109 | + case 'new': |
|
| 1110 | + $this->infoObject = $id; |
|
| 1111 | + $date = 'D:'.@date('Ymd'); |
|
| 1112 | + $this->objects[$id] = array('t'=>'info', 'info'=>array('Creator'=>'R and OS php pdf writer, http://www.ros.co.nz', 'CreationDate'=>$date)); |
|
| 1113 | + break; |
|
| 1114 | + case 'Title': |
|
| 1115 | + case 'Author': |
|
| 1116 | + case 'Subject': |
|
| 1117 | + case 'Keywords': |
|
| 1118 | + case 'Creator': |
|
| 1119 | + case 'Producer': |
|
| 1120 | + case 'CreationDate': |
|
| 1121 | + case 'ModDate': |
|
| 1122 | + case 'Trapped': |
|
| 1123 | + $o['info'][$action] = $options; |
|
| 1124 | + break; |
|
| 1125 | 1125 | |
| 1126 | - case 'out': |
|
| 1127 | - if ($this->encrypted) { |
|
| 1128 | - $this->encryptInit($id); |
|
| 1129 | - } |
|
| 1126 | + case 'out': |
|
| 1127 | + if ($this->encrypted) { |
|
| 1128 | + $this->encryptInit($id); |
|
| 1129 | + } |
|
| 1130 | 1130 | |
| 1131 | - $res = "\n".$id." 0 obj\n<<\n"; |
|
| 1132 | - foreach ($o['info'] as $k=>$v) { |
|
| 1133 | - $res.= '/'.$k.' ('; |
|
| 1134 | - // dates must be outputted as-is, without Unicode transformations |
|
| 1135 | - $raw = ($k === 'CreationDate' || $k === 'ModDate'); |
|
| 1136 | - $c = $v; |
|
| 1131 | + $res = "\n".$id." 0 obj\n<<\n"; |
|
| 1132 | + foreach ($o['info'] as $k=>$v) { |
|
| 1133 | + $res.= '/'.$k.' ('; |
|
| 1134 | + // dates must be outputted as-is, without Unicode transformations |
|
| 1135 | + $raw = ($k === 'CreationDate' || $k === 'ModDate'); |
|
| 1136 | + $c = $v; |
|
| 1137 | 1137 | |
| 1138 | - if ($this->encrypted) { |
|
| 1139 | - $c = $this->ARC4($c); |
|
| 1140 | - } |
|
| 1138 | + if ($this->encrypted) { |
|
| 1139 | + $c = $this->ARC4($c); |
|
| 1140 | + } |
|
| 1141 | 1141 | |
| 1142 | - $res.= ($raw) ? $c : $this->filterText($c); |
|
| 1143 | - $res.= ")\n"; |
|
| 1144 | - } |
|
| 1142 | + $res.= ($raw) ? $c : $this->filterText($c); |
|
| 1143 | + $res.= ")\n"; |
|
| 1144 | + } |
|
| 1145 | 1145 | |
| 1146 | - $res.= ">>\nendobj"; |
|
| 1147 | - return $res; |
|
| 1146 | + $res.= ">>\nendobj"; |
|
| 1147 | + return $res; |
|
| 1148 | 1148 | } |
| 1149 | 1149 | } |
| 1150 | 1150 | |
@@ -1158,38 +1158,38 @@ discard block |
||
| 1158 | 1158 | } |
| 1159 | 1159 | |
| 1160 | 1160 | switch ($action) { |
| 1161 | - case 'new': |
|
| 1162 | - if (is_array($options)) { |
|
| 1163 | - $this->objects[$id] = array('t'=>'action', 'info'=>$options, 'type'=>$options['type']); |
|
| 1164 | - } else { |
|
| 1165 | - // then assume a URI action |
|
| 1166 | - $this->objects[$id] = array('t'=>'action', 'info'=>$options, 'type'=>'URI'); |
|
| 1167 | - } |
|
| 1168 | - break; |
|
| 1169 | - |
|
| 1170 | - case 'out': |
|
| 1171 | - if ($this->encrypted) { |
|
| 1172 | - $this->encryptInit($id); |
|
| 1173 | - } |
|
| 1161 | + case 'new': |
|
| 1162 | + if (is_array($options)) { |
|
| 1163 | + $this->objects[$id] = array('t'=>'action', 'info'=>$options, 'type'=>$options['type']); |
|
| 1164 | + } else { |
|
| 1165 | + // then assume a URI action |
|
| 1166 | + $this->objects[$id] = array('t'=>'action', 'info'=>$options, 'type'=>'URI'); |
|
| 1167 | + } |
|
| 1168 | + break; |
|
| 1174 | 1169 | |
| 1175 | - $res = "\n".$id." 0 obj\n<< /Type /Action"; |
|
| 1176 | - switch ($o['type']) { |
|
| 1177 | - case 'ilink': |
|
| 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"; |
|
| 1180 | - break; |
|
| 1170 | + case 'out': |
|
| 1171 | + if ($this->encrypted) { |
|
| 1172 | + $this->encryptInit($id); |
|
| 1173 | + } |
|
| 1181 | 1174 | |
| 1182 | - case 'URI': |
|
| 1183 | - $res.= "\n/S /URI\n/URI ("; |
|
| 1184 | - if ($this->encrypted) { |
|
| 1185 | - $res.= $this->filterText($this->ARC4($o['info'])); |
|
| 1186 | - } else { |
|
| 1187 | - $res.= $this->filterText($o['info']); |
|
| 1188 | - } |
|
| 1175 | + $res = "\n".$id." 0 obj\n<< /Type /Action"; |
|
| 1176 | + switch ($o['type']) { |
|
| 1177 | + case 'ilink': |
|
| 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"; |
|
| 1180 | + break; |
|
| 1181 | + |
|
| 1182 | + case 'URI': |
|
| 1183 | + $res.= "\n/S /URI\n/URI ("; |
|
| 1184 | + if ($this->encrypted) { |
|
| 1185 | + $res.= $this->filterText($this->ARC4($o['info'])); |
|
| 1186 | + } else { |
|
| 1187 | + $res.= $this->filterText($o['info']); |
|
| 1188 | + } |
|
| 1189 | 1189 | |
| 1190 | - $res.= ")"; |
|
| 1191 | - break; |
|
| 1192 | - } |
|
| 1190 | + $res.= ")"; |
|
| 1191 | + break; |
|
| 1192 | + } |
|
| 1193 | 1193 | |
| 1194 | 1194 | $res.= "\n>>\nendobj"; |
| 1195 | 1195 | return $res; |
@@ -1207,39 +1207,39 @@ discard block |
||
| 1207 | 1207 | } |
| 1208 | 1208 | |
| 1209 | 1209 | switch ($action) { |
| 1210 | - case 'new': |
|
| 1211 | - // add the annotation to the current page |
|
| 1212 | - $pageId = $this->currentPage; |
|
| 1213 | - $this->o_page($pageId, 'annot', $id); |
|
| 1214 | - |
|
| 1215 | - // and add the action object which is going to be required |
|
| 1216 | - switch ($options['type']) { |
|
| 1217 | - case 'link': |
|
| 1218 | - $this->objects[$id] = array('t'=>'annotation', 'info'=>$options); |
|
| 1219 | - $this->numObj++; |
|
| 1220 | - $this->o_action($this->numObj, 'new', $options['url']); |
|
| 1221 | - $this->objects[$id]['info']['actionId'] = $this->numObj; |
|
| 1222 | - break; |
|
| 1223 | - |
|
| 1224 | - case 'ilink': |
|
| 1225 | - // this is to a named internal link |
|
| 1226 | - $label = $options['label']; |
|
| 1227 | - $this->objects[$id] = array('t'=>'annotation', 'info'=>$options); |
|
| 1228 | - $this->numObj++; |
|
| 1229 | - $this->o_action($this->numObj, 'new', array('type'=>'ilink', 'label'=>$label)); |
|
| 1230 | - $this->objects[$id]['info']['actionId'] = $this->numObj; |
|
| 1231 | - break; |
|
| 1232 | - } |
|
| 1210 | + case 'new': |
|
| 1211 | + // add the annotation to the current page |
|
| 1212 | + $pageId = $this->currentPage; |
|
| 1213 | + $this->o_page($pageId, 'annot', $id); |
|
| 1214 | + |
|
| 1215 | + // and add the action object which is going to be required |
|
| 1216 | + switch ($options['type']) { |
|
| 1217 | + case 'link': |
|
| 1218 | + $this->objects[$id] = array('t'=>'annotation', 'info'=>$options); |
|
| 1219 | + $this->numObj++; |
|
| 1220 | + $this->o_action($this->numObj, 'new', $options['url']); |
|
| 1221 | + $this->objects[$id]['info']['actionId'] = $this->numObj; |
|
| 1222 | + break; |
|
| 1223 | + |
|
| 1224 | + case 'ilink': |
|
| 1225 | + // this is to a named internal link |
|
| 1226 | + $label = $options['label']; |
|
| 1227 | + $this->objects[$id] = array('t'=>'annotation', 'info'=>$options); |
|
| 1228 | + $this->numObj++; |
|
| 1229 | + $this->o_action($this->numObj, 'new', array('type'=>'ilink', 'label'=>$label)); |
|
| 1230 | + $this->objects[$id]['info']['actionId'] = $this->numObj; |
|
| 1231 | + break; |
|
| 1232 | + } |
|
| 1233 | 1233 | break; |
| 1234 | 1234 | |
| 1235 | - case 'out': |
|
| 1236 | - $res = "\n".$id." 0 obj\n<< /Type /Annot"; |
|
| 1237 | - switch ($o['info']['type']) { |
|
| 1238 | - case 'link': |
|
| 1239 | - case 'ilink': |
|
| 1240 | - $res.= "\n/Subtype /Link"; |
|
| 1241 | - break; |
|
| 1242 | - } |
|
| 1235 | + case 'out': |
|
| 1236 | + $res = "\n".$id." 0 obj\n<< /Type /Annot"; |
|
| 1237 | + switch ($o['info']['type']) { |
|
| 1238 | + case 'link': |
|
| 1239 | + case 'ilink': |
|
| 1240 | + $res.= "\n/Subtype /Link"; |
|
| 1241 | + break; |
|
| 1242 | + } |
|
| 1243 | 1243 | $res.= "\n/A ".$o['info']['actionId']." 0 R"; |
| 1244 | 1244 | $res.= "\n/Border [0 0 0]"; |
| 1245 | 1245 | $res.= "\n/H /I"; |
@@ -1265,77 +1265,77 @@ discard block |
||
| 1265 | 1265 | } |
| 1266 | 1266 | |
| 1267 | 1267 | switch ($action) { |
| 1268 | - case 'new': |
|
| 1269 | - $this->numPages++; |
|
| 1270 | - $this->objects[$id] = array('t'=>'page', 'info'=>array('parent'=>$this->currentNode, 'pageNum'=>$this->numPages)); |
|
| 1271 | - |
|
| 1272 | - if (is_array($options)) { |
|
| 1273 | - // then this must be a page insertion, array should contain 'rid','pos'=[before|after] |
|
| 1274 | - $options['id'] = $id; |
|
| 1275 | - $this->o_pages($this->currentNode, 'page', $options); |
|
| 1276 | - } else { |
|
| 1277 | - $this->o_pages($this->currentNode, 'page', $id); |
|
| 1278 | - } |
|
| 1268 | + case 'new': |
|
| 1269 | + $this->numPages++; |
|
| 1270 | + $this->objects[$id] = array('t'=>'page', 'info'=>array('parent'=>$this->currentNode, 'pageNum'=>$this->numPages)); |
|
| 1271 | + |
|
| 1272 | + if (is_array($options)) { |
|
| 1273 | + // then this must be a page insertion, array should contain 'rid','pos'=[before|after] |
|
| 1274 | + $options['id'] = $id; |
|
| 1275 | + $this->o_pages($this->currentNode, 'page', $options); |
|
| 1276 | + } else { |
|
| 1277 | + $this->o_pages($this->currentNode, 'page', $id); |
|
| 1278 | + } |
|
| 1279 | 1279 | |
| 1280 | - $this->currentPage = $id; |
|
| 1281 | - //make a contents object to go with this page |
|
| 1282 | - $this->numObj++; |
|
| 1283 | - $this->o_contents($this->numObj, 'new', $id); |
|
| 1284 | - $this->currentContents = $this->numObj; |
|
| 1285 | - $this->objects[$id]['info']['contents'] = array(); |
|
| 1286 | - $this->objects[$id]['info']['contents'][] = $this->numObj; |
|
| 1287 | - |
|
| 1288 | - $match = ($this->numPages%2 ? 'odd' : 'even'); |
|
| 1289 | - foreach($this->addLooseObjects as $oId=>$target) { |
|
| 1290 | - if ($target === 'all' || $match === $target) { |
|
| 1291 | - $this->objects[$id]['info']['contents'][] = $oId; |
|
| 1292 | - } |
|
| 1293 | - } |
|
| 1294 | - break; |
|
| 1280 | + $this->currentPage = $id; |
|
| 1281 | + //make a contents object to go with this page |
|
| 1282 | + $this->numObj++; |
|
| 1283 | + $this->o_contents($this->numObj, 'new', $id); |
|
| 1284 | + $this->currentContents = $this->numObj; |
|
| 1285 | + $this->objects[$id]['info']['contents'] = array(); |
|
| 1286 | + $this->objects[$id]['info']['contents'][] = $this->numObj; |
|
| 1287 | + |
|
| 1288 | + $match = ($this->numPages%2 ? 'odd' : 'even'); |
|
| 1289 | + foreach($this->addLooseObjects as $oId=>$target) { |
|
| 1290 | + if ($target === 'all' || $match === $target) { |
|
| 1291 | + $this->objects[$id]['info']['contents'][] = $oId; |
|
| 1292 | + } |
|
| 1293 | + } |
|
| 1294 | + break; |
|
| 1295 | 1295 | |
| 1296 | - case 'content': |
|
| 1297 | - $o['info']['contents'][] = $options; |
|
| 1298 | - break; |
|
| 1296 | + case 'content': |
|
| 1297 | + $o['info']['contents'][] = $options; |
|
| 1298 | + break; |
|
| 1299 | 1299 | |
| 1300 | - case 'annot': |
|
| 1301 | - // add an annotation to this page |
|
| 1302 | - if (!isset($o['info']['annot'])) { |
|
| 1303 | - $o['info']['annot'] = array(); |
|
| 1304 | - } |
|
| 1300 | + case 'annot': |
|
| 1301 | + // add an annotation to this page |
|
| 1302 | + if (!isset($o['info']['annot'])) { |
|
| 1303 | + $o['info']['annot'] = array(); |
|
| 1304 | + } |
|
| 1305 | 1305 | |
| 1306 | - // $options should contain the id of the annotation dictionary |
|
| 1307 | - $o['info']['annot'][] = $options; |
|
| 1308 | - break; |
|
| 1306 | + // $options should contain the id of the annotation dictionary |
|
| 1307 | + $o['info']['annot'][] = $options; |
|
| 1308 | + break; |
|
| 1309 | 1309 | |
| 1310 | - case 'out': |
|
| 1311 | - $res = "\n".$id." 0 obj\n<< /Type /Page"; |
|
| 1312 | - $res.= "\n/Parent ".$o['info']['parent']." 0 R"; |
|
| 1310 | + case 'out': |
|
| 1311 | + $res = "\n".$id." 0 obj\n<< /Type /Page"; |
|
| 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"; |
|
| 1318 | - } |
|
| 1319 | - $res.= " ]"; |
|
| 1320 | - } |
|
| 1314 | + if (isset($o['info']['annot'])) { |
|
| 1315 | + $res.= "\n/Annots ["; |
|
| 1316 | + foreach($o['info']['annot'] as $aId) { |
|
| 1317 | + $res.= " ".$aId." 0 R"; |
|
| 1318 | + } |
|
| 1319 | + $res.= " ]"; |
|
| 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"; |
|
| 1327 | - |
|
| 1328 | - // reverse the page contents so added objects are below normal content |
|
| 1329 | - //foreach (array_reverse($o['info']['contents']) as $cId) { |
|
| 1330 | - // Back to normal now that I've got transparency working --Benj |
|
| 1331 | - foreach ($o['info']['contents'] as $cId) { |
|
| 1332 | - $res.= $cId." 0 R\n"; |
|
| 1333 | - } |
|
| 1334 | - $res.= "]"; |
|
| 1335 | - } |
|
| 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 | + |
|
| 1328 | + // reverse the page contents so added objects are below normal content |
|
| 1329 | + //foreach (array_reverse($o['info']['contents']) as $cId) { |
|
| 1330 | + // Back to normal now that I've got transparency working --Benj |
|
| 1331 | + foreach ($o['info']['contents'] as $cId) { |
|
| 1332 | + $res.= $cId." 0 R\n"; |
|
| 1333 | + } |
|
| 1334 | + $res.= "]"; |
|
| 1335 | + } |
|
| 1336 | 1336 | |
| 1337 | - $res.= "\n>>\nendobj"; |
|
| 1338 | - return $res; |
|
| 1337 | + $res.= "\n>>\nendobj"; |
|
| 1338 | + return $res; |
|
| 1339 | 1339 | } |
| 1340 | 1340 | } |
| 1341 | 1341 | |
@@ -1349,51 +1349,51 @@ discard block |
||
| 1349 | 1349 | } |
| 1350 | 1350 | |
| 1351 | 1351 | switch ($action) { |
| 1352 | - case 'new': |
|
| 1353 | - $this->objects[$id] = array('t'=>'contents', 'c'=>'', 'info'=>array()); |
|
| 1354 | - if (mb_strlen($options, '8bit') && intval($options)) { |
|
| 1355 | - // then this contents is the primary for a page |
|
| 1356 | - $this->objects[$id]['onPage'] = $options; |
|
| 1357 | - } else if ($options === 'raw') { |
|
| 1358 | - // then this page contains some other type of system object |
|
| 1359 | - $this->objects[$id]['raw'] = 1; |
|
| 1360 | - } |
|
| 1361 | - break; |
|
| 1352 | + case 'new': |
|
| 1353 | + $this->objects[$id] = array('t'=>'contents', 'c'=>'', 'info'=>array()); |
|
| 1354 | + if (mb_strlen($options, '8bit') && intval($options)) { |
|
| 1355 | + // then this contents is the primary for a page |
|
| 1356 | + $this->objects[$id]['onPage'] = $options; |
|
| 1357 | + } else if ($options === 'raw') { |
|
| 1358 | + // then this page contains some other type of system object |
|
| 1359 | + $this->objects[$id]['raw'] = 1; |
|
| 1360 | + } |
|
| 1361 | + break; |
|
| 1362 | 1362 | |
| 1363 | - case 'add': |
|
| 1364 | - // add more options to the decleration |
|
| 1365 | - foreach ($options as $k=>$v) { |
|
| 1366 | - $o['info'][$k] = $v; |
|
| 1367 | - } |
|
| 1363 | + case 'add': |
|
| 1364 | + // add more options to the decleration |
|
| 1365 | + foreach ($options as $k=>$v) { |
|
| 1366 | + $o['info'][$k] = $v; |
|
| 1367 | + } |
|
| 1368 | 1368 | |
| 1369 | - case 'out': |
|
| 1370 | - $tmp = $o['c']; |
|
| 1371 | - $res = "\n".$id." 0 obj\n"; |
|
| 1369 | + case 'out': |
|
| 1370 | + $tmp = $o['c']; |
|
| 1371 | + $res = "\n".$id." 0 obj\n"; |
|
| 1372 | 1372 | |
| 1373 | - if (isset($this->objects[$id]['raw'])) { |
|
| 1374 | - $res.= $tmp; |
|
| 1375 | - } else { |
|
| 1376 | - $res.= "<<"; |
|
| 1377 | - if (function_exists('gzcompress') && $this->options['compression']) { |
|
| 1378 | - // then implement ZLIB based compression on this content stream |
|
| 1379 | - $res.= " /Filter /FlateDecode"; |
|
| 1380 | - $tmp = gzcompress($tmp, 6); |
|
| 1381 | - } |
|
| 1373 | + if (isset($this->objects[$id]['raw'])) { |
|
| 1374 | + $res.= $tmp; |
|
| 1375 | + } else { |
|
| 1376 | + $res.= "<<"; |
|
| 1377 | + if (function_exists('gzcompress') && $this->options['compression']) { |
|
| 1378 | + // then implement ZLIB based compression on this content stream |
|
| 1379 | + $res.= " /Filter /FlateDecode"; |
|
| 1380 | + $tmp = gzcompress($tmp, 6); |
|
| 1381 | + } |
|
| 1382 | 1382 | |
| 1383 | - if ($this->encrypted) { |
|
| 1384 | - $this->encryptInit($id); |
|
| 1385 | - $tmp = $this->ARC4($tmp); |
|
| 1386 | - } |
|
| 1383 | + if ($this->encrypted) { |
|
| 1384 | + $this->encryptInit($id); |
|
| 1385 | + $tmp = $this->ARC4($tmp); |
|
| 1386 | + } |
|
| 1387 | 1387 | |
| 1388 | - foreach($o['info'] as $k=>$v) { |
|
| 1389 | - $res.= "\n/".$k.' '.$v; |
|
| 1390 | - } |
|
| 1388 | + foreach($o['info'] as $k=>$v) { |
|
| 1389 | + $res.= "\n/".$k.' '.$v; |
|
| 1390 | + } |
|
| 1391 | 1391 | |
| 1392 | - $res.= "\n/Length ".mb_strlen($tmp, '8bit') ." >>\nstream\n".$tmp."\nendstream"; |
|
| 1393 | - } |
|
| 1392 | + $res.= "\n/Length ".mb_strlen($tmp, '8bit') ." >>\nstream\n".$tmp."\nendstream"; |
|
| 1393 | + } |
|
| 1394 | 1394 | |
| 1395 | - $res.= "\nendobj"; |
|
| 1396 | - return $res; |
|
| 1395 | + $res.= "\nendobj"; |
|
| 1396 | + return $res; |
|
| 1397 | 1397 | } |
| 1398 | 1398 | } |
| 1399 | 1399 | |
@@ -1403,19 +1403,19 @@ discard block |
||
| 1403 | 1403 | } |
| 1404 | 1404 | |
| 1405 | 1405 | switch ($action) { |
| 1406 | - case 'new': |
|
| 1407 | - $this->objects[$id] = array('t'=>'embedjs', 'info'=>array( |
|
| 1408 | - 'Names' => '[(EmbeddedJS) '.($id+1).' 0 R]' |
|
| 1409 | - )); |
|
| 1410 | - break; |
|
| 1406 | + case 'new': |
|
| 1407 | + $this->objects[$id] = array('t'=>'embedjs', 'info'=>array( |
|
| 1408 | + 'Names' => '[(EmbeddedJS) '.($id+1).' 0 R]' |
|
| 1409 | + )); |
|
| 1410 | + break; |
|
| 1411 | 1411 | |
| 1412 | - case 'out': |
|
| 1413 | - $res .= "\n".$id." 0 obj\n".'<< '; |
|
| 1414 | - foreach($o['info'] as $k=>$v) { |
|
| 1415 | - $res.= "\n/".$k.' '.$v; |
|
| 1416 | - } |
|
| 1417 | - $res.= "\n>>\nendobj"; |
|
| 1418 | - return $res; |
|
| 1412 | + case 'out': |
|
| 1413 | + $res .= "\n".$id." 0 obj\n".'<< '; |
|
| 1414 | + foreach($o['info'] as $k=>$v) { |
|
| 1415 | + $res.= "\n/".$k.' '.$v; |
|
| 1416 | + } |
|
| 1417 | + $res.= "\n>>\nendobj"; |
|
| 1418 | + return $res; |
|
| 1419 | 1419 | } |
| 1420 | 1420 | } |
| 1421 | 1421 | |
@@ -1425,20 +1425,20 @@ discard block |
||
| 1425 | 1425 | } |
| 1426 | 1426 | |
| 1427 | 1427 | switch ($action) { |
| 1428 | - case 'new': |
|
| 1429 | - $this->objects[$id] = array('t'=>'javascript', 'info'=>array( |
|
| 1430 | - 'S' => '/JavaScript', |
|
| 1431 | - 'JS' => '('.$this->filterText($code).')', |
|
| 1432 | - )); |
|
| 1433 | - break; |
|
| 1428 | + case 'new': |
|
| 1429 | + $this->objects[$id] = array('t'=>'javascript', 'info'=>array( |
|
| 1430 | + 'S' => '/JavaScript', |
|
| 1431 | + 'JS' => '('.$this->filterText($code).')', |
|
| 1432 | + )); |
|
| 1433 | + break; |
|
| 1434 | 1434 | |
| 1435 | - case 'out': |
|
| 1436 | - $res = "\n".$id." 0 obj\n".'<< '; |
|
| 1437 | - foreach($o['info'] as $k=>$v) { |
|
| 1438 | - $res.= "\n/".$k.' '.$v; |
|
| 1439 | - } |
|
| 1440 | - $res.= "\n>>\nendobj"; |
|
| 1441 | - return $res; |
|
| 1435 | + case 'out': |
|
| 1436 | + $res = "\n".$id." 0 obj\n".'<< '; |
|
| 1437 | + foreach($o['info'] as $k=>$v) { |
|
| 1438 | + $res.= "\n/".$k.' '.$v; |
|
| 1439 | + } |
|
| 1440 | + $res.= "\n>>\nendobj"; |
|
| 1441 | + return $res; |
|
| 1442 | 1442 | } |
| 1443 | 1443 | } |
| 1444 | 1444 | |
@@ -1451,28 +1451,28 @@ discard block |
||
| 1451 | 1451 | } |
| 1452 | 1452 | |
| 1453 | 1453 | switch ($action) { |
| 1454 | - case 'new': |
|
| 1455 | - // make the new object |
|
| 1456 | - $this->objects[$id] = array('t'=>'image', 'data'=>&$options['data'], 'info'=>array()); |
|
| 1457 | - $this->objects[$id]['info']['Type'] = '/XObject'; |
|
| 1458 | - $this->objects[$id]['info']['Subtype'] = '/Image'; |
|
| 1459 | - $this->objects[$id]['info']['Width'] = $options['iw']; |
|
| 1460 | - $this->objects[$id]['info']['Height'] = $options['ih']; |
|
| 1461 | - |
|
| 1462 | - if (!isset($options['type']) || $options['type'] === 'jpg') { |
|
| 1463 | - if (!isset($options['channels'])) { |
|
| 1464 | - $options['channels'] = 3; |
|
| 1465 | - } |
|
| 1454 | + case 'new': |
|
| 1455 | + // make the new object |
|
| 1456 | + $this->objects[$id] = array('t'=>'image', 'data'=>&$options['data'], 'info'=>array()); |
|
| 1457 | + $this->objects[$id]['info']['Type'] = '/XObject'; |
|
| 1458 | + $this->objects[$id]['info']['Subtype'] = '/Image'; |
|
| 1459 | + $this->objects[$id]['info']['Width'] = $options['iw']; |
|
| 1460 | + $this->objects[$id]['info']['Height'] = $options['ih']; |
|
| 1461 | + |
|
| 1462 | + if (!isset($options['type']) || $options['type'] === 'jpg') { |
|
| 1463 | + if (!isset($options['channels'])) { |
|
| 1464 | + $options['channels'] = 3; |
|
| 1465 | + } |
|
| 1466 | 1466 | |
| 1467 | - switch ($options['channels']) { |
|
| 1468 | - case 1: |
|
| 1469 | - $this->objects[$id]['info']['ColorSpace'] = '/DeviceGray'; |
|
| 1470 | - break; |
|
| 1467 | + switch ($options['channels']) { |
|
| 1468 | + case 1: |
|
| 1469 | + $this->objects[$id]['info']['ColorSpace'] = '/DeviceGray'; |
|
| 1470 | + break; |
|
| 1471 | 1471 | |
| 1472 | - default: |
|
| 1473 | - $this->objects[$id]['info']['ColorSpace'] = '/DeviceRGB'; |
|
| 1474 | - break; |
|
| 1475 | - } |
|
| 1472 | + default: |
|
| 1473 | + $this->objects[$id]['info']['ColorSpace'] = '/DeviceRGB'; |
|
| 1474 | + break; |
|
| 1475 | + } |
|
| 1476 | 1476 | |
| 1477 | 1477 | $this->objects[$id]['info']['Filter'] = '/DCTDecode'; |
| 1478 | 1478 | $this->objects[$id]['info']['BitsPerComponent'] = 8; |
@@ -1490,39 +1490,39 @@ discard block |
||
| 1490 | 1490 | $this->objects[$id]['info']['ColorSpace'] = $tmp; |
| 1491 | 1491 | if (isset($options['transparency'])) { |
| 1492 | 1492 | switch ($options['transparency']['type']) { |
| 1493 | - case 'indexed': |
|
| 1494 | - $tmp = ' [ '.$options['transparency']['data'].' '.$options['transparency']['data'].'] '; |
|
| 1495 | - $this->objects[$id]['info']['Mask'] = $tmp; |
|
| 1496 | - break; |
|
| 1497 | - |
|
| 1498 | - case 'color-key': |
|
| 1499 | - $tmp = ' [ '. |
|
| 1500 | - $options['transparency']['r'] . ' ' . $options['transparency']['r'] . |
|
| 1501 | - $options['transparency']['g'] . ' ' . $options['transparency']['g'] . |
|
| 1502 | - $options['transparency']['b'] . ' ' . $options['transparency']['b'] . |
|
| 1503 | - ' ] '; |
|
| 1504 | - $this->objects[$id]['info']['Mask'] = $tmp; |
|
| 1505 | - pre_r($tmp); |
|
| 1506 | - break; |
|
| 1493 | + case 'indexed': |
|
| 1494 | + $tmp = ' [ '.$options['transparency']['data'].' '.$options['transparency']['data'].'] '; |
|
| 1495 | + $this->objects[$id]['info']['Mask'] = $tmp; |
|
| 1496 | + break; |
|
| 1497 | + |
|
| 1498 | + case 'color-key': |
|
| 1499 | + $tmp = ' [ '. |
|
| 1500 | + $options['transparency']['r'] . ' ' . $options['transparency']['r'] . |
|
| 1501 | + $options['transparency']['g'] . ' ' . $options['transparency']['g'] . |
|
| 1502 | + $options['transparency']['b'] . ' ' . $options['transparency']['b'] . |
|
| 1503 | + ' ] '; |
|
| 1504 | + $this->objects[$id]['info']['Mask'] = $tmp; |
|
| 1505 | + pre_r($tmp); |
|
| 1506 | + break; |
|
| 1507 | 1507 | |
| 1508 | 1508 | } |
| 1509 | 1509 | } |
| 1510 | 1510 | } else { |
| 1511 | 1511 | if (isset($options['transparency'])) { |
| 1512 | 1512 | switch ($options['transparency']['type']) { |
| 1513 | - case 'indexed': |
|
| 1514 | - $tmp = ' [ '.$options['transparency']['data'].' '.$options['transparency']['data'].'] '; |
|
| 1515 | - $this->objects[$id]['info']['Mask'] = $tmp; |
|
| 1516 | - break; |
|
| 1517 | - |
|
| 1518 | - case 'color-key': |
|
| 1519 | - $tmp = ' [ '. |
|
| 1520 | - $options['transparency']['r'] . ' ' . $options['transparency']['r'] . ' ' . |
|
| 1521 | - $options['transparency']['g'] . ' ' . $options['transparency']['g'] . ' ' . |
|
| 1522 | - $options['transparency']['b'] . ' ' . $options['transparency']['b'] . |
|
| 1523 | - ' ] '; |
|
| 1524 | - $this->objects[$id]['info']['Mask'] = $tmp; |
|
| 1525 | - break; |
|
| 1513 | + case 'indexed': |
|
| 1514 | + $tmp = ' [ '.$options['transparency']['data'].' '.$options['transparency']['data'].'] '; |
|
| 1515 | + $this->objects[$id]['info']['Mask'] = $tmp; |
|
| 1516 | + break; |
|
| 1517 | + |
|
| 1518 | + case 'color-key': |
|
| 1519 | + $tmp = ' [ '. |
|
| 1520 | + $options['transparency']['r'] . ' ' . $options['transparency']['r'] . ' ' . |
|
| 1521 | + $options['transparency']['g'] . ' ' . $options['transparency']['g'] . ' ' . |
|
| 1522 | + $options['transparency']['b'] . ' ' . $options['transparency']['b'] . |
|
| 1523 | + ' ] '; |
|
| 1524 | + $this->objects[$id]['info']['Mask'] = $tmp; |
|
| 1525 | + break; |
|
| 1526 | 1526 | } |
| 1527 | 1527 | } |
| 1528 | 1528 | $this->objects[$id]['info']['ColorSpace'] = '/'.$options['color']; |
@@ -1539,22 +1539,22 @@ discard block |
||
| 1539 | 1539 | $this->o_procset($this->procsetObjectId, 'add', 'ImageC'); |
| 1540 | 1540 | break; |
| 1541 | 1541 | |
| 1542 | - case 'out': |
|
| 1543 | - $tmp = &$o['data']; |
|
| 1544 | - $res = "\n".$id." 0 obj\n<<"; |
|
| 1542 | + case 'out': |
|
| 1543 | + $tmp = &$o['data']; |
|
| 1544 | + $res = "\n".$id." 0 obj\n<<"; |
|
| 1545 | 1545 | |
| 1546 | - foreach($o['info'] as $k=>$v) { |
|
| 1547 | - $res.= "\n/".$k.' '.$v; |
|
| 1548 | - } |
|
| 1546 | + foreach($o['info'] as $k=>$v) { |
|
| 1547 | + $res.= "\n/".$k.' '.$v; |
|
| 1548 | + } |
|
| 1549 | 1549 | |
| 1550 | - if ($this->encrypted) { |
|
| 1551 | - $this->encryptInit($id); |
|
| 1552 | - $tmp = $this->ARC4($tmp); |
|
| 1553 | - } |
|
| 1550 | + if ($this->encrypted) { |
|
| 1551 | + $this->encryptInit($id); |
|
| 1552 | + $tmp = $this->ARC4($tmp); |
|
| 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 | - return $res; |
|
| 1557 | + return $res; |
|
| 1558 | 1558 | } |
| 1559 | 1559 | } |
| 1560 | 1560 | |
@@ -1575,29 +1575,29 @@ discard block |
||
| 1575 | 1575 | } |
| 1576 | 1576 | |
| 1577 | 1577 | switch ($action) { |
| 1578 | - case "new": |
|
| 1579 | - $this->objects[$id] = array('t' => 'extGState', 'info' => $options); |
|
| 1578 | + case "new": |
|
| 1579 | + $this->objects[$id] = array('t' => 'extGState', 'info' => $options); |
|
| 1580 | 1580 | |
| 1581 | - // Tell the pages about the new resource |
|
| 1582 | - $this->numStates++; |
|
| 1583 | - $this->o_pages($this->currentNode, 'extGState', array("objNum" => $id, "stateNum" => $this->numStates)); |
|
| 1584 | - break; |
|
| 1581 | + // Tell the pages about the new resource |
|
| 1582 | + $this->numStates++; |
|
| 1583 | + $this->o_pages($this->currentNode, 'extGState', array("objNum" => $id, "stateNum" => $this->numStates)); |
|
| 1584 | + break; |
|
| 1585 | 1585 | |
| 1586 | - case "out": |
|
| 1587 | - $res = |
|
| 1588 | - "\n" . $id . " 0 obj\n". |
|
| 1589 | - "<< /Type /ExtGState\n"; |
|
| 1586 | + case "out": |
|
| 1587 | + $res = |
|
| 1588 | + "\n" . $id . " 0 obj\n". |
|
| 1589 | + "<< /Type /ExtGState\n"; |
|
| 1590 | 1590 | |
| 1591 | - foreach ($o["info"] as $parameter => $value) { |
|
| 1592 | - if ( !in_array($parameter, $valid_params)) |
|
| 1593 | - continue; |
|
| 1594 | - $res.= "/$parameter $value\n"; |
|
| 1595 | - } |
|
| 1591 | + foreach ($o["info"] as $parameter => $value) { |
|
| 1592 | + if ( !in_array($parameter, $valid_params)) |
|
| 1593 | + continue; |
|
| 1594 | + $res.= "/$parameter $value\n"; |
|
| 1595 | + } |
|
| 1596 | 1596 | |
| 1597 | - $res.= |
|
| 1598 | - ">>\n". |
|
| 1599 | - "endobj"; |
|
| 1600 | - return $res; |
|
| 1597 | + $res.= |
|
| 1598 | + ">>\n". |
|
| 1599 | + "endobj"; |
|
| 1600 | + return $res; |
|
| 1601 | 1601 | } |
| 1602 | 1602 | } |
| 1603 | 1603 | |
@@ -1611,63 +1611,63 @@ discard block |
||
| 1611 | 1611 | } |
| 1612 | 1612 | |
| 1613 | 1613 | switch ($action) { |
| 1614 | - case 'new': |
|
| 1615 | - // make the new object |
|
| 1616 | - $this->objects[$id] = array('t'=>'encryption', 'info'=>$options); |
|
| 1617 | - $this->arc4_objnum = $id; |
|
| 1618 | - |
|
| 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'); |
|
| 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); |
|
| 1627 | - } else { |
|
| 1628 | - $owner = $options['owner']; |
|
| 1629 | - } |
|
| 1614 | + case 'new': |
|
| 1615 | + // make the new object |
|
| 1616 | + $this->objects[$id] = array('t'=>'encryption', 'info'=>$options); |
|
| 1617 | + $this->arc4_objnum = $id; |
|
| 1618 | + |
|
| 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'); |
|
| 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); |
|
| 1627 | + } else { |
|
| 1628 | + $owner = $options['owner']; |
|
| 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); |
|
| 1636 | - } else { |
|
| 1637 | - $user = $options['user']; |
|
| 1638 | - } |
|
| 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 | + } else { |
|
| 1637 | + $user = $options['user']; |
|
| 1638 | + } |
|
| 1639 | 1639 | |
| 1640 | - $tmp = $this->md5_16($owner); |
|
| 1641 | - $okey = substr($tmp, 0, 5); |
|
| 1642 | - $this->ARC4_init($okey); |
|
| 1643 | - $ovalue = $this->ARC4($user); |
|
| 1644 | - $this->objects[$id]['info']['O'] = $ovalue; |
|
| 1645 | - |
|
| 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); |
|
| 1648 | - |
|
| 1649 | - $ukey = substr($tmp, 0, 5); |
|
| 1650 | - $this->ARC4_init($ukey); |
|
| 1651 | - $this->encryptionKey = $ukey; |
|
| 1652 | - $this->encrypted = 1; |
|
| 1653 | - $uvalue = $this->ARC4($pad); |
|
| 1654 | - $this->objects[$id]['info']['U'] = $uvalue; |
|
| 1655 | - $this->encryptionKey = $ukey; |
|
| 1656 | - // initialize the arc4 array |
|
| 1657 | - break; |
|
| 1640 | + $tmp = $this->md5_16($owner); |
|
| 1641 | + $okey = substr($tmp, 0, 5); |
|
| 1642 | + $this->ARC4_init($okey); |
|
| 1643 | + $ovalue = $this->ARC4($user); |
|
| 1644 | + $this->objects[$id]['info']['O'] = $ovalue; |
|
| 1645 | + |
|
| 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); |
|
| 1648 | + |
|
| 1649 | + $ukey = substr($tmp, 0, 5); |
|
| 1650 | + $this->ARC4_init($ukey); |
|
| 1651 | + $this->encryptionKey = $ukey; |
|
| 1652 | + $this->encrypted = 1; |
|
| 1653 | + $uvalue = $this->ARC4($pad); |
|
| 1654 | + $this->objects[$id]['info']['U'] = $uvalue; |
|
| 1655 | + $this->encryptionKey = $ukey; |
|
| 1656 | + // initialize the arc4 array |
|
| 1657 | + break; |
|
| 1658 | 1658 | |
| 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']) .')'; |
|
| 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"; |
|
| 1670 | - return $res; |
|
| 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']) .')'; |
|
| 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"; |
|
| 1670 | + return $res; |
|
| 1671 | 1671 | } |
| 1672 | 1672 | } |
| 1673 | 1673 | |
@@ -1999,112 +1999,112 @@ discard block |
||
| 1999 | 1999 | // then there must be some keyword |
| 2000 | 2000 | $key = substr($row, 0, $pos); |
| 2001 | 2001 | switch ($key) { |
| 2002 | - case 'FontName': |
|
| 2003 | - case 'FullName': |
|
| 2004 | - case 'FamilyName': |
|
| 2005 | - case 'Weight': |
|
| 2006 | - case 'ItalicAngle': |
|
| 2007 | - case 'IsFixedPitch': |
|
| 2008 | - case 'CharacterSet': |
|
| 2009 | - case 'UnderlinePosition': |
|
| 2010 | - case 'UnderlineThickness': |
|
| 2011 | - case 'Version': |
|
| 2012 | - case 'EncodingScheme': |
|
| 2013 | - case 'CapHeight': |
|
| 2014 | - case 'XHeight': |
|
| 2015 | - case 'Ascender': |
|
| 2016 | - case 'Descender': |
|
| 2017 | - case 'StdHW': |
|
| 2018 | - case 'StdVW': |
|
| 2019 | - case 'StartCharMetrics': |
|
| 2020 | - case 'FontHeightOffset': // OAR - Added so we can offset the height calculation of a Windows font. Otherwise it's too big. |
|
| 2021 | - $data[$key] = trim(substr($row, $pos)); |
|
| 2022 | - break; |
|
| 2023 | - |
|
| 2024 | - case 'FontBBox': |
|
| 2025 | - $data[$key] = explode(' ', trim(substr($row, $pos))); |
|
| 2026 | - break; |
|
| 2027 | - |
|
| 2028 | - case 'C': // Found in AFM files |
|
| 2029 | - //C 39 ; WX 222 ; N quoteright ; B 53 463 157 718 ; |
|
| 2030 | - $bits = explode(';', trim($row)); |
|
| 2031 | - $dtmp = array(); |
|
| 2032 | - |
|
| 2033 | - foreach($bits as $bit) { |
|
| 2034 | - $bits2 = explode(' ', trim($bit)); |
|
| 2035 | - if (mb_strlen($bits2[0], '8bit')) { |
|
| 2036 | - if (count($bits2) >2) { |
|
| 2037 | - $dtmp[$bits2[0]] = array(); |
|
| 2038 | - for ($i = 1;$i<count($bits2);$i++) { |
|
| 2039 | - $dtmp[$bits2[0]][] = $bits2[$i]; |
|
| 2002 | + case 'FontName': |
|
| 2003 | + case 'FullName': |
|
| 2004 | + case 'FamilyName': |
|
| 2005 | + case 'Weight': |
|
| 2006 | + case 'ItalicAngle': |
|
| 2007 | + case 'IsFixedPitch': |
|
| 2008 | + case 'CharacterSet': |
|
| 2009 | + case 'UnderlinePosition': |
|
| 2010 | + case 'UnderlineThickness': |
|
| 2011 | + case 'Version': |
|
| 2012 | + case 'EncodingScheme': |
|
| 2013 | + case 'CapHeight': |
|
| 2014 | + case 'XHeight': |
|
| 2015 | + case 'Ascender': |
|
| 2016 | + case 'Descender': |
|
| 2017 | + case 'StdHW': |
|
| 2018 | + case 'StdVW': |
|
| 2019 | + case 'StartCharMetrics': |
|
| 2020 | + case 'FontHeightOffset': // OAR - Added so we can offset the height calculation of a Windows font. Otherwise it's too big. |
|
| 2021 | + $data[$key] = trim(substr($row, $pos)); |
|
| 2022 | + break; |
|
| 2023 | + |
|
| 2024 | + case 'FontBBox': |
|
| 2025 | + $data[$key] = explode(' ', trim(substr($row, $pos))); |
|
| 2026 | + break; |
|
| 2027 | + |
|
| 2028 | + case 'C': // Found in AFM files |
|
| 2029 | + //C 39 ; WX 222 ; N quoteright ; B 53 463 157 718 ; |
|
| 2030 | + $bits = explode(';', trim($row)); |
|
| 2031 | + $dtmp = array(); |
|
| 2032 | + |
|
| 2033 | + foreach($bits as $bit) { |
|
| 2034 | + $bits2 = explode(' ', trim($bit)); |
|
| 2035 | + if (mb_strlen($bits2[0], '8bit')) { |
|
| 2036 | + if (count($bits2) >2) { |
|
| 2037 | + $dtmp[$bits2[0]] = array(); |
|
| 2038 | + for ($i = 1;$i<count($bits2);$i++) { |
|
| 2039 | + $dtmp[$bits2[0]][] = $bits2[$i]; |
|
| 2040 | + } |
|
| 2041 | + } else if (count($bits2) == 2) { |
|
| 2042 | + $dtmp[$bits2[0]] = $bits2[1]; |
|
| 2043 | + } |
|
| 2040 | 2044 | } |
| 2041 | - } else if (count($bits2) == 2) { |
|
| 2042 | - $dtmp[$bits2[0]] = $bits2[1]; |
|
| 2043 | 2045 | } |
| 2044 | - } |
|
| 2045 | - } |
|
| 2046 | 2046 | |
| 2047 | - $cc = (int)$dtmp['C']; |
|
| 2048 | - if ($cc >= 0) { |
|
| 2049 | - $data['C'][$dtmp['C']] = $dtmp; |
|
| 2050 | - $data['C'][$dtmp['N']] = $dtmp; |
|
| 2051 | - } else { |
|
| 2052 | - $data['C'][$dtmp['N']] = $dtmp; |
|
| 2053 | - } |
|
| 2047 | + $cc = (int)$dtmp['C']; |
|
| 2048 | + if ($cc >= 0) { |
|
| 2049 | + $data['C'][$dtmp['C']] = $dtmp; |
|
| 2050 | + $data['C'][$dtmp['N']] = $dtmp; |
|
| 2051 | + } else { |
|
| 2052 | + $data['C'][$dtmp['N']] = $dtmp; |
|
| 2053 | + } |
|
| 2054 | 2054 | |
| 2055 | - if (!isset($data['MissingWidth']) && $cc == -1 && $dtmp['N'] === '.notdef') { |
|
| 2056 | - $data['MissingWidth'] = $width; |
|
| 2057 | - } |
|
| 2055 | + if (!isset($data['MissingWidth']) && $cc == -1 && $dtmp['N'] === '.notdef') { |
|
| 2056 | + $data['MissingWidth'] = $width; |
|
| 2057 | + } |
|
| 2058 | 2058 | |
| 2059 | - break; |
|
| 2060 | - |
|
| 2061 | - case 'U': // Found in UFM files |
|
| 2062 | - if ($data['isUnicode']) { |
|
| 2063 | - // U 827 ; WX 0 ; N squaresubnosp ; G 675 ; |
|
| 2064 | - $bits = explode(';', trim($row)); |
|
| 2065 | - $dtmp = array(); |
|
| 2066 | - |
|
| 2067 | - foreach($bits as $bit) { |
|
| 2068 | - $bits2 = explode(' ', trim($bit)); |
|
| 2069 | - if (mb_strlen($bits2[0], '8bit')) { |
|
| 2070 | - if (count($bits2) >2) { |
|
| 2071 | - $dtmp[$bits2[0]] = array(); |
|
| 2072 | - for ($i = 1;$i<count($bits2);$i++) { |
|
| 2073 | - $dtmp[$bits2[0]][] = $bits2[$i]; |
|
| 2059 | + break; |
|
| 2060 | + |
|
| 2061 | + case 'U': // Found in UFM files |
|
| 2062 | + if ($data['isUnicode']) { |
|
| 2063 | + // U 827 ; WX 0 ; N squaresubnosp ; G 675 ; |
|
| 2064 | + $bits = explode(';', trim($row)); |
|
| 2065 | + $dtmp = array(); |
|
| 2066 | + |
|
| 2067 | + foreach($bits as $bit) { |
|
| 2068 | + $bits2 = explode(' ', trim($bit)); |
|
| 2069 | + if (mb_strlen($bits2[0], '8bit')) { |
|
| 2070 | + if (count($bits2) >2) { |
|
| 2071 | + $dtmp[$bits2[0]] = array(); |
|
| 2072 | + for ($i = 1;$i<count($bits2);$i++) { |
|
| 2073 | + $dtmp[$bits2[0]][] = $bits2[$i]; |
|
| 2074 | + } |
|
| 2075 | + } else if (count($bits2) == 2) { |
|
| 2076 | + $dtmp[$bits2[0]] = $bits2[1]; |
|
| 2077 | + } |
|
| 2074 | 2078 | } |
| 2075 | - } else if (count($bits2) == 2) { |
|
| 2076 | - $dtmp[$bits2[0]] = $bits2[1]; |
|
| 2077 | 2079 | } |
| 2078 | - } |
|
| 2079 | - } |
|
| 2080 | 2080 | |
| 2081 | - $cc = (int)$dtmp['U']; |
|
| 2082 | - $glyph = $dtmp['G']; |
|
| 2083 | - $width = $dtmp['WX']; |
|
| 2084 | - if ($cc >= 0) { |
|
| 2085 | - // Set values in CID to GID map |
|
| 2086 | - if ($cc >= 0 && $cc < 0xFFFF && $glyph) { |
|
| 2087 | - $cidtogid[$cc*2] = chr($glyph >> 8); |
|
| 2088 | - $cidtogid[$cc*2 + 1] = chr($glyph & 0xFF); |
|
| 2089 | - } |
|
| 2081 | + $cc = (int)$dtmp['U']; |
|
| 2082 | + $glyph = $dtmp['G']; |
|
| 2083 | + $width = $dtmp['WX']; |
|
| 2084 | + if ($cc >= 0) { |
|
| 2085 | + // Set values in CID to GID map |
|
| 2086 | + if ($cc >= 0 && $cc < 0xFFFF && $glyph) { |
|
| 2087 | + $cidtogid[$cc*2] = chr($glyph >> 8); |
|
| 2088 | + $cidtogid[$cc*2 + 1] = chr($glyph & 0xFF); |
|
| 2089 | + } |
|
| 2090 | 2090 | |
| 2091 | - $data['C'][$dtmp['U']] = $dtmp; |
|
| 2092 | - $data['C'][$dtmp['N']] = $dtmp; |
|
| 2093 | - } else { |
|
| 2094 | - $data['C'][$dtmp['N']] = $dtmp; |
|
| 2095 | - } |
|
| 2091 | + $data['C'][$dtmp['U']] = $dtmp; |
|
| 2092 | + $data['C'][$dtmp['N']] = $dtmp; |
|
| 2093 | + } else { |
|
| 2094 | + $data['C'][$dtmp['N']] = $dtmp; |
|
| 2095 | + } |
|
| 2096 | 2096 | |
| 2097 | - if (!isset($data['MissingWidth']) && $cc == -1 && $dtmp['N'] === '.notdef') { |
|
| 2098 | - $data['MissingWidth'] = $width; |
|
| 2099 | - } |
|
| 2100 | - } |
|
| 2101 | - break; |
|
| 2097 | + if (!isset($data['MissingWidth']) && $cc == -1 && $dtmp['N'] === '.notdef') { |
|
| 2098 | + $data['MissingWidth'] = $width; |
|
| 2099 | + } |
|
| 2100 | + } |
|
| 2101 | + break; |
|
| 2102 | 2102 | |
| 2103 | - case 'KPX': |
|
| 2104 | - //KPX Adieresis yacute -40 |
|
| 2105 | - $bits = explode(' ', trim($row)); |
|
| 2106 | - $data['KPX'][$bits[1]][$bits[2]] = $bits[3]; |
|
| 2107 | - break; |
|
| 2103 | + case 'KPX': |
|
| 2104 | + //KPX Adieresis yacute -40 |
|
| 2105 | + $bits = explode(' ', trim($row)); |
|
| 2106 | + $data['KPX'][$bits[1]][$bits[2]] = $bits[3]; |
|
| 2107 | + break; |
|
| 2108 | 2108 | } |
| 2109 | 2109 | } |
| 2110 | 2110 | } |
@@ -3108,163 +3108,163 @@ discard block |
||
| 3108 | 3108 | if ($text[$j] === '<') { |
| 3109 | 3109 | $j++; |
| 3110 | 3110 | switch ($text[$j]) { |
| 3111 | - case '/': |
|
| 3112 | - $j++; |
|
| 3113 | - if (mb_strlen($text) <= $j) { |
|
| 3114 | - return $directive; |
|
| 3115 | - } |
|
| 3111 | + case '/': |
|
| 3112 | + $j++; |
|
| 3113 | + if (mb_strlen($text) <= $j) { |
|
| 3114 | + return $directive; |
|
| 3115 | + } |
|
| 3116 | 3116 | |
| 3117 | - switch ($text[$j]) { |
|
| 3118 | - case 'b': |
|
| 3119 | - case 'i': |
|
| 3120 | - $j++; |
|
| 3121 | - if ($text[$j] === '>') { |
|
| 3122 | - $p = mb_strrpos($this->currentTextState, $text[$j-1]); |
|
| 3117 | + switch ($text[$j]) { |
|
| 3118 | + case 'b': |
|
| 3119 | + case 'i': |
|
| 3120 | + $j++; |
|
| 3121 | + if ($text[$j] === '>') { |
|
| 3122 | + $p = mb_strrpos($this->currentTextState, $text[$j-1]); |
|
| 3123 | 3123 | |
| 3124 | - if ($p !== false) { |
|
| 3125 | - // then there is one to remove |
|
| 3126 | - $this->currentTextState = mb_substr($this->currentTextState, 0, $p) .substr($this->currentTextState, $p+1); |
|
| 3127 | - } |
|
| 3124 | + if ($p !== false) { |
|
| 3125 | + // then there is one to remove |
|
| 3126 | + $this->currentTextState = mb_substr($this->currentTextState, 0, $p) .substr($this->currentTextState, $p+1); |
|
| 3127 | + } |
|
| 3128 | 3128 | |
| 3129 | - $directive = $j-$i+1; |
|
| 3130 | - } |
|
| 3131 | - break; |
|
| 3129 | + $directive = $j-$i+1; |
|
| 3130 | + } |
|
| 3131 | + break; |
|
| 3132 | + |
|
| 3133 | + case 'c': |
|
| 3134 | + // this this might be a callback function |
|
| 3135 | + $j++; |
|
| 3136 | + $k = mb_strpos($text, '>', $j); |
|
| 3137 | + |
|
| 3138 | + if ($k !== false && $text[$j] === ':') { |
|
| 3139 | + // then this will be treated as a callback directive |
|
| 3140 | + $directive = $k-$i+1; |
|
| 3141 | + $f = 0; |
|
| 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, ':'); |
|
| 3145 | + |
|
| 3146 | + if ($b1 !== false) { |
|
| 3147 | + $func = mb_substr($tmp, 0, $b1); |
|
| 3148 | + $parm = mb_substr($tmp, $b1+1); |
|
| 3149 | + } else { |
|
| 3150 | + $func = $tmp; |
|
| 3151 | + $parm = ''; |
|
| 3152 | + } |
|
| 3132 | 3153 | |
| 3133 | - case 'c': |
|
| 3134 | - // this this might be a callback function |
|
| 3135 | - $j++; |
|
| 3136 | - $k = mb_strpos($text, '>', $j); |
|
| 3137 | - |
|
| 3138 | - if ($k !== false && $text[$j] === ':') { |
|
| 3139 | - // then this will be treated as a callback directive |
|
| 3140 | - $directive = $k-$i+1; |
|
| 3141 | - $f = 0; |
|
| 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, ':'); |
|
| 3145 | - |
|
| 3146 | - if ($b1 !== false) { |
|
| 3147 | - $func = mb_substr($tmp, 0, $b1); |
|
| 3148 | - $parm = mb_substr($tmp, $b1+1); |
|
| 3149 | - } else { |
|
| 3150 | - $func = $tmp; |
|
| 3151 | - $parm = ''; |
|
| 3152 | - } |
|
| 3154 | + if (!isset($func) || !mb_strlen(trim($func), '8bit')) { |
|
| 3155 | + $directive = 0; |
|
| 3156 | + } else { |
|
| 3157 | + // only call the function if this is the final call |
|
| 3158 | + if ($final) { |
|
| 3159 | + // need to assess the text position, calculate the text width to this point |
|
| 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)); |
|
| 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); |
|
| 3167 | + |
|
| 3168 | + if (is_array($ret)) { |
|
| 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) { |
|
| 3171 | + switch ($rk) { |
|
| 3172 | + case 'x': |
|
| 3173 | + case 'y': |
|
| 3174 | + $$rk = $rv; |
|
| 3175 | + break; |
|
| 3176 | + } |
|
| 3177 | + } |
|
| 3178 | + } |
|
| 3153 | 3179 | |
| 3154 | - if (!isset($func) || !mb_strlen(trim($func), '8bit')) { |
|
| 3155 | - $directive = 0; |
|
| 3156 | - } else { |
|
| 3157 | - // only call the function if this is the final call |
|
| 3158 | - if ($final) { |
|
| 3159 | - // need to assess the text position, calculate the text width to this point |
|
| 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)); |
|
| 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); |
|
| 3167 | - |
|
| 3168 | - if (is_array($ret)) { |
|
| 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) { |
|
| 3171 | - switch ($rk) { |
|
| 3172 | - case 'x': |
|
| 3173 | - case 'y': |
|
| 3174 | - $$rk = $rv; |
|
| 3175 | - break; |
|
| 3180 | + // also remove from to the stack |
|
| 3181 | + // for simplicity, just take from the end, fix this another day |
|
| 3182 | + $this->nCallback--; |
|
| 3183 | + if ($this->nCallback<0) { |
|
| 3184 | + $this->nCallBack = 0; |
|
| 3176 | 3185 | } |
| 3177 | 3186 | } |
| 3178 | 3187 | } |
| 3179 | - |
|
| 3180 | - // also remove from to the stack |
|
| 3181 | - // for simplicity, just take from the end, fix this another day |
|
| 3182 | - $this->nCallback--; |
|
| 3183 | - if ($this->nCallback<0) { |
|
| 3184 | - $this->nCallBack = 0; |
|
| 3185 | - } |
|
| 3186 | 3188 | } |
| 3187 | - } |
|
| 3188 | - } |
|
| 3189 | - break; |
|
| 3189 | + break; |
|
| 3190 | 3190 | } |
| 3191 | 3191 | break; |
| 3192 | 3192 | |
| 3193 | - case 'b': |
|
| 3194 | - case 'i': |
|
| 3195 | - $j++; |
|
| 3196 | - if ($text[$j] === '>') { |
|
| 3197 | - $this->currentTextState.= $text[$j-1]; |
|
| 3198 | - $directive = $j-$i+1; |
|
| 3199 | - } |
|
| 3200 | - break; |
|
| 3193 | + case 'b': |
|
| 3194 | + case 'i': |
|
| 3195 | + $j++; |
|
| 3196 | + if ($text[$j] === '>') { |
|
| 3197 | + $this->currentTextState.= $text[$j-1]; |
|
| 3198 | + $directive = $j-$i+1; |
|
| 3199 | + } |
|
| 3200 | + break; |
|
| 3201 | 3201 | |
| 3202 | - case 'C': |
|
| 3203 | - $noClose = 1; |
|
| 3204 | - case 'c': |
|
| 3205 | - // this this might be a callback function |
|
| 3206 | - $j++; |
|
| 3207 | - $k = mb_strpos($text, '>', $j); |
|
| 3202 | + case 'C': |
|
| 3203 | + $noClose = 1; |
|
| 3204 | + case 'c': |
|
| 3205 | + // this this might be a callback function |
|
| 3206 | + $j++; |
|
| 3207 | + $k = mb_strpos($text, '>', $j); |
|
| 3208 | 3208 | |
| 3209 | - if ($k !== false && $text[$j] === ':') { |
|
| 3210 | - // then this will be treated as a callback directive |
|
| 3211 | - $directive = $k-$i+1; |
|
| 3209 | + if ($k !== false && $text[$j] === ':') { |
|
| 3210 | + // then this will be treated as a callback directive |
|
| 3211 | + $directive = $k-$i+1; |
|
| 3212 | 3212 | |
| 3213 | - $f = 0; |
|
| 3213 | + $f = 0; |
|
| 3214 | 3214 | |
| 3215 | - // split the remainder on colons to get the function name and the paramater |
|
| 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, ':'); |
|
| 3215 | + // split the remainder on colons to get the function name and the paramater |
|
| 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, ':'); |
|
| 3219 | 3219 | |
| 3220 | - if ($b1 !== false) { |
|
| 3221 | - $func = mb_substr($tmp, 0, $b1); |
|
| 3222 | - $parm = mb_substr($tmp, $b1+1); |
|
| 3223 | - } else { |
|
| 3224 | - $func = $tmp; |
|
| 3225 | - $parm = ''; |
|
| 3226 | - } |
|
| 3227 | - |
|
| 3228 | - if (!isset($func) || !mb_strlen(trim($func), '8bit')) { |
|
| 3229 | - $directive = 0; |
|
| 3230 | - } else { |
|
| 3231 | - // only call the function if this is the final call, ie, the one actually doing printing, not measurement |
|
| 3232 | - if ($final) { |
|
| 3233 | - // need to assess the text position, calculate the text width to this point |
|
| 3234 | - // can use getTextWidth to find the text width I think |
|
| 3235 | - // also add the text height and descender |
|
| 3236 | - $tmp = $this->PRVTgetTextPosition($x, $y, $angle, $size, $wordSpaceAdjust, mb_substr($text, 0, $i)); |
|
| 3237 | - |
|
| 3238 | - $info = array( |
|
| 3239 | - 'x' => $tmp[0], |
|
| 3240 | - 'y' => $tmp[1], |
|
| 3241 | - 'angle' => $angle, |
|
| 3242 | - 'status' => 'start', |
|
| 3243 | - 'p' => $parm, |
|
| 3244 | - 'f' => $func, |
|
| 3245 | - 'height' => $this->getFontHeight($size), |
|
| 3246 | - 'descender' => $this->getFontDescender($size) |
|
| 3247 | - ); |
|
| 3248 | - $x = $tmp[0]; |
|
| 3249 | - $y = $tmp[1]; |
|
| 3250 | - |
|
| 3251 | - if (!isset($noClose) || !$noClose) { |
|
| 3252 | - // only add to the stack if this is a small 'c', therefore is a start-stop pair |
|
| 3253 | - $this->nCallback++; |
|
| 3254 | - $info['nCallback'] = $this->nCallback; |
|
| 3255 | - $this->callback[$this->nCallback] = $info; |
|
| 3220 | + if ($b1 !== false) { |
|
| 3221 | + $func = mb_substr($tmp, 0, $b1); |
|
| 3222 | + $parm = mb_substr($tmp, $b1+1); |
|
| 3223 | + } else { |
|
| 3224 | + $func = $tmp; |
|
| 3225 | + $parm = ''; |
|
| 3256 | 3226 | } |
| 3257 | 3227 | |
| 3258 | - $ret = $this->$func($info); |
|
| 3259 | - if (is_array($ret)) { |
|
| 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) { |
|
| 3262 | - switch ($rk) { |
|
| 3263 | - case 'x': |
|
| 3264 | - case 'y': |
|
| 3265 | - $$rk = $rv; |
|
| 3266 | - break; |
|
| 3228 | + if (!isset($func) || !mb_strlen(trim($func), '8bit')) { |
|
| 3229 | + $directive = 0; |
|
| 3230 | + } else { |
|
| 3231 | + // only call the function if this is the final call, ie, the one actually doing printing, not measurement |
|
| 3232 | + if ($final) { |
|
| 3233 | + // need to assess the text position, calculate the text width to this point |
|
| 3234 | + // can use getTextWidth to find the text width I think |
|
| 3235 | + // also add the text height and descender |
|
| 3236 | + $tmp = $this->PRVTgetTextPosition($x, $y, $angle, $size, $wordSpaceAdjust, mb_substr($text, 0, $i)); |
|
| 3237 | + |
|
| 3238 | + $info = array( |
|
| 3239 | + 'x' => $tmp[0], |
|
| 3240 | + 'y' => $tmp[1], |
|
| 3241 | + 'angle' => $angle, |
|
| 3242 | + 'status' => 'start', |
|
| 3243 | + 'p' => $parm, |
|
| 3244 | + 'f' => $func, |
|
| 3245 | + 'height' => $this->getFontHeight($size), |
|
| 3246 | + 'descender' => $this->getFontDescender($size) |
|
| 3247 | + ); |
|
| 3248 | + $x = $tmp[0]; |
|
| 3249 | + $y = $tmp[1]; |
|
| 3250 | + |
|
| 3251 | + if (!isset($noClose) || !$noClose) { |
|
| 3252 | + // only add to the stack if this is a small 'c', therefore is a start-stop pair |
|
| 3253 | + $this->nCallback++; |
|
| 3254 | + $info['nCallback'] = $this->nCallback; |
|
| 3255 | + $this->callback[$this->nCallback] = $info; |
|
| 3267 | 3256 | } |
| 3257 | + |
|
| 3258 | + $ret = $this->$func($info); |
|
| 3259 | + if (is_array($ret)) { |
|
| 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) { |
|
| 3262 | + switch ($rk) { |
|
| 3263 | + case 'x': |
|
| 3264 | + case 'y': |
|
| 3265 | + $$rk = $rv; |
|
| 3266 | + break; |
|
| 3267 | + } |
|
| 3268 | 3268 | } |
| 3269 | 3269 | } |
| 3270 | 3270 | } |
@@ -3471,29 +3471,29 @@ discard block |
||
| 3471 | 3471 | */ |
| 3472 | 3472 | function PRVTadjustWrapText($text, $actual, $width, &$x, &$adjust, $justification) { |
| 3473 | 3473 | switch ($justification) { |
| 3474 | - case 'left': |
|
| 3475 | - return; |
|
| 3474 | + case 'left': |
|
| 3475 | + return; |
|
| 3476 | 3476 | |
| 3477 | - case 'right': |
|
| 3478 | - $x+= $width-$actual; |
|
| 3479 | - break; |
|
| 3477 | + case 'right': |
|
| 3478 | + $x+= $width-$actual; |
|
| 3479 | + break; |
|
| 3480 | 3480 | |
| 3481 | - case 'center': |
|
| 3482 | - case 'centre': |
|
| 3483 | - $x+= ($width-$actual) /2; |
|
| 3484 | - break; |
|
| 3481 | + case 'center': |
|
| 3482 | + case 'centre': |
|
| 3483 | + $x+= ($width-$actual) /2; |
|
| 3484 | + break; |
|
| 3485 | 3485 | |
| 3486 | - case 'full': |
|
| 3487 | - // count the number of words |
|
| 3488 | - $words = explode(' ', $text); |
|
| 3489 | - $nspaces = count($words) -1; |
|
| 3486 | + case 'full': |
|
| 3487 | + // count the number of words |
|
| 3488 | + $words = explode(' ', $text); |
|
| 3489 | + $nspaces = count($words) -1; |
|
| 3490 | 3490 | |
| 3491 | - if ($nspaces>0) { |
|
| 3492 | - $adjust = ($width-$actual) /$nspaces; |
|
| 3493 | - } else { |
|
| 3494 | - $adjust = 0; |
|
| 3495 | - } |
|
| 3496 | - break; |
|
| 3491 | + if ($nspaces>0) { |
|
| 3492 | + $adjust = ($width-$actual) /$nspaces; |
|
| 3493 | + } else { |
|
| 3494 | + $adjust = 0; |
|
| 3495 | + } |
|
| 3496 | + break; |
|
| 3497 | 3497 | } |
| 3498 | 3498 | } |
| 3499 | 3499 | |
@@ -3766,48 +3766,48 @@ discard block |
||
| 3766 | 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 | - case 'all': |
|
| 3770 | - // then this object is to be added to this page (done in the next block) and |
|
| 3771 | - // all future new pages. |
|
| 3772 | - $this->addLooseObjects[$id] = 'all'; |
|
| 3773 | - |
|
| 3774 | - case 'add': |
|
| 3775 | - if (isset($this->objects[$this->currentContents]['onPage'])) { |
|
| 3776 | - // then the destination contents is the primary for the page |
|
| 3777 | - // (though this object is actually added to that page) |
|
| 3778 | - $this->o_page($this->objects[$this->currentContents]['onPage'], 'content', $id); |
|
| 3779 | - } |
|
| 3780 | - break; |
|
| 3769 | + case 'all': |
|
| 3770 | + // then this object is to be added to this page (done in the next block) and |
|
| 3771 | + // all future new pages. |
|
| 3772 | + $this->addLooseObjects[$id] = 'all'; |
|
| 3773 | + |
|
| 3774 | + case 'add': |
|
| 3775 | + if (isset($this->objects[$this->currentContents]['onPage'])) { |
|
| 3776 | + // then the destination contents is the primary for the page |
|
| 3777 | + // (though this object is actually added to that page) |
|
| 3778 | + $this->o_page($this->objects[$this->currentContents]['onPage'], 'content', $id); |
|
| 3779 | + } |
|
| 3780 | + break; |
|
| 3781 | 3781 | |
| 3782 | - case 'even': |
|
| 3783 | - $this->addLooseObjects[$id] = 'even'; |
|
| 3784 | - $pageObjectId = $this->objects[$this->currentContents]['onPage']; |
|
| 3785 | - if ($this->objects[$pageObjectId]['info']['pageNum']%2 == 0) { |
|
| 3786 | - $this->addObject($id); |
|
| 3787 | - // hacky huh :) |
|
| 3788 | - } |
|
| 3789 | - break; |
|
| 3782 | + case 'even': |
|
| 3783 | + $this->addLooseObjects[$id] = 'even'; |
|
| 3784 | + $pageObjectId = $this->objects[$this->currentContents]['onPage']; |
|
| 3785 | + if ($this->objects[$pageObjectId]['info']['pageNum']%2 == 0) { |
|
| 3786 | + $this->addObject($id); |
|
| 3787 | + // hacky huh :) |
|
| 3788 | + } |
|
| 3789 | + break; |
|
| 3790 | 3790 | |
| 3791 | - case 'odd': |
|
| 3792 | - $this->addLooseObjects[$id] = 'odd'; |
|
| 3793 | - $pageObjectId = $this->objects[$this->currentContents]['onPage']; |
|
| 3794 | - if ($this->objects[$pageObjectId]['info']['pageNum']%2 == 1) { |
|
| 3795 | - $this->addObject($id); |
|
| 3796 | - // hacky huh :) |
|
| 3797 | - } |
|
| 3798 | - break; |
|
| 3791 | + case 'odd': |
|
| 3792 | + $this->addLooseObjects[$id] = 'odd'; |
|
| 3793 | + $pageObjectId = $this->objects[$this->currentContents]['onPage']; |
|
| 3794 | + if ($this->objects[$pageObjectId]['info']['pageNum']%2 == 1) { |
|
| 3795 | + $this->addObject($id); |
|
| 3796 | + // hacky huh :) |
|
| 3797 | + } |
|
| 3798 | + break; |
|
| 3799 | 3799 | |
| 3800 | - case 'next': |
|
| 3801 | - $this->addLooseObjects[$id] = 'all'; |
|
| 3802 | - break; |
|
| 3800 | + case 'next': |
|
| 3801 | + $this->addLooseObjects[$id] = 'all'; |
|
| 3802 | + break; |
|
| 3803 | 3803 | |
| 3804 | - case 'nexteven': |
|
| 3805 | - $this->addLooseObjects[$id] = 'even'; |
|
| 3806 | - break; |
|
| 3804 | + case 'nexteven': |
|
| 3805 | + $this->addLooseObjects[$id] = 'even'; |
|
| 3806 | + break; |
|
| 3807 | 3807 | |
| 3808 | - case 'nextodd': |
|
| 3809 | - $this->addLooseObjects[$id] = 'odd'; |
|
| 3810 | - break; |
|
| 3808 | + case 'nextodd': |
|
| 3809 | + $this->addLooseObjects[$id] = 'odd'; |
|
| 3810 | + break; |
|
| 3811 | 3811 | } |
| 3812 | 3812 | } |
| 3813 | 3813 | } |
@@ -4025,105 +4025,105 @@ discard block |
||
| 4025 | 4025 | $chunkType = mb_substr($data, $p+4, 4, '8bit'); |
| 4026 | 4026 | // echo $chunkType.' - '.$chunkLen.'<br>'; |
| 4027 | 4027 | switch ($chunkType) { |
| 4028 | - case 'IHDR': |
|
| 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]); |
|
| 4037 | - |
|
| 4038 | - //print_r($info); |
|
| 4039 | - $haveHeader = 1; |
|
| 4040 | - if ($info['compressionMethod'] != 0) { |
|
| 4041 | - $error = 1; |
|
| 4042 | - |
|
| 4043 | - //debugpng |
|
| 4044 | - if (DEBUGPNG) print '[addPngFromFile unsupported compression method '.$file.']'; |
|
| 4045 | - |
|
| 4046 | - $errormsg = 'unsupported compression method'; |
|
| 4047 | - } |
|
| 4028 | + case 'IHDR': |
|
| 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]); |
|
| 4037 | + |
|
| 4038 | + //print_r($info); |
|
| 4039 | + $haveHeader = 1; |
|
| 4040 | + if ($info['compressionMethod'] != 0) { |
|
| 4041 | + $error = 1; |
|
| 4042 | + |
|
| 4043 | + //debugpng |
|
| 4044 | + if (DEBUGPNG) print '[addPngFromFile unsupported compression method '.$file.']'; |
|
| 4045 | + |
|
| 4046 | + $errormsg = 'unsupported compression method'; |
|
| 4047 | + } |
|
| 4048 | 4048 | |
| 4049 | - if ($info['filterMethod'] != 0) { |
|
| 4050 | - $error = 1; |
|
| 4049 | + if ($info['filterMethod'] != 0) { |
|
| 4050 | + $error = 1; |
|
| 4051 | 4051 | |
| 4052 | - //debugpng |
|
| 4053 | - if (DEBUGPNG) print '[addPngFromFile unsupported filter method '.$file.']'; |
|
| 4052 | + //debugpng |
|
| 4053 | + if (DEBUGPNG) print '[addPngFromFile unsupported filter method '.$file.']'; |
|
| 4054 | 4054 | |
| 4055 | - $errormsg = 'unsupported filter method'; |
|
| 4056 | - } |
|
| 4057 | - break; |
|
| 4055 | + $errormsg = 'unsupported filter method'; |
|
| 4056 | + } |
|
| 4057 | + break; |
|
| 4058 | 4058 | |
| 4059 | - case 'PLTE': |
|
| 4060 | - $pdata.= mb_substr($data, $p+8, $chunkLen, '8bit'); |
|
| 4061 | - break; |
|
| 4059 | + case 'PLTE': |
|
| 4060 | + $pdata.= mb_substr($data, $p+8, $chunkLen, '8bit'); |
|
| 4061 | + break; |
|
| 4062 | 4062 | |
| 4063 | - case 'IDAT': |
|
| 4064 | - $idata.= mb_substr($data, $p+8, $chunkLen, '8bit'); |
|
| 4065 | - break; |
|
| 4063 | + case 'IDAT': |
|
| 4064 | + $idata.= mb_substr($data, $p+8, $chunkLen, '8bit'); |
|
| 4065 | + break; |
|
| 4066 | 4066 | |
| 4067 | - case 'tRNS': |
|
| 4068 | - //this chunk can only occur once and it must occur after the PLTE chunk and before IDAT chunk |
|
| 4069 | - //print "tRNS found, color type = ".$info['colorType']."\n"; |
|
| 4070 | - $transparency = array(); |
|
| 4067 | + case 'tRNS': |
|
| 4068 | + //this chunk can only occur once and it must occur after the PLTE chunk and before IDAT chunk |
|
| 4069 | + //print "tRNS found, color type = ".$info['colorType']."\n"; |
|
| 4070 | + $transparency = array(); |
|
| 4071 | 4071 | |
| 4072 | - if ($info['colorType'] == 3) { |
|
| 4073 | - // indexed color, rbg |
|
| 4074 | - /* corresponding to entries in the plte chunk |
|
| 4072 | + if ($info['colorType'] == 3) { |
|
| 4073 | + // indexed color, rbg |
|
| 4074 | + /* corresponding to entries in the plte chunk |
|
| 4075 | 4075 | Alpha for palette index 0: 1 byte |
| 4076 | 4076 | Alpha for palette index 1: 1 byte |
| 4077 | 4077 | ...etc... |
| 4078 | 4078 | */ |
| 4079 | - // there will be one entry for each palette entry. up until the last non-opaque entry. |
|
| 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; |
|
| 4084 | - |
|
| 4085 | - for ($i = $chunkLen;$i >= 0;$i--) { |
|
| 4086 | - if (ord($data[$p+8+$i]) == 0) { |
|
| 4087 | - $trans = $i; |
|
| 4088 | - } |
|
| 4089 | - } |
|
| 4079 | + // there will be one entry for each palette entry. up until the last non-opaque entry. |
|
| 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; |
|
| 4084 | + |
|
| 4085 | + for ($i = $chunkLen;$i >= 0;$i--) { |
|
| 4086 | + if (ord($data[$p+8+$i]) == 0) { |
|
| 4087 | + $trans = $i; |
|
| 4088 | + } |
|
| 4089 | + } |
|
| 4090 | 4090 | |
| 4091 | - $transparency['data'] = $trans; |
|
| 4092 | - } elseif ($info['colorType'] == 0) { |
|
| 4093 | - // grayscale |
|
| 4094 | - /* corresponding to entries in the plte chunk |
|
| 4091 | + $transparency['data'] = $trans; |
|
| 4092 | + } elseif ($info['colorType'] == 0) { |
|
| 4093 | + // grayscale |
|
| 4094 | + /* corresponding to entries in the plte chunk |
|
| 4095 | 4095 | Gray: 2 bytes, range 0 .. (2^bitdepth)-1 |
| 4096 | 4096 | */ |
| 4097 | - // $transparency['grayscale'] = $this->PRVT_getBytes($data,$p+8,2); // g = grayscale |
|
| 4098 | - $transparency['type'] = 'indexed'; |
|
| 4097 | + // $transparency['grayscale'] = $this->PRVT_getBytes($data,$p+8,2); // g = grayscale |
|
| 4098 | + $transparency['type'] = 'indexed'; |
|
| 4099 | 4099 | |
| 4100 | - $transparency['data'] = ord($data[$p+8+1]); |
|
| 4101 | - } elseif ($info['colorType'] == 2) { |
|
| 4102 | - // truecolor |
|
| 4103 | - /* corresponding to entries in the plte chunk |
|
| 4100 | + $transparency['data'] = ord($data[$p+8+1]); |
|
| 4101 | + } elseif ($info['colorType'] == 2) { |
|
| 4102 | + // truecolor |
|
| 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); |
|
| 4109 | - // r from truecolor |
|
| 4110 | - $transparency['g'] = $this->PRVT_getBytes($data, $p+10, 2); |
|
| 4111 | - // g from truecolor |
|
| 4112 | - $transparency['b'] = $this->PRVT_getBytes($data, $p+12, 2); |
|
| 4113 | - // b from truecolor |
|
| 4114 | - |
|
| 4115 | - $transparency['type'] = 'color-key'; |
|
| 4108 | + $transparency['r'] = $this->PRVT_getBytes($data, $p+8, 2); |
|
| 4109 | + // r from truecolor |
|
| 4110 | + $transparency['g'] = $this->PRVT_getBytes($data, $p+10, 2); |
|
| 4111 | + // g from truecolor |
|
| 4112 | + $transparency['b'] = $this->PRVT_getBytes($data, $p+12, 2); |
|
| 4113 | + // b from truecolor |
|
| 4114 | + |
|
| 4115 | + $transparency['type'] = 'color-key'; |
|
| 4116 | 4116 | |
| 4117 | - } else { |
|
| 4118 | - //unsupported transparency type |
|
| 4119 | - //debugpng |
|
| 4120 | - if (DEBUGPNG) print '[addPngFromFile unsupported transparency type '.$file.']'; |
|
| 4121 | - } |
|
| 4122 | - // KS End new code |
|
| 4123 | - break; |
|
| 4117 | + } else { |
|
| 4118 | + //unsupported transparency type |
|
| 4119 | + //debugpng |
|
| 4120 | + if (DEBUGPNG) print '[addPngFromFile unsupported transparency type '.$file.']'; |
|
| 4121 | + } |
|
| 4122 | + // KS End new code |
|
| 4123 | + break; |
|
| 4124 | 4124 | |
| 4125 | - default: |
|
| 4126 | - break; |
|
| 4125 | + default: |
|
| 4126 | + break; |
|
| 4127 | 4127 | } |
| 4128 | 4128 | |
| 4129 | 4129 | $p+= $chunkLen+12; |
@@ -4168,20 +4168,20 @@ discard block |
||
| 4168 | 4168 | $errormsg = 'transparancey alpha channel not supported, transparency only supported for palette images.'; |
| 4169 | 4169 | } else { |
| 4170 | 4170 | switch ($info['colorType']) { |
| 4171 | - case 3: |
|
| 4172 | - $color = 'DeviceRGB'; |
|
| 4173 | - $ncolor = 1; |
|
| 4174 | - break; |
|
| 4171 | + case 3: |
|
| 4172 | + $color = 'DeviceRGB'; |
|
| 4173 | + $ncolor = 1; |
|
| 4174 | + break; |
|
| 4175 | 4175 | |
| 4176 | - case 2: |
|
| 4177 | - $color = 'DeviceRGB'; |
|
| 4178 | - $ncolor = 3; |
|
| 4179 | - break; |
|
| 4176 | + case 2: |
|
| 4177 | + $color = 'DeviceRGB'; |
|
| 4178 | + $ncolor = 3; |
|
| 4179 | + break; |
|
| 4180 | 4180 | |
| 4181 | - case 0: |
|
| 4182 | - $color = 'DeviceGray'; |
|
| 4183 | - $ncolor = 1; |
|
| 4184 | - break; |
|
| 4181 | + case 0: |
|
| 4182 | + $color = 'DeviceGray'; |
|
| 4183 | + $ncolor = 1; |
|
| 4184 | + break; |
|
| 4185 | 4185 | } |
| 4186 | 4186 | } |
| 4187 | 4187 | } |
@@ -4469,48 +4469,48 @@ discard block |
||
| 4469 | 4469 | */ |
| 4470 | 4470 | function transaction($action) { |
| 4471 | 4471 | switch ($action) { |
| 4472 | - case 'start': |
|
| 4473 | - // store all the data away into the checkpoint variable |
|
| 4474 | - $data = get_object_vars($this); |
|
| 4475 | - $this->checkpoint = $data; |
|
| 4476 | - unset($data); |
|
| 4477 | - break; |
|
| 4472 | + case 'start': |
|
| 4473 | + // store all the data away into the checkpoint variable |
|
| 4474 | + $data = get_object_vars($this); |
|
| 4475 | + $this->checkpoint = $data; |
|
| 4476 | + unset($data); |
|
| 4477 | + break; |
|
| 4478 | 4478 | |
| 4479 | - case 'commit': |
|
| 4480 | - if (is_array($this->checkpoint) && isset($this->checkpoint['checkpoint'])) { |
|
| 4481 | - $tmp = $this->checkpoint['checkpoint']; |
|
| 4482 | - $this->checkpoint = $tmp; |
|
| 4483 | - unset($tmp); |
|
| 4484 | - } else { |
|
| 4485 | - $this->checkpoint = ''; |
|
| 4486 | - } |
|
| 4487 | - break; |
|
| 4479 | + case 'commit': |
|
| 4480 | + if (is_array($this->checkpoint) && isset($this->checkpoint['checkpoint'])) { |
|
| 4481 | + $tmp = $this->checkpoint['checkpoint']; |
|
| 4482 | + $this->checkpoint = $tmp; |
|
| 4483 | + unset($tmp); |
|
| 4484 | + } else { |
|
| 4485 | + $this->checkpoint = ''; |
|
| 4486 | + } |
|
| 4487 | + break; |
|
| 4488 | 4488 | |
| 4489 | - case 'rewind': |
|
| 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)) { |
|
| 4492 | - // can only abort if were inside a checkpoint |
|
| 4493 | - $tmp = $this->checkpoint; |
|
| 4489 | + case 'rewind': |
|
| 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)) { |
|
| 4492 | + // can only abort if were inside a checkpoint |
|
| 4493 | + $tmp = $this->checkpoint; |
|
| 4494 | 4494 | |
| 4495 | - foreach ($tmp as $k => $v) { |
|
| 4496 | - if ($k !== 'checkpoint') { |
|
| 4497 | - $this->$k = $v; |
|
| 4495 | + foreach ($tmp as $k => $v) { |
|
| 4496 | + if ($k !== 'checkpoint') { |
|
| 4497 | + $this->$k = $v; |
|
| 4498 | + } |
|
| 4499 | + } |
|
| 4500 | + unset($tmp); |
|
| 4498 | 4501 | } |
| 4499 | - } |
|
| 4500 | - unset($tmp); |
|
| 4501 | - } |
|
| 4502 | - break; |
|
| 4502 | + break; |
|
| 4503 | 4503 | |
| 4504 | - case 'abort': |
|
| 4505 | - if (is_array($this->checkpoint)) { |
|
| 4506 | - // can only abort if were inside a checkpoint |
|
| 4507 | - $tmp = $this->checkpoint; |
|
| 4508 | - foreach ($tmp as $k => $v) { |
|
| 4509 | - $this->$k = $v; |
|
| 4510 | - } |
|
| 4511 | - unset($tmp); |
|
| 4512 | - } |
|
| 4513 | - break; |
|
| 4504 | + case 'abort': |
|
| 4505 | + if (is_array($this->checkpoint)) { |
|
| 4506 | + // can only abort if were inside a checkpoint |
|
| 4507 | + $tmp = $this->checkpoint; |
|
| 4508 | + foreach ($tmp as $k => $v) { |
|
| 4509 | + $this->$k = $v; |
|
| 4510 | + } |
|
| 4511 | + unset($tmp); |
|
| 4512 | + } |
|
| 4513 | + break; |
|
| 4514 | 4514 | } |
| 4515 | 4515 | } |
| 4516 | 4516 | } |
@@ -186,19 +186,19 @@ |
||
| 186 | 186 | case self::CONVERTER_STATE: |
| 187 | 187 | $this->currentLiteral .= $c; |
| 188 | 188 | switch($c) { |
| 189 | - case '-': |
|
| 190 | - $this->formattingInfo->leftAlign = true; |
|
| 191 | - break; |
|
| 192 | - case '.': |
|
| 193 | - $this->state = self::DOT_STATE; |
|
| 194 | - break; |
|
| 195 | - default: |
|
| 196 | - if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
| 197 | - $this->formattingInfo->min = ord($c) - ord('0'); |
|
| 198 | - $this->state = self::MIN_STATE; |
|
| 199 | - } else { |
|
| 200 | - $this->finalizeConverter($c); |
|
| 201 | - } |
|
| 189 | + case '-': |
|
| 190 | + $this->formattingInfo->leftAlign = true; |
|
| 191 | + break; |
|
| 192 | + case '.': |
|
| 193 | + $this->state = self::DOT_STATE; |
|
| 194 | + break; |
|
| 195 | + default: |
|
| 196 | + if(ord($c) >= ord('0') and ord($c) <= ord('9')) { |
|
| 197 | + $this->formattingInfo->min = ord($c) - ord('0'); |
|
| 198 | + $this->state = self::MIN_STATE; |
|
| 199 | + } else { |
|
| 200 | + $this->finalizeConverter($c); |
|
| 201 | + } |
|
| 202 | 202 | } // switch |
| 203 | 203 | break; |
| 204 | 204 | case self::MIN_STATE: |
@@ -171,28 +171,52 @@ discard block |
||
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | switch ($action) { |
| 174 | - case 'subscribe_user_with_password': |
|
| 175 | - $courses_controller->subscribe_user( |
|
| 176 | - isset($_POST['subscribe_user_with_password']) ? $_POST['subscribe_user_with_password'] : '', |
|
| 177 | - isset($_POST['search_term']) ? $_POST['search_term'] : '', |
|
| 178 | - isset($_POST['category_code']) ? $_POST['category_code'] : '' |
|
| 179 | - ); |
|
| 180 | - break; |
|
| 181 | - case 'createcoursecategory': |
|
| 182 | - $courses_controller->categories_list($action); |
|
| 183 | - break; |
|
| 184 | - case 'deletecoursecategory': |
|
| 185 | - $courses_controller->courses_list($action); |
|
| 186 | - break; |
|
| 187 | - case 'sortmycourses': |
|
| 188 | - $courses_controller->courses_list($action); |
|
| 189 | - break; |
|
| 190 | - case 'subscribe': |
|
| 191 | - if (!$user_can_view_page) { |
|
| 192 | - api_not_allowed(true); |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - if (!CoursesAndSessionsCatalog::is(CATALOG_SESSIONS)) { |
|
| 174 | + case 'subscribe_user_with_password': |
|
| 175 | + $courses_controller->subscribe_user( |
|
| 176 | + isset($_POST['subscribe_user_with_password']) ? $_POST['subscribe_user_with_password'] : '', |
|
| 177 | + isset($_POST['search_term']) ? $_POST['search_term'] : '', |
|
| 178 | + isset($_POST['category_code']) ? $_POST['category_code'] : '' |
|
| 179 | + ); |
|
| 180 | + break; |
|
| 181 | + case 'createcoursecategory': |
|
| 182 | + $courses_controller->categories_list($action); |
|
| 183 | + break; |
|
| 184 | + case 'deletecoursecategory': |
|
| 185 | + $courses_controller->courses_list($action); |
|
| 186 | + break; |
|
| 187 | + case 'sortmycourses': |
|
| 188 | + $courses_controller->courses_list($action); |
|
| 189 | + break; |
|
| 190 | + case 'subscribe': |
|
| 191 | + if (!$user_can_view_page) { |
|
| 192 | + api_not_allowed(true); |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + if (!CoursesAndSessionsCatalog::is(CATALOG_SESSIONS)) { |
|
| 196 | + $courses_controller->courses_categories( |
|
| 197 | + $action, |
|
| 198 | + $categoryCode, |
|
| 199 | + null, |
|
| 200 | + null, |
|
| 201 | + null, |
|
| 202 | + $limit |
|
| 203 | + ); |
|
| 204 | + } else { |
|
| 205 | + header('Location: ' . api_get_self()); |
|
| 206 | + } |
|
| 207 | + break; |
|
| 208 | + case 'display_random_courses': |
|
| 209 | + if (!$user_can_view_page) { |
|
| 210 | + api_not_allowed(true); |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + $courses_controller->courses_categories($action); |
|
| 214 | + break; |
|
| 215 | + case 'display_courses': |
|
| 216 | + if (!$user_can_view_page) { |
|
| 217 | + api_not_allowed(true); |
|
| 218 | + } |
|
| 219 | + |
|
| 196 | 220 | $courses_controller->courses_categories( |
| 197 | 221 | $action, |
| 198 | 222 | $categoryCode, |
@@ -201,126 +225,102 @@ discard block |
||
| 201 | 225 | null, |
| 202 | 226 | $limit |
| 203 | 227 | ); |
| 204 | - } else { |
|
| 205 | - header('Location: ' . api_get_self()); |
|
| 206 | - } |
|
| 207 | - break; |
|
| 208 | - case 'display_random_courses': |
|
| 209 | - if (!$user_can_view_page) { |
|
| 210 | - api_not_allowed(true); |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - $courses_controller->courses_categories($action); |
|
| 214 | - break; |
|
| 215 | - case 'display_courses': |
|
| 216 | - if (!$user_can_view_page) { |
|
| 217 | - api_not_allowed(true); |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - $courses_controller->courses_categories( |
|
| 221 | - $action, |
|
| 222 | - $categoryCode, |
|
| 223 | - null, |
|
| 224 | - null, |
|
| 225 | - null, |
|
| 226 | - $limit |
|
| 227 | - ); |
|
| 228 | - break; |
|
| 229 | - case 'display_sessions': |
|
| 230 | - if (!$user_can_view_page) { |
|
| 231 | - api_not_allowed(true); |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - $courses_controller->sessionsList($action, $nameTools, $limit); |
|
| 235 | - break; |
|
| 236 | - case 'subscribe_to_session': |
|
| 237 | - if (!$user_can_view_page) { |
|
| 238 | - api_not_allowed(true); |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - $userId = api_get_user_id(); |
|
| 242 | - $confirmed = isset($_GET['confirm']); |
|
| 243 | - $sessionId = intval($_GET['session_id']); |
|
| 244 | - |
|
| 245 | - if (empty($userId)) { |
|
| 246 | - api_not_allowed(); |
|
| 247 | - exit; |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - if (!$confirmed) { |
|
| 251 | - $template = new Template(null, false, false, false, false, false); |
|
| 252 | - $template->assign('session_id', $sessionId); |
|
| 253 | - |
|
| 254 | - $layout = $template->get_template('auth/confirm_session_subscription.tpl'); |
|
| 255 | - |
|
| 256 | - echo $template->fetch($layout); |
|
| 257 | - exit; |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - $registrationAllowed = api_get_setting('catalog_allow_session_auto_subscription'); |
|
| 261 | - if ($registrationAllowed === 'true') { |
|
| 262 | - $entityManager = Database::getManager(); |
|
| 263 | - $repository = $entityManager->getRepository('ChamiloCoreBundle:SequenceResource'); |
|
| 264 | - |
|
| 265 | - $sequences = $repository->getRequirements( |
|
| 266 | - $sessionId, |
|
| 267 | - SequenceResource::SESSION_TYPE |
|
| 268 | - ); |
|
| 228 | + break; |
|
| 229 | + case 'display_sessions': |
|
| 230 | + if (!$user_can_view_page) { |
|
| 231 | + api_not_allowed(true); |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + $courses_controller->sessionsList($action, $nameTools, $limit); |
|
| 235 | + break; |
|
| 236 | + case 'subscribe_to_session': |
|
| 237 | + if (!$user_can_view_page) { |
|
| 238 | + api_not_allowed(true); |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + $userId = api_get_user_id(); |
|
| 242 | + $confirmed = isset($_GET['confirm']); |
|
| 243 | + $sessionId = intval($_GET['session_id']); |
|
| 269 | 244 | |
| 270 | - if (count($sequences) > 0) { |
|
| 271 | - $requirementsData = SequenceResourceManager::checkRequirementsForUser( |
|
| 272 | - $sequences, |
|
| 273 | - SequenceResource::SESSION_TYPE, |
|
| 274 | - $userId |
|
| 245 | + if (empty($userId)) { |
|
| 246 | + api_not_allowed(); |
|
| 247 | + exit; |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + if (!$confirmed) { |
|
| 251 | + $template = new Template(null, false, false, false, false, false); |
|
| 252 | + $template->assign('session_id', $sessionId); |
|
| 253 | + |
|
| 254 | + $layout = $template->get_template('auth/confirm_session_subscription.tpl'); |
|
| 255 | + |
|
| 256 | + echo $template->fetch($layout); |
|
| 257 | + exit; |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + $registrationAllowed = api_get_setting('catalog_allow_session_auto_subscription'); |
|
| 261 | + if ($registrationAllowed === 'true') { |
|
| 262 | + $entityManager = Database::getManager(); |
|
| 263 | + $repository = $entityManager->getRepository('ChamiloCoreBundle:SequenceResource'); |
|
| 264 | + |
|
| 265 | + $sequences = $repository->getRequirements( |
|
| 266 | + $sessionId, |
|
| 267 | + SequenceResource::SESSION_TYPE |
|
| 275 | 268 | ); |
| 276 | 269 | |
| 277 | - $continueWithSubscription = SequenceResourceManager::checkSequenceAreCompleted($requirementsData); |
|
| 270 | + if (count($sequences) > 0) { |
|
| 271 | + $requirementsData = SequenceResourceManager::checkRequirementsForUser( |
|
| 272 | + $sequences, |
|
| 273 | + SequenceResource::SESSION_TYPE, |
|
| 274 | + $userId |
|
| 275 | + ); |
|
| 276 | + |
|
| 277 | + $continueWithSubscription = SequenceResourceManager::checkSequenceAreCompleted($requirementsData); |
|
| 278 | 278 | |
| 279 | - if (!$continueWithSubscription) { |
|
| 280 | - header('Location: ' . api_get_path(WEB_CODE_PATH) . 'auth/courses.php'); |
|
| 281 | - exit; |
|
| 279 | + if (!$continueWithSubscription) { |
|
| 280 | + header('Location: ' . api_get_path(WEB_CODE_PATH) . 'auth/courses.php'); |
|
| 281 | + exit; |
|
| 282 | + } |
|
| 282 | 283 | } |
| 283 | - } |
|
| 284 | 284 | |
| 285 | - SessionManager::suscribe_users_to_session( |
|
| 286 | - $_GET['session_id'], |
|
| 287 | - array($userId), |
|
| 288 | - SESSION_VISIBLE_READ_ONLY, |
|
| 289 | - false |
|
| 290 | - ); |
|
| 285 | + SessionManager::suscribe_users_to_session( |
|
| 286 | + $_GET['session_id'], |
|
| 287 | + array($userId), |
|
| 288 | + SESSION_VISIBLE_READ_ONLY, |
|
| 289 | + false |
|
| 290 | + ); |
|
| 291 | 291 | |
| 292 | - $coursesList = SessionManager::get_course_list_by_session_id($_GET['session_id']); |
|
| 293 | - $count = count($coursesList); |
|
| 294 | - $url = ''; |
|
| 295 | - |
|
| 296 | - if ($count <= 0) { |
|
| 297 | - // no course in session -> return to catalog |
|
| 298 | - $url = api_get_path(WEB_CODE_PATH) . 'auth/courses.php'; |
|
| 299 | - } elseif ($count == 1) { |
|
| 300 | - // only one course, so redirect directly to this course |
|
| 301 | - foreach ($coursesList as $course) { |
|
| 302 | - $url = api_get_path(WEB_COURSE_PATH) . $course['directory'] . '/index.php?id_session=' . intval($_GET['session_id']); |
|
| 292 | + $coursesList = SessionManager::get_course_list_by_session_id($_GET['session_id']); |
|
| 293 | + $count = count($coursesList); |
|
| 294 | + $url = ''; |
|
| 295 | + |
|
| 296 | + if ($count <= 0) { |
|
| 297 | + // no course in session -> return to catalog |
|
| 298 | + $url = api_get_path(WEB_CODE_PATH) . 'auth/courses.php'; |
|
| 299 | + } elseif ($count == 1) { |
|
| 300 | + // only one course, so redirect directly to this course |
|
| 301 | + foreach ($coursesList as $course) { |
|
| 302 | + $url = api_get_path(WEB_COURSE_PATH) . $course['directory'] . '/index.php?id_session=' . intval($_GET['session_id']); |
|
| 303 | + } |
|
| 304 | + } else { |
|
| 305 | + $url = api_get_path(WEB_CODE_PATH) . 'session/index.php?session_id=' . intval($_GET['session_id']); |
|
| 303 | 306 | } |
| 304 | - } else { |
|
| 305 | - $url = api_get_path(WEB_CODE_PATH) . 'session/index.php?session_id=' . intval($_GET['session_id']); |
|
| 307 | + header('Location: ' . $url); |
|
| 308 | + exit; |
|
| 306 | 309 | } |
| 307 | - header('Location: ' . $url); |
|
| 308 | - exit; |
|
| 309 | - } |
|
| 310 | - //else show error message? |
|
| 311 | - break; |
|
| 312 | - case 'search_tag': |
|
| 313 | - if (!$user_can_view_page) { |
|
| 314 | - api_not_allowed(true); |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - $courses_controller->sessionsListByCoursesTag($limit); |
|
| 318 | - break; |
|
| 319 | - case 'search_session': |
|
| 320 | - if (!$user_can_view_page) { |
|
| 321 | - api_not_allowed(true); |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - $courses_controller->sessionListBySearch($limit); |
|
| 325 | - break; |
|
| 310 | + //else show error message? |
|
| 311 | + break; |
|
| 312 | + case 'search_tag': |
|
| 313 | + if (!$user_can_view_page) { |
|
| 314 | + api_not_allowed(true); |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + $courses_controller->sessionsListByCoursesTag($limit); |
|
| 318 | + break; |
|
| 319 | + case 'search_session': |
|
| 320 | + if (!$user_can_view_page) { |
|
| 321 | + api_not_allowed(true); |
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + $courses_controller->sessionListBySearch($limit); |
|
| 325 | + break; |
|
| 326 | 326 | } |