@@ -241,15 +241,14 @@ discard block |
||
| 241 | 241 | $this->DefOrientation = 'P'; |
| 242 | 242 | $this->w = $size[0]; |
| 243 | 243 | $this->h = $size[1]; |
| 244 | - } |
|
| 245 | - elseif($orientation=='l' || $orientation=='landscape') |
|
| 244 | + } elseif($orientation=='l' || $orientation=='landscape') |
|
| 246 | 245 | {
|
| 247 | 246 | $this->DefOrientation = 'L'; |
| 248 | 247 | $this->w = $size[1]; |
| 249 | 248 | $this->h = $size[0]; |
| 249 | + } else {
|
|
| 250 | + $this->Error('Incorrect orientation: '.$orientation);
|
|
| 250 | 251 | } |
| 251 | - else |
|
| 252 | - $this->Error('Incorrect orientation: '.$orientation);
|
|
| 253 | 252 | $this->CurOrientation = $this->DefOrientation; |
| 254 | 253 | $this->wPt = $this->w*$this->k; |
| 255 | 254 | $this->hPt = $this->h*$this->k; |
@@ -284,8 +283,9 @@ discard block |
||
| 284 | 283 | // Set left, top and right margins |
| 285 | 284 | $this->lMargin = $left; |
| 286 | 285 | $this->tMargin = $top; |
| 287 | - if($right===null) |
|
| 288 | - $right = $left; |
|
| 286 | + if($right===null) {
|
|
| 287 | + $right = $left; |
|
| 288 | + } |
|
| 289 | 289 | $this->rMargin = $right; |
| 290 | 290 | } |
| 291 | 291 | |
@@ -299,8 +299,9 @@ discard block |
||
| 299 | 299 | {
|
| 300 | 300 | // Set left margin |
| 301 | 301 | $this->lMargin = $margin; |
| 302 | - if($this->page>0 && $this->x<$margin) |
|
| 303 | - $this->x = $margin; |
|
| 302 | + if($this->page>0 && $this->x<$margin) {
|
|
| 303 | + $this->x = $margin; |
|
| 304 | + } |
|
| 304 | 305 | } |
| 305 | 306 | |
| 306 | 307 | /** |
@@ -372,14 +373,16 @@ discard block |
||
| 372 | 373 | public function SetDisplayMode($zoom, string $layout='default') : void |
| 373 | 374 | {
|
| 374 | 375 | // Set display mode in viewer |
| 375 | - if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) |
|
| 376 | - $this->ZoomMode = $zoom; |
|
| 377 | - else |
|
| 378 | - $this->Error('Incorrect zoom display mode: '.$zoom);
|
|
| 379 | - if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') |
|
| 380 | - $this->LayoutMode = $layout; |
|
| 381 | - else |
|
| 382 | - $this->Error('Incorrect layout display mode: '.$layout);
|
|
| 376 | + if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) {
|
|
| 377 | + $this->ZoomMode = $zoom; |
|
| 378 | + } else {
|
|
| 379 | + $this->Error('Incorrect zoom display mode: '.$zoom);
|
|
| 380 | + } |
|
| 381 | + if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') {
|
|
| 382 | + $this->LayoutMode = $layout; |
|
| 383 | + } else {
|
|
| 384 | + $this->Error('Incorrect layout display mode: '.$layout);
|
|
| 385 | + } |
|
| 383 | 386 | } |
| 384 | 387 | |
| 385 | 388 | /** |
@@ -394,10 +397,11 @@ discard block |
||
| 394 | 397 | public function SetCompression(bool $compress) : void |
| 395 | 398 | {
|
| 396 | 399 | // Set page compression |
| 397 | - if(function_exists('gzcompress'))
|
|
| 398 | - $this->compress = $compress; |
|
| 399 | - else |
|
| 400 | - $this->compress = false; |
|
| 400 | + if(function_exists('gzcompress')) {
|
|
| 401 | + $this->compress = $compress; |
|
| 402 | + } else {
|
|
| 403 | + $this->compress = false; |
|
| 404 | + } |
|
| 401 | 405 | } |
| 402 | 406 | |
| 403 | 407 | /** |
@@ -488,10 +492,12 @@ discard block |
||
| 488 | 492 | public function Close() : void |
| 489 | 493 | {
|
| 490 | 494 | // Terminate document |
| 491 | - if($this->state==3) |
|
| 492 | - return; |
|
| 493 | - if($this->page==0) |
|
| 494 | - $this->addPage(); |
|
| 495 | + if($this->state==3) {
|
|
| 496 | + return; |
|
| 497 | + } |
|
| 498 | + if($this->page==0) {
|
|
| 499 | + $this->addPage(); |
|
| 500 | + } |
|
| 495 | 501 | // Page footer |
| 496 | 502 | $this->InFooter = true; |
| 497 | 503 | $this->Footer(); |
@@ -533,8 +539,9 @@ discard block |
||
| 533 | 539 | public function AddPage(string $orientation='', $size='', int $rotation=0) : void |
| 534 | 540 | {
|
| 535 | 541 | // Start a new page |
| 536 | - if($this->state==3) |
|
| 537 | - $this->Error('The document is closed');
|
|
| 542 | + if($this->state==3) {
|
|
| 543 | + $this->Error('The document is closed');
|
|
| 544 | + } |
|
| 538 | 545 | $family = $this->FontFamily; |
| 539 | 546 | $style = $this->FontStyle.($this->underline ? 'U' : ''); |
| 540 | 547 | $fontsize = $this->FontSizePt; |
@@ -560,15 +567,18 @@ discard block |
||
| 560 | 567 | $this->LineWidth = $lw; |
| 561 | 568 | $this->_out(sprintf('%.2F w',$lw*$this->k));
|
| 562 | 569 | // Set font |
| 563 | - if($family) |
|
| 564 | - $this->setFont($family,$style,$fontsize); |
|
| 570 | + if($family) {
|
|
| 571 | + $this->setFont($family,$style,$fontsize); |
|
| 572 | + } |
|
| 565 | 573 | // Set colors |
| 566 | 574 | $this->DrawColor = $dc; |
| 567 | - if($dc!='0 G') |
|
| 568 | - $this->_out($dc); |
|
| 575 | + if($dc!='0 G') {
|
|
| 576 | + $this->_out($dc); |
|
| 577 | + } |
|
| 569 | 578 | $this->FillColor = $fc; |
| 570 | - if($fc!='0 g') |
|
| 571 | - $this->_out($fc); |
|
| 579 | + if($fc!='0 g') {
|
|
| 580 | + $this->_out($fc); |
|
| 581 | + } |
|
| 572 | 582 | $this->TextColor = $tc; |
| 573 | 583 | $this->ColorFlag = $cf; |
| 574 | 584 | // Page header |
@@ -582,8 +592,9 @@ discard block |
||
| 582 | 592 | $this->_out(sprintf('%.2F w',$lw*$this->k));
|
| 583 | 593 | } |
| 584 | 594 | // Restore font |
| 585 | - if($family) |
|
| 586 | - $this->setFont($family,$style,$fontsize); |
|
| 595 | + if($family) {
|
|
| 596 | + $this->setFont($family,$style,$fontsize); |
|
| 597 | + } |
|
| 587 | 598 | // Restore colors |
| 588 | 599 | if($this->DrawColor!=$dc) |
| 589 | 600 | {
|
@@ -706,8 +717,9 @@ discard block |
||
| 706 | 717 | $cw = &$this->CurrentFont['cw']; |
| 707 | 718 | $w = 0; |
| 708 | 719 | $l = strlen($s); |
| 709 | - for($i=0;$i<$l;$i++) |
|
| 710 | - $w += $cw[$s[$i]]; |
|
| 720 | + for($i=0;$i<$l;$i++) {
|
|
| 721 | + $w += $cw[$s[$i]]; |
|
| 722 | + } |
|
| 711 | 723 | return $w*$this->FontSize/1000; |
| 712 | 724 | } |
| 713 | 725 | |
@@ -721,8 +733,9 @@ discard block |
||
| 721 | 733 | {
|
| 722 | 734 | // Set line width |
| 723 | 735 | $this->LineWidth = $width; |
| 724 | - if($this->page>0) |
|
| 725 | - $this->_out(sprintf('%.2F w',$width*$this->k));
|
|
| 736 | + if($this->page>0) {
|
|
| 737 | + $this->_out(sprintf('%.2F w',$width*$this->k));
|
|
| 738 | + } |
|
| 726 | 739 | } |
| 727 | 740 | |
| 728 | 741 | /** |
@@ -758,12 +771,13 @@ discard block |
||
| 758 | 771 | public function Rect(float $x, float $y, float $w, float $h, string $style='') : void |
| 759 | 772 | {
|
| 760 | 773 | // Draw a rectangle |
| 761 | - if($style=='F') |
|
| 762 | - $op = 'f'; |
|
| 763 | - elseif($style=='FD' || $style=='DF') |
|
| 764 | - $op = 'B'; |
|
| 765 | - else |
|
| 766 | - $op = 'S'; |
|
| 774 | + if($style=='F') {
|
|
| 775 | + $op = 'f'; |
|
| 776 | + } elseif($style=='FD' || $style=='DF') {
|
|
| 777 | + $op = 'B'; |
|
| 778 | + } else {
|
|
| 779 | + $op = 'S'; |
|
| 780 | + } |
|
| 767 | 781 | $this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op));
|
| 768 | 782 | } |
| 769 | 783 | |
@@ -788,23 +802,27 @@ discard block |
||
| 788 | 802 | {
|
| 789 | 803 | // Add a TrueType, OpenType or Type1 font |
| 790 | 804 | $family = strtolower($family); |
| 791 | - if($file=='') |
|
| 792 | - $file = str_replace(' ','',$family).strtolower($style).'.php';
|
|
| 805 | + if($file=='') {
|
|
| 806 | + $file = str_replace(' ','',$family).strtolower($style).'.php';
|
|
| 807 | + } |
|
| 793 | 808 | $style = strtoupper($style); |
| 794 | - if($style=='IB') |
|
| 795 | - $style = 'BI'; |
|
| 809 | + if($style=='IB') {
|
|
| 810 | + $style = 'BI'; |
|
| 811 | + } |
|
| 796 | 812 | $fontkey = $family.$style; |
| 797 | - if(isset($this->fonts[$fontkey])) |
|
| 798 | - return; |
|
| 813 | + if(isset($this->fonts[$fontkey])) {
|
|
| 814 | + return; |
|
| 815 | + } |
|
| 799 | 816 | $info = $this->_loadfont($file); |
| 800 | 817 | $info['i'] = count($this->fonts)+1; |
| 801 | 818 | if(!empty($info['file'])) |
| 802 | 819 | {
|
| 803 | 820 | // Embedded font |
| 804 | - if($info['type']=='TrueType') |
|
| 805 | - $this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']);
|
|
| 806 | - else |
|
| 807 | - $this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']);
|
|
| 821 | + if($info['type']=='TrueType') {
|
|
| 822 | + $this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']);
|
|
| 823 | + } else {
|
|
| 824 | + $this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']);
|
|
| 825 | + } |
|
| 808 | 826 | } |
| 809 | 827 | $this->fonts[$fontkey] = $info; |
| 810 | 828 | } |
@@ -847,42 +865,49 @@ discard block |
||
| 847 | 865 | public function SetFont(string $family, string $style='', float $size=0) : void |
| 848 | 866 | {
|
| 849 | 867 | // Select a font; size given in points |
| 850 | - if($family=='') |
|
| 851 | - $family = $this->FontFamily; |
|
| 852 | - else |
|
| 853 | - $family = strtolower($family); |
|
| 868 | + if($family=='') {
|
|
| 869 | + $family = $this->FontFamily; |
|
| 870 | + } else {
|
|
| 871 | + $family = strtolower($family); |
|
| 872 | + } |
|
| 854 | 873 | $style = strtoupper($style); |
| 855 | 874 | if(strpos($style,'U')!==false) |
| 856 | 875 | {
|
| 857 | 876 | $this->underline = true; |
| 858 | 877 | $style = str_replace('U','',$style);
|
| 878 | + } else {
|
|
| 879 | + $this->underline = false; |
|
| 880 | + } |
|
| 881 | + if($style=='IB') {
|
|
| 882 | + $style = 'BI'; |
|
| 883 | + } |
|
| 884 | + if($size==0) {
|
|
| 885 | + $size = $this->FontSizePt; |
|
| 859 | 886 | } |
| 860 | - else |
|
| 861 | - $this->underline = false; |
|
| 862 | - if($style=='IB') |
|
| 863 | - $style = 'BI'; |
|
| 864 | - if($size==0) |
|
| 865 | - $size = $this->FontSizePt; |
|
| 866 | 887 | // Test if font is already selected |
| 867 | - if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) |
|
| 868 | - return; |
|
| 888 | + if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) {
|
|
| 889 | + return; |
|
| 890 | + } |
|
| 869 | 891 | // Test if font is already loaded |
| 870 | 892 | $fontkey = $family.$style; |
| 871 | 893 | if(!isset($this->fonts[$fontkey])) |
| 872 | 894 | {
|
| 873 | 895 | // Test if one of the core fonts |
| 874 | - if($family=='arial') |
|
| 875 | - $family = 'helvetica'; |
|
| 896 | + if($family=='arial') {
|
|
| 897 | + $family = 'helvetica'; |
|
| 898 | + } |
|
| 876 | 899 | if(in_array($family,$this->CoreFonts)) |
| 877 | 900 | {
|
| 878 | - if($family=='symbol' || $family=='zapfdingbats') |
|
| 879 | - $style = ''; |
|
| 901 | + if($family=='symbol' || $family=='zapfdingbats') {
|
|
| 902 | + $style = ''; |
|
| 903 | + } |
|
| 880 | 904 | $fontkey = $family.$style; |
| 881 | - if(!isset($this->fonts[$fontkey])) |
|
| 882 | - $this->addFont($family,$style); |
|
| 905 | + if(!isset($this->fonts[$fontkey])) {
|
|
| 906 | + $this->addFont($family,$style); |
|
| 907 | + } |
|
| 908 | + } else {
|
|
| 909 | + $this->Error('Undefined font: '.$family.' '.$style);
|
|
| 883 | 910 | } |
| 884 | - else |
|
| 885 | - $this->Error('Undefined font: '.$family.' '.$style);
|
|
| 886 | 911 | } |
| 887 | 912 | // Select it |
| 888 | 913 | $this->FontFamily = $family; |
@@ -890,8 +915,9 @@ discard block |
||
| 890 | 915 | $this->FontSizePt = $size; |
| 891 | 916 | $this->FontSize = $size/$this->k; |
| 892 | 917 | $this->CurrentFont = &$this->fonts[$fontkey]; |
| 893 | - if($this->page>0) |
|
| 894 | - $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
|
|
| 918 | + if($this->page>0) {
|
|
| 919 | + $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
|
|
| 920 | + } |
|
| 895 | 921 | } |
| 896 | 922 | |
| 897 | 923 | /** |
@@ -901,12 +927,14 @@ discard block |
||
| 901 | 927 | public function SetFontSize(float $size) : void |
| 902 | 928 | {
|
| 903 | 929 | // Set font size in points |
| 904 | - if($this->FontSizePt==$size) |
|
| 905 | - return; |
|
| 930 | + if($this->FontSizePt==$size) {
|
|
| 931 | + return; |
|
| 932 | + } |
|
| 906 | 933 | $this->FontSizePt = $size; |
| 907 | 934 | $this->FontSize = $size/$this->k; |
| 908 | - if($this->page>0) |
|
| 909 | - $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
|
|
| 935 | + if($this->page>0) {
|
|
| 936 | + $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt));
|
|
| 937 | + } |
|
| 910 | 938 | } |
| 911 | 939 | |
| 912 | 940 | /** |
@@ -933,10 +961,12 @@ discard block |
||
| 933 | 961 | public function SetLink(int $link, float $y=0, int $page=-1) : void |
| 934 | 962 | {
|
| 935 | 963 | // Set destination of internal link |
| 936 | - if($y==-1) |
|
| 937 | - $y = $this->y; |
|
| 938 | - if($page==-1) |
|
| 939 | - $page = $this->page; |
|
| 964 | + if($y==-1) {
|
|
| 965 | + $y = $this->y; |
|
| 966 | + } |
|
| 967 | + if($page==-1) {
|
|
| 968 | + $page = $this->page; |
|
| 969 | + } |
|
| 940 | 970 | $this->links[$link] = array($page, $y); |
| 941 | 971 | } |
| 942 | 972 | |
@@ -970,13 +1000,16 @@ discard block |
||
| 970 | 1000 | public function Text(float $x, float $y, string $txt) : void |
| 971 | 1001 | {
|
| 972 | 1002 | // Output a string |
| 973 | - if(!isset($this->CurrentFont)) |
|
| 974 | - $this->Error('No font has been set');
|
|
| 1003 | + if(!isset($this->CurrentFont)) {
|
|
| 1004 | + $this->Error('No font has been set');
|
|
| 1005 | + } |
|
| 975 | 1006 | $s = sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt));
|
| 976 | - if($this->underline && $txt!='') |
|
| 977 | - $s .= ' '.$this->_dounderline($x,$y,$txt); |
|
| 978 | - if($this->ColorFlag) |
|
| 979 | - $s = 'q '.$this->TextColor.' '.$s.' Q'; |
|
| 1007 | + if($this->underline && $txt!='') {
|
|
| 1008 | + $s .= ' '.$this->_dounderline($x,$y,$txt); |
|
| 1009 | + } |
|
| 1010 | + if($this->ColorFlag) {
|
|
| 1011 | + $s = 'q '.$this->TextColor.' '.$s.' Q'; |
|
| 1012 | + } |
|
| 980 | 1013 | $this->_out($s); |
| 981 | 1014 | } |
| 982 | 1015 | |
@@ -1056,62 +1089,76 @@ discard block |
||
| 1056 | 1089 | $this->_out(sprintf('%.3F Tw',$ws*$k));
|
| 1057 | 1090 | } |
| 1058 | 1091 | } |
| 1059 | - if($w==0) |
|
| 1060 | - $w = $this->w-$this->rMargin-$this->x; |
|
| 1092 | + if($w==0) {
|
|
| 1093 | + $w = $this->w-$this->rMargin-$this->x; |
|
| 1094 | + } |
|
| 1061 | 1095 | $s = ''; |
| 1062 | 1096 | if($fill || $border==1) |
| 1063 | 1097 | {
|
| 1064 | - if($fill) |
|
| 1065 | - $op = ($border==1) ? 'B' : 'f'; |
|
| 1066 | - else |
|
| 1067 | - $op = 'S'; |
|
| 1098 | + if($fill) {
|
|
| 1099 | + $op = ($border==1) ? 'B' : 'f'; |
|
| 1100 | + } else {
|
|
| 1101 | + $op = 'S'; |
|
| 1102 | + } |
|
| 1068 | 1103 | $s = sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op);
|
| 1069 | 1104 | } |
| 1070 | 1105 | if(is_string($border)) |
| 1071 | 1106 | {
|
| 1072 | 1107 | $x = $this->x; |
| 1073 | 1108 | $y = $this->y; |
| 1074 | - if(strpos($border,'L')!==false) |
|
| 1075 | - $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);
|
|
| 1076 | - if(strpos($border,'T')!==false) |
|
| 1077 | - $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);
|
|
| 1078 | - if(strpos($border,'R')!==false) |
|
| 1079 | - $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
|
|
| 1080 | - if(strpos($border,'B')!==false) |
|
| 1081 | - $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
|
|
| 1109 | + if(strpos($border,'L')!==false) {
|
|
| 1110 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);
|
|
| 1111 | + } |
|
| 1112 | + if(strpos($border,'T')!==false) {
|
|
| 1113 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);
|
|
| 1114 | + } |
|
| 1115 | + if(strpos($border,'R')!==false) {
|
|
| 1116 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
|
|
| 1117 | + } |
|
| 1118 | + if(strpos($border,'B')!==false) {
|
|
| 1119 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
|
|
| 1120 | + } |
|
| 1082 | 1121 | } |
| 1083 | 1122 | if($txt!=='') |
| 1084 | 1123 | {
|
| 1085 | - if(!isset($this->CurrentFont)) |
|
| 1086 | - $this->Error('No font has been set');
|
|
| 1087 | - if($align=='R') |
|
| 1088 | - $dx = $w-$this->cMargin-$this->getStringWidth($txt); |
|
| 1089 | - elseif($align=='C') |
|
| 1090 | - $dx = ($w-$this->getStringWidth($txt))/2; |
|
| 1091 | - else |
|
| 1092 | - $dx = $this->cMargin; |
|
| 1093 | - if($this->ColorFlag) |
|
| 1094 | - $s .= 'q '.$this->TextColor.' '; |
|
| 1124 | + if(!isset($this->CurrentFont)) {
|
|
| 1125 | + $this->Error('No font has been set');
|
|
| 1126 | + } |
|
| 1127 | + if($align=='R') {
|
|
| 1128 | + $dx = $w-$this->cMargin-$this->getStringWidth($txt); |
|
| 1129 | + } elseif($align=='C') {
|
|
| 1130 | + $dx = ($w-$this->getStringWidth($txt))/2; |
|
| 1131 | + } else {
|
|
| 1132 | + $dx = $this->cMargin; |
|
| 1133 | + } |
|
| 1134 | + if($this->ColorFlag) {
|
|
| 1135 | + $s .= 'q '.$this->TextColor.' '; |
|
| 1136 | + } |
|
| 1095 | 1137 | $s .= sprintf('BT %.2F %.2F Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$this->_escape($txt));
|
| 1096 | - if($this->underline) |
|
| 1097 | - $s .= ' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); |
|
| 1098 | - if($this->ColorFlag) |
|
| 1099 | - $s .= ' Q'; |
|
| 1100 | - if($link) |
|
| 1101 | - $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->getStringWidth($txt),$this->FontSize,$link); |
|
| 1102 | - } |
|
| 1103 | - if($s) |
|
| 1104 | - $this->_out($s); |
|
| 1138 | + if($this->underline) {
|
|
| 1139 | + $s .= ' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); |
|
| 1140 | + } |
|
| 1141 | + if($this->ColorFlag) {
|
|
| 1142 | + $s .= ' Q'; |
|
| 1143 | + } |
|
| 1144 | + if($link) {
|
|
| 1145 | + $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->getStringWidth($txt),$this->FontSize,$link); |
|
| 1146 | + } |
|
| 1147 | + } |
|
| 1148 | + if($s) {
|
|
| 1149 | + $this->_out($s); |
|
| 1150 | + } |
|
| 1105 | 1151 | $this->lasth = $h; |
| 1106 | 1152 | if($ln>0) |
| 1107 | 1153 | {
|
| 1108 | 1154 | // Go to next line |
| 1109 | 1155 | $this->y += $h; |
| 1110 | - if($ln==1) |
|
| 1111 | - $this->x = $this->lMargin; |
|
| 1156 | + if($ln==1) {
|
|
| 1157 | + $this->x = $this->lMargin; |
|
| 1158 | + } |
|
| 1159 | + } else {
|
|
| 1160 | + $this->x += $w; |
|
| 1112 | 1161 | } |
| 1113 | - else |
|
| 1114 | - $this->x += $w; |
|
| 1115 | 1162 | } |
| 1116 | 1163 | |
| 1117 | 1164 | /** |
@@ -1145,16 +1192,19 @@ discard block |
||
| 1145 | 1192 | public function MultiCell(float $w, float $h, string $txt, $border=0, string $align='J', bool $fill=false) : void |
| 1146 | 1193 | {
|
| 1147 | 1194 | // Output text with automatic or explicit line breaks |
| 1148 | - if(!isset($this->CurrentFont)) |
|
| 1149 | - $this->Error('No font has been set');
|
|
| 1195 | + if(!isset($this->CurrentFont)) {
|
|
| 1196 | + $this->Error('No font has been set');
|
|
| 1197 | + } |
|
| 1150 | 1198 | $cw = &$this->CurrentFont['cw']; |
| 1151 | - if($w==0) |
|
| 1152 | - $w = $this->w-$this->rMargin-$this->x; |
|
| 1199 | + if($w==0) {
|
|
| 1200 | + $w = $this->w-$this->rMargin-$this->x; |
|
| 1201 | + } |
|
| 1153 | 1202 | $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; |
| 1154 | 1203 | $s = str_replace("\r",'',$txt);
|
| 1155 | 1204 | $nb = strlen($s); |
| 1156 | - if($nb>0 && $s[$nb-1]=="\n") |
|
| 1157 | - $nb--; |
|
| 1205 | + if($nb>0 && $s[$nb-1]=="\n") {
|
|
| 1206 | + $nb--; |
|
| 1207 | + } |
|
| 1158 | 1208 | $b = 0; |
| 1159 | 1209 | $b2 = ''; |
| 1160 | 1210 | if($border) |
@@ -1164,14 +1214,15 @@ discard block |
||
| 1164 | 1214 | $border = 'LTRB'; |
| 1165 | 1215 | $b = 'LRT'; |
| 1166 | 1216 | $b2 = 'LR'; |
| 1167 | - } |
|
| 1168 | - else |
|
| 1217 | + } else |
|
| 1169 | 1218 | {
|
| 1170 | 1219 | $b2 = ''; |
| 1171 | - if(strpos($border,'L')!==false) |
|
| 1172 | - $b2 .= 'L'; |
|
| 1173 | - if(strpos($border,'R')!==false) |
|
| 1174 | - $b2 .= 'R'; |
|
| 1220 | + if(strpos($border,'L')!==false) {
|
|
| 1221 | + $b2 .= 'L'; |
|
| 1222 | + } |
|
| 1223 | + if(strpos($border,'R')!==false) {
|
|
| 1224 | + $b2 .= 'R'; |
|
| 1225 | + } |
|
| 1175 | 1226 | $b = (strpos($border,'T')!==false) ? $b2.'T' : $b2; |
| 1176 | 1227 | } |
| 1177 | 1228 | } |
@@ -1201,8 +1252,9 @@ discard block |
||
| 1201 | 1252 | $l = 0; |
| 1202 | 1253 | $ns = 0; |
| 1203 | 1254 | $nl++; |
| 1204 | - if($border && $nl==2) |
|
| 1205 | - $b = $b2; |
|
| 1255 | + if($border && $nl==2) {
|
|
| 1256 | + $b = $b2; |
|
| 1257 | + } |
|
| 1206 | 1258 | continue; |
| 1207 | 1259 | } |
| 1208 | 1260 | if($c==' ') |
@@ -1217,16 +1269,16 @@ discard block |
||
| 1217 | 1269 | // Automatic line break |
| 1218 | 1270 | if($sep==-1) |
| 1219 | 1271 | {
|
| 1220 | - if($i==$j) |
|
| 1221 | - $i++; |
|
| 1272 | + if($i==$j) {
|
|
| 1273 | + $i++; |
|
| 1274 | + } |
|
| 1222 | 1275 | if($this->ws>0) |
| 1223 | 1276 | {
|
| 1224 | 1277 | $this->ws = 0; |
| 1225 | 1278 | $this->_out('0 Tw');
|
| 1226 | 1279 | } |
| 1227 | 1280 | $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
| 1228 | - } |
|
| 1229 | - else |
|
| 1281 | + } else |
|
| 1230 | 1282 | {
|
| 1231 | 1283 | if($align=='J') |
| 1232 | 1284 | {
|
@@ -1241,11 +1293,12 @@ discard block |
||
| 1241 | 1293 | $l = 0; |
| 1242 | 1294 | $ns = 0; |
| 1243 | 1295 | $nl++; |
| 1244 | - if($border && $nl==2) |
|
| 1245 | - $b = $b2; |
|
| 1296 | + if($border && $nl==2) {
|
|
| 1297 | + $b = $b2; |
|
| 1298 | + } |
|
| 1299 | + } else {
|
|
| 1300 | + $i++; |
|
| 1246 | 1301 | } |
| 1247 | - else |
|
| 1248 | - $i++; |
|
| 1249 | 1302 | } |
| 1250 | 1303 | // Last chunk |
| 1251 | 1304 | if($this->ws>0) |
@@ -1253,8 +1306,9 @@ discard block |
||
| 1253 | 1306 | $this->ws = 0; |
| 1254 | 1307 | $this->_out('0 Tw');
|
| 1255 | 1308 | } |
| 1256 | - if($border && strpos($border,'B')!==false) |
|
| 1257 | - $b .= 'B'; |
|
| 1309 | + if($border && strpos($border,'B')!==false) {
|
|
| 1310 | + $b .= 'B'; |
|
| 1311 | + } |
|
| 1258 | 1312 | $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
| 1259 | 1313 | $this->x = $this->lMargin; |
| 1260 | 1314 | } |
@@ -1272,8 +1326,9 @@ discard block |
||
| 1272 | 1326 | public function Write(float $h, string $txt, $link='') : void |
| 1273 | 1327 | {
|
| 1274 | 1328 | // Output text in flowing mode |
| 1275 | - if(!isset($this->CurrentFont)) |
|
| 1276 | - $this->Error('No font has been set');
|
|
| 1329 | + if(!isset($this->CurrentFont)) {
|
|
| 1330 | + $this->Error('No font has been set');
|
|
| 1331 | + } |
|
| 1277 | 1332 | $cw = &$this->CurrentFont['cw']; |
| 1278 | 1333 | $w = $this->w-$this->rMargin-$this->x; |
| 1279 | 1334 | $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; |
@@ -1305,8 +1360,9 @@ discard block |
||
| 1305 | 1360 | $nl++; |
| 1306 | 1361 | continue; |
| 1307 | 1362 | } |
| 1308 | - if($c==' ') |
|
| 1309 | - $sep = $i; |
|
| 1363 | + if($c==' ') {
|
|
| 1364 | + $sep = $i; |
|
| 1365 | + } |
|
| 1310 | 1366 | $l += $cw[$c]; |
| 1311 | 1367 | if($l>$wmax) |
| 1312 | 1368 | {
|
@@ -1324,11 +1380,11 @@ discard block |
||
| 1324 | 1380 | $nl++; |
| 1325 | 1381 | continue; |
| 1326 | 1382 | } |
| 1327 | - if($i==$j) |
|
| 1328 | - $i++; |
|
| 1383 | + if($i==$j) {
|
|
| 1384 | + $i++; |
|
| 1385 | + } |
|
| 1329 | 1386 | $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',false,$link); |
| 1330 | - } |
|
| 1331 | - else |
|
| 1387 | + } else |
|
| 1332 | 1388 | {
|
| 1333 | 1389 | $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',false,$link); |
| 1334 | 1390 | $i = $sep+1; |
@@ -1343,13 +1399,14 @@ discard block |
||
| 1343 | 1399 | $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; |
| 1344 | 1400 | } |
| 1345 | 1401 | $nl++; |
| 1402 | + } else {
|
|
| 1403 | + $i++; |
|
| 1346 | 1404 | } |
| 1347 | - else |
|
| 1348 | - $i++; |
|
| 1349 | 1405 | } |
| 1350 | 1406 | // Last chunk |
| 1351 | - if($i!=$j) |
|
| 1352 | - $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',false,$link); |
|
| 1407 | + if($i!=$j) {
|
|
| 1408 | + $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',false,$link); |
|
| 1409 | + } |
|
| 1353 | 1410 | } |
| 1354 | 1411 | |
| 1355 | 1412 | /** |
@@ -1363,10 +1420,11 @@ discard block |
||
| 1363 | 1420 | {
|
| 1364 | 1421 | // Line feed; default value is the last cell height |
| 1365 | 1422 | $this->x = $this->lMargin; |
| 1366 | - if($h===null) |
|
| 1367 | - $this->y += $this->lasth; |
|
| 1368 | - else |
|
| 1369 | - $this->y += $h; |
|
| 1423 | + if($h===null) {
|
|
| 1424 | + $this->y += $this->lasth; |
|
| 1425 | + } else {
|
|
| 1426 | + $this->y += $h; |
|
| 1427 | + } |
|
| 1370 | 1428 | } |
| 1371 | 1429 | |
| 1372 | 1430 | /** |
@@ -1418,30 +1476,34 @@ discard block |
||
| 1418 | 1476 | public function Image(string $file, ?float $x=null, ?float $y=null, float $w=0, float $h=0, string $type='', $link='') : void |
| 1419 | 1477 | {
|
| 1420 | 1478 | // Put an image on the page |
| 1421 | - if($file=='') |
|
| 1422 | - $this->Error('Image file name is empty');
|
|
| 1479 | + if($file=='') {
|
|
| 1480 | + $this->Error('Image file name is empty');
|
|
| 1481 | + } |
|
| 1423 | 1482 | if(!isset($this->images[$file])) |
| 1424 | 1483 | {
|
| 1425 | 1484 | // First use of this image, get info |
| 1426 | 1485 | if($type=='') |
| 1427 | 1486 | {
|
| 1428 | 1487 | $pos = strrpos($file,'.'); |
| 1429 | - if(!$pos) |
|
| 1430 | - $this->Error('Image file has no extension and no type was specified: '.$file);
|
|
| 1488 | + if(!$pos) {
|
|
| 1489 | + $this->Error('Image file has no extension and no type was specified: '.$file);
|
|
| 1490 | + } |
|
| 1431 | 1491 | $type = substr($file,$pos+1); |
| 1432 | 1492 | } |
| 1433 | 1493 | $type = strtolower($type); |
| 1434 | - if($type=='jpeg') |
|
| 1435 | - $type = 'jpg'; |
|
| 1494 | + if($type=='jpeg') {
|
|
| 1495 | + $type = 'jpg'; |
|
| 1496 | + } |
|
| 1436 | 1497 | $mtd = '_parse'.$type; |
| 1437 | - if(!method_exists($this,$mtd)) |
|
| 1438 | - $this->Error('Unsupported image type: '.$type);
|
|
| 1498 | + if(!method_exists($this,$mtd)) {
|
|
| 1499 | + $this->Error('Unsupported image type: '.$type);
|
|
| 1500 | + } |
|
| 1439 | 1501 | $info = $this->$mtd($file); |
| 1440 | 1502 | $info['i'] = count($this->images)+1; |
| 1441 | 1503 | $this->images[$file] = $info; |
| 1504 | + } else {
|
|
| 1505 | + $info = $this->images[$file]; |
|
| 1442 | 1506 | } |
| 1443 | - else |
|
| 1444 | - $info = $this->images[$file]; |
|
| 1445 | 1507 | |
| 1446 | 1508 | // Automatic width and height calculation if needed |
| 1447 | 1509 | if($w==0 && $h==0) |
@@ -1450,14 +1512,18 @@ discard block |
||
| 1450 | 1512 | $w = -96; |
| 1451 | 1513 | $h = -96; |
| 1452 | 1514 | } |
| 1453 | - if($w<0) |
|
| 1454 | - $w = -$info['w']*72/$w/$this->k; |
|
| 1455 | - if($h<0) |
|
| 1456 | - $h = -$info['h']*72/$h/$this->k; |
|
| 1457 | - if($w==0) |
|
| 1458 | - $w = $h*$info['w']/$info['h']; |
|
| 1459 | - if($h==0) |
|
| 1460 | - $h = $w*$info['h']/$info['w']; |
|
| 1515 | + if($w<0) {
|
|
| 1516 | + $w = -$info['w']*72/$w/$this->k; |
|
| 1517 | + } |
|
| 1518 | + if($h<0) {
|
|
| 1519 | + $h = -$info['h']*72/$h/$this->k; |
|
| 1520 | + } |
|
| 1521 | + if($w==0) {
|
|
| 1522 | + $w = $h*$info['w']/$info['h']; |
|
| 1523 | + } |
|
| 1524 | + if($h==0) {
|
|
| 1525 | + $h = $w*$info['h']/$info['w']; |
|
| 1526 | + } |
|
| 1461 | 1527 | |
| 1462 | 1528 | // Flowing mode |
| 1463 | 1529 | if($y===null) |
@@ -1473,11 +1539,13 @@ discard block |
||
| 1473 | 1539 | $this->y += $h; |
| 1474 | 1540 | } |
| 1475 | 1541 | |
| 1476 | - if($x===null) |
|
| 1477 | - $x = $this->x; |
|
| 1542 | + if($x===null) {
|
|
| 1543 | + $x = $this->x; |
|
| 1544 | + } |
|
| 1478 | 1545 | $this->_out(sprintf('q %.2F 0 0 %.2F %.2F %.2F cm /I%d Do Q',$w*$this->k,$h*$this->k,$x*$this->k,($this->h-($y+$h))*$this->k,$info['i']));
|
| 1479 | - if($link) |
|
| 1480 | - $this->Link($x,$y,$w,$h,$link); |
|
| 1546 | + if($link) {
|
|
| 1547 | + $this->Link($x,$y,$w,$h,$link); |
|
| 1548 | + } |
|
| 1481 | 1549 | } |
| 1482 | 1550 | |
| 1483 | 1551 | /** |
@@ -1518,10 +1586,11 @@ discard block |
||
| 1518 | 1586 | public function SetX(float $x) : void |
| 1519 | 1587 | {
|
| 1520 | 1588 | // Set x position |
| 1521 | - if($x>=0) |
|
| 1522 | - $this->x = $x; |
|
| 1523 | - else |
|
| 1524 | - $this->x = $this->w+$x; |
|
| 1589 | + if($x>=0) {
|
|
| 1590 | + $this->x = $x; |
|
| 1591 | + } else {
|
|
| 1592 | + $this->x = $this->w+$x; |
|
| 1593 | + } |
|
| 1525 | 1594 | } |
| 1526 | 1595 | |
| 1527 | 1596 | /** |
@@ -1543,12 +1612,14 @@ discard block |
||
| 1543 | 1612 | public function SetY(float $y, bool $resetX=true) : void |
| 1544 | 1613 | {
|
| 1545 | 1614 | // Set y position and optionally reset x |
| 1546 | - if($y>=0) |
|
| 1547 | - $this->y = $y; |
|
| 1548 | - else |
|
| 1549 | - $this->y = $this->h+$y; |
|
| 1550 | - if($resetX) |
|
| 1551 | - $this->x = $this->lMargin; |
|
| 1615 | + if($y>=0) {
|
|
| 1616 | + $this->y = $y; |
|
| 1617 | + } else {
|
|
| 1618 | + $this->y = $this->h+$y; |
|
| 1619 | + } |
|
| 1620 | + if($resetX) {
|
|
| 1621 | + $this->x = $this->lMargin; |
|
| 1622 | + } |
|
| 1552 | 1623 | } |
| 1553 | 1624 | |
| 1554 | 1625 | /** |
@@ -1593,10 +1664,12 @@ discard block |
||
| 1593 | 1664 | $dest = $name; |
| 1594 | 1665 | $name = $tmp; |
| 1595 | 1666 | } |
| 1596 | - if($dest=='') |
|
| 1597 | - $dest = 'I'; |
|
| 1598 | - if($name=='') |
|
| 1599 | - $name = 'doc.pdf'; |
|
| 1667 | + if($dest=='') {
|
|
| 1668 | + $dest = 'I'; |
|
| 1669 | + } |
|
| 1670 | + if($name=='') {
|
|
| 1671 | + $name = 'doc.pdf'; |
|
| 1672 | + } |
|
| 1600 | 1673 | switch(strtoupper($dest)) |
| 1601 | 1674 | {
|
| 1602 | 1675 | case 'I': |
@@ -1623,8 +1696,9 @@ discard block |
||
| 1623 | 1696 | break; |
| 1624 | 1697 | case 'F': |
| 1625 | 1698 | // Save to local file |
| 1626 | - if(!file_put_contents($name,$this->buffer)) |
|
| 1627 | - $this->Error('Unable to create output file: '.$name);
|
|
| 1699 | + if(!file_put_contents($name,$this->buffer)) {
|
|
| 1700 | + $this->Error('Unable to create output file: '.$name);
|
|
| 1701 | + } |
|
| 1628 | 1702 | break; |
| 1629 | 1703 | case 'S': |
| 1630 | 1704 | // Return as a string |
@@ -1641,8 +1715,9 @@ discard block |
||
| 1641 | 1715 | protected function _dochecks() : void |
| 1642 | 1716 | {
|
| 1643 | 1717 | // Check mbstring overloading |
| 1644 | - if(ini_get('mbstring.func_overload') & 2)
|
|
| 1645 | - $this->Error('mbstring overloading must be disabled');
|
|
| 1718 | + if(ini_get('mbstring.func_overload') & 2) {
|
|
| 1719 | + $this->Error('mbstring overloading must be disabled');
|
|
| 1720 | + } |
|
| 1646 | 1721 | } |
| 1647 | 1722 | |
| 1648 | 1723 | /** |
@@ -1654,8 +1729,9 @@ discard block |
||
| 1654 | 1729 | {
|
| 1655 | 1730 | $file = ''; |
| 1656 | 1731 | $line = 0; |
| 1657 | - if(headers_sent($file,$line)) |
|
| 1658 | - $this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)");
|
|
| 1732 | + if(headers_sent($file,$line)) {
|
|
| 1733 | + $this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)");
|
|
| 1734 | + } |
|
| 1659 | 1735 | } |
| 1660 | 1736 | if(ob_get_length()) |
| 1661 | 1737 | {
|
@@ -1664,9 +1740,9 @@ discard block |
||
| 1664 | 1740 | {
|
| 1665 | 1741 | // It contains only a UTF-8 BOM and/or whitespace, let's clean it |
| 1666 | 1742 | ob_clean(); |
| 1743 | + } else {
|
|
| 1744 | + $this->Error("Some data has already been output, can't send PDF file");
|
|
| 1667 | 1745 | } |
| 1668 | - else |
|
| 1669 | - $this->Error("Some data has already been output, can't send PDF file");
|
|
| 1670 | 1746 | } |
| 1671 | 1747 | } |
| 1672 | 1748 | |
@@ -1680,17 +1756,18 @@ discard block |
||
| 1680 | 1756 | if(is_string($size)) |
| 1681 | 1757 | {
|
| 1682 | 1758 | $size = strtolower($size); |
| 1683 | - if(!isset($this->StdPageSizes[$size])) |
|
| 1684 | - $this->Error('Unknown page size: '.$size);
|
|
| 1759 | + if(!isset($this->StdPageSizes[$size])) {
|
|
| 1760 | + $this->Error('Unknown page size: '.$size);
|
|
| 1761 | + } |
|
| 1685 | 1762 | $a = $this->StdPageSizes[$size]; |
| 1686 | 1763 | return array($a[0]/$this->k, $a[1]/$this->k); |
| 1687 | - } |
|
| 1688 | - else |
|
| 1764 | + } else |
|
| 1689 | 1765 | {
|
| 1690 | - if($size[0]>$size[1]) |
|
| 1691 | - return array($size[1], $size[0]); |
|
| 1692 | - else |
|
| 1693 | - return $size; |
|
| 1766 | + if($size[0]>$size[1]) {
|
|
| 1767 | + return array($size[1], $size[0]); |
|
| 1768 | + } else {
|
|
| 1769 | + return $size; |
|
| 1770 | + } |
|
| 1694 | 1771 | } |
| 1695 | 1772 | } |
| 1696 | 1773 | |
@@ -1709,14 +1786,16 @@ discard block |
||
| 1709 | 1786 | $this->y = $this->tMargin; |
| 1710 | 1787 | $this->FontFamily = ''; |
| 1711 | 1788 | // Check page size and orientation |
| 1712 | - if($orientation=='') |
|
| 1713 | - $orientation = $this->DefOrientation; |
|
| 1714 | - else |
|
| 1715 | - $orientation = strtoupper($orientation[0]); |
|
| 1716 | - if($size=='') |
|
| 1717 | - $size = $this->DefPageSize; |
|
| 1718 | - else |
|
| 1719 | - $size = $this->_getpagesize($size); |
|
| 1789 | + if($orientation=='') {
|
|
| 1790 | + $orientation = $this->DefOrientation; |
|
| 1791 | + } else {
|
|
| 1792 | + $orientation = strtoupper($orientation[0]); |
|
| 1793 | + } |
|
| 1794 | + if($size=='') {
|
|
| 1795 | + $size = $this->DefPageSize; |
|
| 1796 | + } else {
|
|
| 1797 | + $size = $this->_getpagesize($size); |
|
| 1798 | + } |
|
| 1720 | 1799 | if($orientation!=$this->CurOrientation || $size[0]!=$this->CurPageSize[0] || $size[1]!=$this->CurPageSize[1]) |
| 1721 | 1800 | {
|
| 1722 | 1801 | // New size or orientation |
@@ -1724,8 +1803,7 @@ discard block |
||
| 1724 | 1803 | {
|
| 1725 | 1804 | $this->w = $size[0]; |
| 1726 | 1805 | $this->h = $size[1]; |
| 1727 | - } |
|
| 1728 | - else |
|
| 1806 | + } else |
|
| 1729 | 1807 | {
|
| 1730 | 1808 | $this->w = $size[1]; |
| 1731 | 1809 | $this->h = $size[0]; |
@@ -1736,12 +1814,14 @@ discard block |
||
| 1736 | 1814 | $this->CurOrientation = $orientation; |
| 1737 | 1815 | $this->CurPageSize = $size; |
| 1738 | 1816 | } |
| 1739 | - if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1]) |
|
| 1740 | - $this->PageInfo[$this->page]['size'] = array($this->wPt, $this->hPt); |
|
| 1817 | + if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1]) {
|
|
| 1818 | + $this->PageInfo[$this->page]['size'] = array($this->wPt, $this->hPt); |
|
| 1819 | + } |
|
| 1741 | 1820 | if($rotation!=0) |
| 1742 | 1821 | {
|
| 1743 | - if($rotation%90!=0) |
|
| 1744 | - $this->Error('Incorrect rotation value: '.$rotation);
|
|
| 1822 | + if($rotation%90!=0) {
|
|
| 1823 | + $this->Error('Incorrect rotation value: '.$rotation);
|
|
| 1824 | + } |
|
| 1745 | 1825 | $this->CurRotation = $rotation; |
| 1746 | 1826 | $this->PageInfo[$this->page]['rotation'] = $rotation; |
| 1747 | 1827 | } |
@@ -1796,8 +1876,9 @@ discard block |
||
| 1796 | 1876 | $nb = strlen($s); |
| 1797 | 1877 | for($i=0;$i<$nb;$i++) |
| 1798 | 1878 | {
|
| 1799 | - if(ord($s[$i])>127) |
|
| 1800 | - return false; |
|
| 1879 | + if(ord($s[$i])>127) {
|
|
| 1880 | + return false; |
|
| 1881 | + } |
|
| 1801 | 1882 | } |
| 1802 | 1883 | return true; |
| 1803 | 1884 | } |
@@ -1811,14 +1892,17 @@ discard block |
||
| 1811 | 1892 | protected function _httpencode(string $param, string $value, bool $isUTF8) : string |
| 1812 | 1893 | {
|
| 1813 | 1894 | // Encode HTTP header field parameter |
| 1814 | - if($this->_isascii($value)) |
|
| 1815 | - return $param.'="'.$value.'"'; |
|
| 1816 | - if(!$isUTF8) |
|
| 1817 | - $value = utf8_encode($value); |
|
| 1818 | - if(strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')!==false) |
|
| 1819 | - return $param.'="'.rawurlencode($value).'"'; |
|
| 1820 | - else |
|
| 1821 | - return $param."*=UTF-8''".rawurlencode($value); |
|
| 1895 | + if($this->_isascii($value)) {
|
|
| 1896 | + return $param.'="'.$value.'"'; |
|
| 1897 | + } |
|
| 1898 | + if(!$isUTF8) {
|
|
| 1899 | + $value = utf8_encode($value); |
|
| 1900 | + } |
|
| 1901 | + if(strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')!==false) {
|
|
| 1902 | + return $param.'="'.rawurlencode($value).'"'; |
|
| 1903 | + } else {
|
|
| 1904 | + return $param."*=UTF-8''".rawurlencode($value); |
|
| 1905 | + } |
|
| 1822 | 1906 | } |
| 1823 | 1907 | |
| 1824 | 1908 | /** |
@@ -1842,15 +1926,13 @@ discard block |
||
| 1842 | 1926 | $c3 = ord($s[$i++]); |
| 1843 | 1927 | $res .= chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2)); |
| 1844 | 1928 | $res .= chr((($c2 & 0x03)<<6) + ($c3 & 0x3F)); |
| 1845 | - } |
|
| 1846 | - elseif($c1>=192) |
|
| 1929 | + } elseif($c1>=192) |
|
| 1847 | 1930 | {
|
| 1848 | 1931 | // 2-byte character |
| 1849 | 1932 | $c2 = ord($s[$i++]); |
| 1850 | 1933 | $res .= chr(($c1 & 0x1C)>>2); |
| 1851 | 1934 | $res .= chr((($c1 & 0x03)<<6) + ($c2 & 0x3F)); |
| 1852 | - } |
|
| 1853 | - else |
|
| 1935 | + } else |
|
| 1854 | 1936 | {
|
| 1855 | 1937 | // Single-byte character |
| 1856 | 1938 | $res .= "\0".chr($c1); |
@@ -1867,10 +1949,11 @@ discard block |
||
| 1867 | 1949 | protected function _escape(string $s) : string |
| 1868 | 1950 | {
|
| 1869 | 1951 | // Escape special characters |
| 1870 | - if(strpos($s,'(')!==false || strpos($s,')')!==false || strpos($s,'\\')!==false || strpos($s,"\r")!==false)
|
|
| 1871 | - return str_replace(array('\\','(',')',"\r"), array('\\\\','\\(','\\)','\\r'), $s);
|
|
| 1872 | - else |
|
| 1873 | - return $s; |
|
| 1952 | + if(strpos($s,'(')!==false || strpos($s,')')!==false || strpos($s,'\\')!==false || strpos($s,"\r")!==false) {
|
|
| 1953 | + return str_replace(array('\\','(',')',"\r"), array('\\\\','\\(','\\)','\\r'), $s);
|
|
| 1954 | + } else {
|
|
| 1955 | + return $s; |
|
| 1956 | + } |
|
| 1874 | 1957 | } |
| 1875 | 1958 | |
| 1876 | 1959 | /** |
@@ -1881,8 +1964,9 @@ discard block |
||
| 1881 | 1964 | protected function _textstring(string $s) : string |
| 1882 | 1965 | {
|
| 1883 | 1966 | // Format a text string |
| 1884 | - if(!$this->_isascii($s)) |
|
| 1885 | - $s = $this->_UTF8toUTF16($s); |
|
| 1967 | + if(!$this->_isascii($s)) {
|
|
| 1968 | + $s = $this->_UTF8toUTF16($s); |
|
| 1969 | + } |
|
| 1886 | 1970 | return '('.$this->_escape($s).')';
|
| 1887 | 1971 | } |
| 1888 | 1972 | |
@@ -1911,16 +1995,19 @@ discard block |
||
| 1911 | 1995 | {
|
| 1912 | 1996 | // Extract info from a JPEG file |
| 1913 | 1997 | $a = getimagesize($file); |
| 1914 | - if(!$a) |
|
| 1915 | - $this->Error('Missing or incorrect image file: '.$file);
|
|
| 1916 | - if($a[2]!=2) |
|
| 1917 | - $this->Error('Not a JPEG file: '.$file);
|
|
| 1918 | - if(!isset($a['channels']) || $a['channels']==3) |
|
| 1919 | - $colspace = 'DeviceRGB'; |
|
| 1920 | - elseif($a['channels']==4) |
|
| 1921 | - $colspace = 'DeviceCMYK'; |
|
| 1922 | - else |
|
| 1923 | - $colspace = 'DeviceGray'; |
|
| 1998 | + if(!$a) {
|
|
| 1999 | + $this->Error('Missing or incorrect image file: '.$file);
|
|
| 2000 | + } |
|
| 2001 | + if($a[2]!=2) {
|
|
| 2002 | + $this->Error('Not a JPEG file: '.$file);
|
|
| 2003 | + } |
|
| 2004 | + if(!isset($a['channels']) || $a['channels']==3) {
|
|
| 2005 | + $colspace = 'DeviceRGB'; |
|
| 2006 | + } elseif($a['channels']==4) {
|
|
| 2007 | + $colspace = 'DeviceCMYK'; |
|
| 2008 | + } else {
|
|
| 2009 | + $colspace = 'DeviceGray'; |
|
| 2010 | + } |
|
| 1924 | 2011 | $bpc = isset($a['bits']) ? $a['bits'] : 8; |
| 1925 | 2012 | $data = file_get_contents($file); |
| 1926 | 2013 | return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data);
|
@@ -1952,34 +2039,41 @@ discard block |
||
| 1952 | 2039 | protected function _parsepngstream($f, string $file) : array |
| 1953 | 2040 | {
|
| 1954 | 2041 | // Check signature |
| 1955 | - if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) |
|
| 1956 | - $this->Error('Not a PNG file: '.$file);
|
|
| 2042 | + if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) {
|
|
| 2043 | + $this->Error('Not a PNG file: '.$file);
|
|
| 2044 | + } |
|
| 1957 | 2045 | |
| 1958 | 2046 | // Read header chunk |
| 1959 | 2047 | $this->_readstream($f,4); |
| 1960 | - if($this->_readstream($f,4)!='IHDR') |
|
| 1961 | - $this->Error('Incorrect PNG file: '.$file);
|
|
| 2048 | + if($this->_readstream($f,4)!='IHDR') {
|
|
| 2049 | + $this->Error('Incorrect PNG file: '.$file);
|
|
| 2050 | + } |
|
| 1962 | 2051 | $w = $this->_readint($f); |
| 1963 | 2052 | $h = $this->_readint($f); |
| 1964 | 2053 | $bpc = ord($this->_readstream($f,1)); |
| 1965 | - if($bpc>8) |
|
| 1966 | - $this->Error('16-bit depth not supported: '.$file);
|
|
| 2054 | + if($bpc>8) {
|
|
| 2055 | + $this->Error('16-bit depth not supported: '.$file);
|
|
| 2056 | + } |
|
| 1967 | 2057 | $ct = ord($this->_readstream($f,1)); |
| 1968 | 2058 | $colspace = ''; |
| 1969 | - if($ct==0 || $ct==4) |
|
| 1970 | - $colspace = 'DeviceGray'; |
|
| 1971 | - elseif($ct==2 || $ct==6) |
|
| 1972 | - $colspace = 'DeviceRGB'; |
|
| 1973 | - elseif($ct==3) |
|
| 1974 | - $colspace = 'Indexed'; |
|
| 1975 | - else |
|
| 1976 | - $this->Error('Unknown color type: '.$file);
|
|
| 1977 | - if(ord($this->_readstream($f,1))!=0) |
|
| 1978 | - $this->Error('Unknown compression method: '.$file);
|
|
| 1979 | - if(ord($this->_readstream($f,1))!=0) |
|
| 1980 | - $this->Error('Unknown filter method: '.$file);
|
|
| 1981 | - if(ord($this->_readstream($f,1))!=0) |
|
| 1982 | - $this->Error('Interlacing not supported: '.$file);
|
|
| 2059 | + if($ct==0 || $ct==4) {
|
|
| 2060 | + $colspace = 'DeviceGray'; |
|
| 2061 | + } elseif($ct==2 || $ct==6) {
|
|
| 2062 | + $colspace = 'DeviceRGB'; |
|
| 2063 | + } elseif($ct==3) {
|
|
| 2064 | + $colspace = 'Indexed'; |
|
| 2065 | + } else {
|
|
| 2066 | + $this->Error('Unknown color type: '.$file);
|
|
| 2067 | + } |
|
| 2068 | + if(ord($this->_readstream($f,1))!=0) {
|
|
| 2069 | + $this->Error('Unknown compression method: '.$file);
|
|
| 2070 | + } |
|
| 2071 | + if(ord($this->_readstream($f,1))!=0) {
|
|
| 2072 | + $this->Error('Unknown filter method: '.$file);
|
|
| 2073 | + } |
|
| 2074 | + if(ord($this->_readstream($f,1))!=0) {
|
|
| 2075 | + $this->Error('Interlacing not supported: '.$file);
|
|
| 2076 | + } |
|
| 1983 | 2077 | $this->_readstream($f,4); |
| 1984 | 2078 | $dp = '/Predictor 15 /Colors '.($colspace=='DeviceRGB' ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w; |
| 1985 | 2079 | |
@@ -1996,44 +2090,45 @@ discard block |
||
| 1996 | 2090 | // Read palette |
| 1997 | 2091 | $pal = $this->_readstream($f,$n); |
| 1998 | 2092 | $this->_readstream($f,4); |
| 1999 | - } |
|
| 2000 | - elseif($type=='tRNS') |
|
| 2093 | + } elseif($type=='tRNS') |
|
| 2001 | 2094 | {
|
| 2002 | 2095 | // Read transparency info |
| 2003 | 2096 | $t = $this->_readstream($f,$n); |
| 2004 | - if($ct==0) |
|
| 2005 | - $trns = array(ord(substr($t,1,1))); |
|
| 2006 | - elseif($ct==2) |
|
| 2007 | - $trns = array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1))); |
|
| 2008 | - else |
|
| 2097 | + if($ct==0) {
|
|
| 2098 | + $trns = array(ord(substr($t,1,1))); |
|
| 2099 | + } elseif($ct==2) {
|
|
| 2100 | + $trns = array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1))); |
|
| 2101 | + } else |
|
| 2009 | 2102 | {
|
| 2010 | 2103 | $pos = strpos($t,chr(0)); |
| 2011 | - if($pos!==false) |
|
| 2012 | - $trns = array($pos); |
|
| 2104 | + if($pos!==false) {
|
|
| 2105 | + $trns = array($pos); |
|
| 2106 | + } |
|
| 2013 | 2107 | } |
| 2014 | 2108 | $this->_readstream($f,4); |
| 2015 | - } |
|
| 2016 | - elseif($type=='IDAT') |
|
| 2109 | + } elseif($type=='IDAT') |
|
| 2017 | 2110 | {
|
| 2018 | 2111 | // Read image data block |
| 2019 | 2112 | $data .= $this->_readstream($f,$n); |
| 2020 | 2113 | $this->_readstream($f,4); |
| 2114 | + } elseif($type=='IEND') {
|
|
| 2115 | + break; |
|
| 2116 | + } else {
|
|
| 2117 | + $this->_readstream($f,$n+4); |
|
| 2021 | 2118 | } |
| 2022 | - elseif($type=='IEND') |
|
| 2023 | - break; |
|
| 2024 | - else |
|
| 2025 | - $this->_readstream($f,$n+4); |
|
| 2026 | 2119 | } |
| 2027 | 2120 | while($n); |
| 2028 | 2121 | |
| 2029 | - if($colspace=='Indexed' && empty($pal)) |
|
| 2030 | - $this->Error('Missing palette in '.$file);
|
|
| 2122 | + if($colspace=='Indexed' && empty($pal)) {
|
|
| 2123 | + $this->Error('Missing palette in '.$file);
|
|
| 2124 | + } |
|
| 2031 | 2125 | $info = array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'dp'=>$dp, 'pal'=>$pal, 'trns'=>$trns);
|
| 2032 | 2126 | if($ct>=4) |
| 2033 | 2127 | {
|
| 2034 | 2128 | // Extract alpha channel |
| 2035 | - if(!function_exists('gzuncompress'))
|
|
| 2036 | - $this->Error('Zlib not available, can\'t handle alpha channel: '.$file);
|
|
| 2129 | + if(!function_exists('gzuncompress')) {
|
|
| 2130 | + $this->Error('Zlib not available, can\'t handle alpha channel: '.$file);
|
|
| 2131 | + } |
|
| 2037 | 2132 | $data = gzuncompress($data); |
| 2038 | 2133 | $color = ''; |
| 2039 | 2134 | $alpha = ''; |
@@ -2050,8 +2145,7 @@ discard block |
||
| 2050 | 2145 | $color .= preg_replace('/(.)./s','$1',$line);
|
| 2051 | 2146 | $alpha .= preg_replace('/.(.)/s','$1',$line);
|
| 2052 | 2147 | } |
| 2053 | - } |
|
| 2054 | - else |
|
| 2148 | + } else |
|
| 2055 | 2149 | {
|
| 2056 | 2150 | // RGB image |
| 2057 | 2151 | $len = 4*$w; |
@@ -2069,8 +2163,9 @@ discard block |
||
| 2069 | 2163 | $data = gzcompress($color); |
| 2070 | 2164 | $info['smask'] = gzcompress($alpha); |
| 2071 | 2165 | $this->WithAlpha = true; |
| 2072 | - if($this->PDFVersion<'1.4') |
|
| 2073 | - $this->PDFVersion = '1.4'; |
|
| 2166 | + if($this->PDFVersion<'1.4') {
|
|
| 2167 | + $this->PDFVersion = '1.4'; |
|
| 2168 | + } |
|
| 2074 | 2169 | } |
| 2075 | 2170 | $info['data'] = $data; |
| 2076 | 2171 | return $info; |
@@ -2089,13 +2184,15 @@ discard block |
||
| 2089 | 2184 | while($n>0 && !feof($f)) |
| 2090 | 2185 | {
|
| 2091 | 2186 | $s = fread($f,$n); |
| 2092 | - if($s===false) |
|
| 2093 | - $this->Error('Error while reading stream');
|
|
| 2187 | + if($s===false) {
|
|
| 2188 | + $this->Error('Error while reading stream');
|
|
| 2189 | + } |
|
| 2094 | 2190 | $n -= strlen($s); |
| 2095 | 2191 | $res .= $s; |
| 2096 | 2192 | } |
| 2097 | - if($n>0) |
|
| 2098 | - $this->Error('Unexpected end of stream');
|
|
| 2193 | + if($n>0) {
|
|
| 2194 | + $this->Error('Unexpected end of stream');
|
|
| 2195 | + } |
|
| 2099 | 2196 | return $res; |
| 2100 | 2197 | } |
| 2101 | 2198 | |
@@ -2152,14 +2249,15 @@ discard block |
||
| 2152 | 2249 | protected function _out(string $s) : void |
| 2153 | 2250 | {
|
| 2154 | 2251 | // Add a line to the document |
| 2155 | - if($this->state==2) |
|
| 2156 | - $this->pages[$this->page] .= $s."\n"; |
|
| 2157 | - elseif($this->state==1) |
|
| 2158 | - $this->_put($s); |
|
| 2159 | - elseif($this->state==0) |
|
| 2160 | - $this->Error('No page has been added yet');
|
|
| 2161 | - elseif($this->state==3) |
|
| 2162 | - $this->Error('The document is closed');
|
|
| 2252 | + if($this->state==2) {
|
|
| 2253 | + $this->pages[$this->page] .= $s."\n"; |
|
| 2254 | + } elseif($this->state==1) {
|
|
| 2255 | + $this->_put($s); |
|
| 2256 | + } elseif($this->state==0) {
|
|
| 2257 | + $this->Error('No page has been added yet');
|
|
| 2258 | + } elseif($this->state==3) {
|
|
| 2259 | + $this->Error('The document is closed');
|
|
| 2260 | + } |
|
| 2163 | 2261 | } |
| 2164 | 2262 | |
| 2165 | 2263 | /** |
@@ -2187,8 +2285,9 @@ discard block |
||
| 2187 | 2285 | protected function _newobj(?int $n=null) : void |
| 2188 | 2286 | {
|
| 2189 | 2287 | // Begin a new object |
| 2190 | - if($n===null) |
|
| 2191 | - $n = ++$this->n; |
|
| 2288 | + if($n===null) {
|
|
| 2289 | + $n = ++$this->n; |
|
| 2290 | + } |
|
| 2192 | 2291 | $this->offsets[$n] = $this->_getoffset(); |
| 2193 | 2292 | $this->_put($n.' 0 obj'); |
| 2194 | 2293 | } |
@@ -2214,9 +2313,9 @@ discard block |
||
| 2214 | 2313 | {
|
| 2215 | 2314 | $entries = '/Filter /FlateDecode '; |
| 2216 | 2315 | $data = gzcompress($data); |
| 2316 | + } else {
|
|
| 2317 | + $entries = ''; |
|
| 2217 | 2318 | } |
| 2218 | - else |
|
| 2219 | - $entries = ''; |
|
| 2220 | 2319 | $entries .= '/Length '.strlen($data); |
| 2221 | 2320 | $this->_newobj(); |
| 2222 | 2321 | $this->_put('<<'.$entries.'>>');
|
@@ -2233,10 +2332,12 @@ discard block |
||
| 2233 | 2332 | $this->_newobj(); |
| 2234 | 2333 | $this->_put('<</Type /Page');
|
| 2235 | 2334 | $this->_put('/Parent 1 0 R');
|
| 2236 | - if(isset($this->PageInfo[$n]['size'])) |
|
| 2237 | - $this->_put(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageInfo[$n]['size'][0],$this->PageInfo[$n]['size'][1]));
|
|
| 2238 | - if(isset($this->PageInfo[$n]['rotation'])) |
|
| 2239 | - $this->_put('/Rotate '.$this->PageInfo[$n]['rotation']);
|
|
| 2335 | + if(isset($this->PageInfo[$n]['size'])) {
|
|
| 2336 | + $this->_put(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageInfo[$n]['size'][0],$this->PageInfo[$n]['size'][1]));
|
|
| 2337 | + } |
|
| 2338 | + if(isset($this->PageInfo[$n]['rotation'])) {
|
|
| 2339 | + $this->_put('/Rotate '.$this->PageInfo[$n]['rotation']);
|
|
| 2340 | + } |
|
| 2240 | 2341 | $this->_put('/Resources 2 0 R');
|
| 2241 | 2342 | if(isset($this->PageLinks[$n])) |
| 2242 | 2343 | {
|
@@ -2246,27 +2347,30 @@ discard block |
||
| 2246 | 2347 | {
|
| 2247 | 2348 | $rect = sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]);
|
| 2248 | 2349 | $annots .= '<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] '; |
| 2249 | - if(is_string($pl[4])) |
|
| 2250 | - $annots .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>'; |
|
| 2251 | - else |
|
| 2350 | + if(is_string($pl[4])) {
|
|
| 2351 | + $annots .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>'; |
|
| 2352 | + } else |
|
| 2252 | 2353 | {
|
| 2253 | 2354 | $l = $this->links[$pl[4]]; |
| 2254 | - if(isset($this->PageInfo[$l[0]]['size'])) |
|
| 2255 | - $h = $this->PageInfo[$l[0]]['size'][1]; |
|
| 2256 | - else |
|
| 2257 | - $h = ($this->DefOrientation=='P') ? $this->DefPageSize[1]*$this->k : $this->DefPageSize[0]*$this->k; |
|
| 2355 | + if(isset($this->PageInfo[$l[0]]['size'])) {
|
|
| 2356 | + $h = $this->PageInfo[$l[0]]['size'][1]; |
|
| 2357 | + } else {
|
|
| 2358 | + $h = ($this->DefOrientation=='P') ? $this->DefPageSize[1]*$this->k : $this->DefPageSize[0]*$this->k; |
|
| 2359 | + } |
|
| 2258 | 2360 | $annots .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',$this->PageInfo[$l[0]]['n'],$h-$l[1]*$this->k);
|
| 2259 | 2361 | } |
| 2260 | 2362 | } |
| 2261 | 2363 | $this->_put($annots.']'); |
| 2262 | 2364 | } |
| 2263 | - if($this->WithAlpha) |
|
| 2264 | - $this->_put('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>');
|
|
| 2365 | + if($this->WithAlpha) {
|
|
| 2366 | + $this->_put('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>');
|
|
| 2367 | + } |
|
| 2265 | 2368 | $this->_put('/Contents '.($this->n+1).' 0 R>>');
|
| 2266 | 2369 | $this->_put('endobj');
|
| 2267 | 2370 | // Page content |
| 2268 | - if(!empty($this->AliasNbPages)) |
|
| 2269 | - $this->pages[$n] = str_replace($this->AliasNbPages, strval($this->page), $this->pages[$n]); |
|
| 2371 | + if(!empty($this->AliasNbPages)) {
|
|
| 2372 | + $this->pages[$n] = str_replace($this->AliasNbPages, strval($this->page), $this->pages[$n]); |
|
| 2373 | + } |
|
| 2270 | 2374 | $this->_putstreamobject($this->pages[$n]); |
| 2271 | 2375 | } |
| 2272 | 2376 | |
@@ -2276,24 +2380,26 @@ discard block |
||
| 2276 | 2380 | protected function _putpages() : void |
| 2277 | 2381 | {
|
| 2278 | 2382 | $nb = $this->page; |
| 2279 | - for($n=1;$n<=$nb;$n++) |
|
| 2280 | - $this->PageInfo[$n]['n'] = $this->n+1+2*($n-1); |
|
| 2281 | - for($n=1;$n<=$nb;$n++) |
|
| 2282 | - $this->_putpage($n); |
|
| 2383 | + for($n=1;$n<=$nb;$n++) {
|
|
| 2384 | + $this->PageInfo[$n]['n'] = $this->n+1+2*($n-1); |
|
| 2385 | + } |
|
| 2386 | + for($n=1;$n<=$nb;$n++) {
|
|
| 2387 | + $this->_putpage($n); |
|
| 2388 | + } |
|
| 2283 | 2389 | // Pages root |
| 2284 | 2390 | $this->_newobj(1); |
| 2285 | 2391 | $this->_put('<</Type /Pages');
|
| 2286 | 2392 | $kids = '/Kids ['; |
| 2287 | - for($n=1;$n<=$nb;$n++) |
|
| 2288 | - $kids .= $this->PageInfo[$n]['n'].' 0 R '; |
|
| 2393 | + for($n=1;$n<=$nb;$n++) {
|
|
| 2394 | + $kids .= $this->PageInfo[$n]['n'].' 0 R '; |
|
| 2395 | + } |
|
| 2289 | 2396 | $this->_put($kids.']'); |
| 2290 | 2397 | $this->_put('/Count '.$nb);
|
| 2291 | 2398 | if($this->DefOrientation=='P') |
| 2292 | 2399 | {
|
| 2293 | 2400 | $w = $this->DefPageSize[0]; |
| 2294 | 2401 | $h = $this->DefPageSize[1]; |
| 2295 | - } |
|
| 2296 | - else |
|
| 2402 | + } else |
|
| 2297 | 2403 | {
|
| 2298 | 2404 | $w = $this->DefPageSize[1]; |
| 2299 | 2405 | $h = $this->DefPageSize[0]; |
@@ -2443,8 +2549,7 @@ discard block |
||
| 2443 | 2549 | {
|
| 2444 | 2550 | $ranges .= sprintf("<%02X> <%02X> <%04X>\n",$c,$c+$v[1]-1,$v[0]);
|
| 2445 | 2551 | $nbr++; |
| 2446 | - } |
|
| 2447 | - else |
|
| 2552 | + } else |
|
| 2448 | 2553 | {
|
| 2449 | 2554 | $chars .= sprintf("<%02X> <%04X>\n",$c,$v);
|
| 2450 | 2555 | $nbc++; |