@@ -17,11 +17,9 @@ discard block |
||
| 17 | 17 | public function current_font($c){ |
| 18 | 18 | if($c=='family'){ |
| 19 | 19 | return $this->FontFamily; |
| 20 | - } |
|
| 21 | - elseif($c=='style'){ |
|
| 20 | + } elseif($c=='style'){ |
|
| 22 | 21 | return $this->FontStyle; |
| 23 | - } |
|
| 24 | - elseif($c=='size'){ |
|
| 22 | + } elseif($c=='size'){ |
|
| 25 | 23 | return $this->FontSizePt; |
| 26 | 24 | } |
| 27 | 25 | } |
@@ -29,8 +27,7 @@ discard block |
||
| 29 | 27 | public function get_color($c){ |
| 30 | 28 | if($c=='fill'){ |
| 31 | 29 | return $this->FillColor; |
| 32 | - } |
|
| 33 | - elseif($c=='text'){ |
|
| 30 | + } elseif($c=='text'){ |
|
| 34 | 31 | return $this->TextColor; |
| 35 | 32 | } |
| 36 | 33 | } |
@@ -42,11 +39,9 @@ discard block |
||
| 42 | 39 | public function get_margin($c){ |
| 43 | 40 | if($c=='l'){ |
| 44 | 41 | return $this->lMargin; |
| 45 | - } |
|
| 46 | - elseif($c=='r'){ |
|
| 42 | + } elseif($c=='r'){ |
|
| 47 | 43 | return $this->rMargin; |
| 48 | - } |
|
| 49 | - elseif($c=='t'){ |
|
| 44 | + } elseif($c=='t'){ |
|
| 50 | 45 | return $this->tMargin; |
| 51 | 46 | } |
| 52 | 47 | } |
@@ -84,8 +79,7 @@ discard block |
||
| 84 | 79 | break; |
| 85 | 80 | } |
| 86 | 81 | } |
| 87 | - } |
|
| 88 | - else{ |
|
| 82 | + } else{ |
|
| 89 | 83 | $a=false; |
| 90 | 84 | } |
| 91 | 85 | return $a; |
@@ -98,8 +92,7 @@ discard block |
||
| 98 | 92 | for($i=0; $i<3; $i++){ |
| 99 | 93 | if($n==6){ |
| 100 | 94 | $result[$i]=self::$hex[$str[2*$i]]*16+self::$hex[$str[2*$i+1]]; |
| 101 | - } |
|
| 102 | - else{ |
|
| 95 | + } else{ |
|
| 103 | 96 | $result[$i]=self::$hex[$str[$i]]*16+self::$hex[$str[$i]]; |
| 104 | 97 | } |
| 105 | 98 | } |
@@ -113,16 +106,14 @@ discard block |
||
| 113 | 106 | $array=array(); |
| 114 | 107 | if($this->is_hex($str)){ |
| 115 | 108 | $array=$this->hextodec($str); |
| 116 | - } |
|
| 117 | - elseif($this->is_rgb($str)){ |
|
| 109 | + } elseif($this->is_rgb($str)){ |
|
| 118 | 110 | $array=explode(',', trim($str, ',')); |
| 119 | 111 | for($i=0; $i<3; $i++){ |
| 120 | 112 | if(!isset($array[$i])){ |
| 121 | 113 | $array[$i]=0; |
| 122 | 114 | } |
| 123 | 115 | } |
| 124 | - } |
|
| 125 | - else{ |
|
| 116 | + } else{ |
|
| 126 | 117 | $array=array(null, null, null); |
| 127 | 118 | $i=0; |
| 128 | 119 | $tmp=explode(' ', $str); |
@@ -135,11 +126,9 @@ discard block |
||
| 135 | 126 | } |
| 136 | 127 | if($p=='T'){ |
| 137 | 128 | $this->SetTextColor($array[0],$array[1],$array[2]); |
| 138 | - } |
|
| 139 | - elseif($p=='D'){ |
|
| 129 | + } elseif($p=='D'){ |
|
| 140 | 130 | $this->SetDrawColor($array[0],$array[1], $array[2]); |
| 141 | - } |
|
| 142 | - elseif($p=='F'){ |
|
| 131 | + } elseif($p=='F'){ |
|
| 143 | 132 | $this->SetFillColor($array[0],$array[1],$array[2]); |
| 144 | 133 | } |
| 145 | 134 | } |
@@ -164,30 +153,35 @@ discard block |
||
| 164 | 153 | ************************************************************************/ |
| 165 | 154 | |
| 166 | 155 | private function &FontData($family, $style, $size){ |
| 167 | - if($family=='') |
|
| 168 | - $family = $this->FontFamily; |
|
| 169 | - else |
|
| 170 | - $family = strtolower($family); |
|
| 156 | + if($family=='') { |
|
| 157 | + $family = $this->FontFamily; |
|
| 158 | + } else { |
|
| 159 | + $family = strtolower($family); |
|
| 160 | + } |
|
| 171 | 161 | $style = strtoupper($style); |
| 172 | 162 | if(strpos($style,'U')!==false){ |
| 173 | 163 | $this->underline = true; |
| 174 | 164 | $style = str_replace('U','',$style); |
| 175 | 165 | } |
| 176 | - if($style=='IB') |
|
| 177 | - $style = 'BI'; |
|
| 166 | + if($style=='IB') { |
|
| 167 | + $style = 'BI'; |
|
| 168 | + } |
|
| 178 | 169 | $fontkey = $family.$style; |
| 179 | 170 | if(!isset($this->fonts[$fontkey])){ |
| 180 | - if($family=='arial') |
|
| 181 | - $family = 'helvetica'; |
|
| 171 | + if($family=='arial') { |
|
| 172 | + $family = 'helvetica'; |
|
| 173 | + } |
|
| 182 | 174 | if(in_array($family,$this->CoreFonts)){ |
| 183 | - if($family=='symbol' || $family=='zapfdingbats') |
|
| 184 | - $style = ''; |
|
| 175 | + if($family=='symbol' || $family=='zapfdingbats') { |
|
| 176 | + $style = ''; |
|
| 177 | + } |
|
| 185 | 178 | $fontkey = $family.$style; |
| 186 | - if(!isset($this->fonts[$fontkey])) |
|
| 187 | - $this->AddFont($family,$style); |
|
| 179 | + if(!isset($this->fonts[$fontkey])) { |
|
| 180 | + $this->AddFont($family,$style); |
|
| 181 | + } |
|
| 182 | + } else { |
|
| 183 | + $this->Error('Undefined font: '.$family.' '.$style); |
|
| 188 | 184 | } |
| 189 | - else |
|
| 190 | - $this->Error('Undefined font: '.$family.' '.$style); |
|
| 191 | 185 | } |
| 192 | 186 | $result['FontSize'] = $size/$this->k; |
| 193 | 187 | $result['CurrentFont']=&$this->fonts[$fontkey]; |
@@ -242,8 +236,7 @@ discard block |
||
| 242 | 236 | $x-=($a+$sl); |
| 243 | 237 | $a=0; |
| 244 | 238 | $u=$p; |
| 245 | - } |
|
| 246 | - else{ |
|
| 239 | + } else{ |
|
| 247 | 240 | $x=$cw[$parced_str[$i]]*$cfty['font-size']; |
| 248 | 241 | $t=''; |
| 249 | 242 | $u=$i; |
@@ -330,8 +323,7 @@ discard block |
||
| 330 | 323 | if($line['width']!=0){ |
| 331 | 324 | if($align=='R'){ |
| 332 | 325 | $dx = $w-$line['width']/($this->k*1000); |
| 333 | - } |
|
| 334 | - elseif($align=='C'){ |
|
| 326 | + } elseif($align=='C'){ |
|
| 335 | 327 | $dx = ($w-$line['width']/($this->k*1000))/2; |
| 336 | 328 | } |
| 337 | 329 | if($align=='J'){ |
@@ -365,8 +357,7 @@ discard block |
||
| 365 | 357 | } |
| 366 | 358 | $xx+=$this->GetStringWidth($tt); |
| 367 | 359 | } |
| 368 | - } |
|
| 369 | - else{ |
|
| 360 | + } else{ |
|
| 370 | 361 | $this->Text($xx, $y, $txt); |
| 371 | 362 | if($line['style'][$tj]['href']){ |
| 372 | 363 | $yr=$this->y+0.5*($lh*$line['height']-$line['height']/$this->k); |
@@ -40,12 +40,10 @@ discard block |
||
| 40 | 40 | if(strpos($r[1], 'U')!==false){ |
| 41 | 41 | $style['font-style'].='U'; |
| 42 | 42 | } |
| 43 | - } |
|
| 44 | - elseif($r[1]){ |
|
| 43 | + } elseif($r[1]){ |
|
| 45 | 44 | if($r[0]=='href'){ |
| 46 | 45 | $style[$r[0]]=implode(':', array_slice($r,1)); |
| 47 | - } |
|
| 48 | - else{ |
|
| 46 | + } else{ |
|
| 49 | 47 | $style[$r[0]]=$r[1]; |
| 50 | 48 | } |
| 51 | 49 | } |
@@ -118,8 +116,7 @@ discard block |
||
| 118 | 116 | $cs=$this->style_merge($cs, $this->get_style($open[$total[$i]])); |
| 119 | 117 | array_push($tmp, $cs); |
| 120 | 118 | $k=strpos($str, '>',$total[$i]+1)+1; |
| 121 | - } |
|
| 122 | - else{ |
|
| 119 | + } else{ |
|
| 123 | 120 | $k=$total[$i]+4; |
| 124 | 121 | array_pop($tmp); |
| 125 | 122 | $l=count($tmp)-1; |
@@ -72,8 +72,7 @@ discard block |
||
| 72 | 72 | if($c=='R' || $c=='T'){ |
| 73 | 73 | if($c=='R'){ |
| 74 | 74 | $result['c-align']=array_pad(array(), $this->col_num, 'L'); |
| 75 | - } |
|
| 76 | - else{ |
|
| 75 | + } else{ |
|
| 77 | 76 | $result['c-align']=array(); |
| 78 | 77 | } |
| 79 | 78 | } |
@@ -97,11 +96,9 @@ discard block |
||
| 97 | 96 | private function inherating(&$sty, $setting, $c){ |
| 98 | 97 | if($c=='C'){ |
| 99 | 98 | $sty[$setting]=$this->row_style[$setting]; |
| 100 | - } |
|
| 101 | - elseif($c=='R'){ |
|
| 99 | + } elseif($c=='R'){ |
|
| 102 | 100 | $sty[$setting]=$this->table_style[$setting]; |
| 103 | - } |
|
| 104 | - else{ |
|
| 101 | + } else{ |
|
| 105 | 102 | $sty[$setting]=$this->document_style[$setting]; |
| 106 | 103 | } |
| 107 | 104 | } |
@@ -115,38 +112,32 @@ discard block |
||
| 115 | 112 | if($sty['width']==0){ |
| 116 | 113 | $sty['width']=$this->document_style['document_width']; |
| 117 | 114 | } |
| 118 | - } |
|
| 119 | - else{ |
|
| 115 | + } else{ |
|
| 120 | 116 | $x=strpos($sty['width'], '%'); |
| 121 | 117 | if($x!=false){ |
| 122 | 118 | $x=min(abs(substr($sty['width'], 0, $x)), 100); |
| 123 | 119 | if($x){ |
| 124 | 120 | $sty['width']=$x*$this->document_style['document_width']/100.0; |
| 125 | - } |
|
| 126 | - else{ |
|
| 121 | + } else{ |
|
| 127 | 122 | $sty['width']=$this->document_style['document_width']; |
| 128 | 123 | } |
| 129 | - } |
|
| 130 | - else{ |
|
| 124 | + } else{ |
|
| 131 | 125 | $sty['width']=$this->document_style['document_width']; |
| 132 | 126 | } |
| 133 | 127 | } |
| 134 | 128 | if(!is_numeric($sty['l-margin'])){ |
| 135 | 129 | $sty['l-margin']=0; |
| 136 | - } |
|
| 137 | - else{ |
|
| 130 | + } else{ |
|
| 138 | 131 | $sty['l-margin']=abs($sty['l-margin']); |
| 139 | 132 | } |
| 140 | 133 | if(is_numeric($sty['border-width'])){ |
| 141 | 134 | $sty['border-width']=abs($sty['border-width']); |
| 142 | - } |
|
| 143 | - else{ |
|
| 135 | + } else{ |
|
| 144 | 136 | $sty['border-width']=false; |
| 145 | 137 | } |
| 146 | 138 | if($sty['split-row']=='false'){ |
| 147 | 139 | $sty['split-row']=false; |
| 148 | - } |
|
| 149 | - elseif($sty['split-row']!==false){ |
|
| 140 | + } elseif($sty['split-row']!==false){ |
|
| 150 | 141 | $sty['split-row']=true; |
| 151 | 142 | } |
| 152 | 143 | } |
@@ -158,8 +149,7 @@ discard block |
||
| 158 | 149 | if(!is_numeric($sty['paddingX'])){ |
| 159 | 150 | if($c=='C' || $c=='R'){ |
| 160 | 151 | $this->inherating($sty, 'paddingX', $c); |
| 161 | - } |
|
| 162 | - else{ |
|
| 152 | + } else{ |
|
| 163 | 153 | $sty['paddingX']=self::XPadding; |
| 164 | 154 | } |
| 165 | 155 | } |
@@ -167,16 +157,14 @@ discard block |
||
| 167 | 157 | if(!is_numeric($sty['paddingY'])){ |
| 168 | 158 | if($c=='C' || $c=='R'){ |
| 169 | 159 | $this->inherating($sty, 'paddingY', $c); |
| 170 | - } |
|
| 171 | - else{ |
|
| 160 | + } else{ |
|
| 172 | 161 | $sty['paddingY']=self::YPadding; |
| 173 | 162 | } |
| 174 | 163 | } |
| 175 | 164 | $sty['paddingY']=abs($sty['paddingY']); |
| 176 | 165 | if($sty['border']===false && ($c=='C' || $c=='R')){ |
| 177 | 166 | $this->inherating($sty, 'border', $c); |
| 178 | - } |
|
| 179 | - else{ |
|
| 167 | + } else{ |
|
| 180 | 168 | $border=array('T'=>1, 'R'=>1, 'B'=>1, 'L'=>1); |
| 181 | 169 | if(!(is_numeric($sty['border']) && $sty['border']==1)){ |
| 182 | 170 | foreach($border as $k=>$v){ |
@@ -193,12 +181,10 @@ discard block |
||
| 193 | 181 | if($sty[$setting]===false || !($this->pdf_obj->is_hex($sty[$setting]) || $this->pdf_obj->is_rgb($sty[$setting]))){ |
| 194 | 182 | if($c=='C' || $c=='R'){ |
| 195 | 183 | $this->inherating($sty, $setting, $c); |
| 196 | - } |
|
| 197 | - elseif($setting=='font-color'){ |
|
| 184 | + } elseif($setting=='font-color'){ |
|
| 198 | 185 | $sty[$setting]=$this->document_style[$setting]; |
| 199 | 186 | } |
| 200 | - } |
|
| 201 | - else{ |
|
| 187 | + } else{ |
|
| 202 | 188 | $sty[$setting]=$sty[$setting]; |
| 203 | 189 | } |
| 204 | 190 | } |
@@ -210,12 +196,10 @@ discard block |
||
| 210 | 196 | } |
| 211 | 197 | if(is_numeric($sty['line-height'])){ |
| 212 | 198 | $sty['line-height']=self::LP*abs($sty['line-height']); |
| 213 | - } |
|
| 214 | - else{ |
|
| 199 | + } else{ |
|
| 215 | 200 | if($c=='C' || $c=='R'){ |
| 216 | 201 | $this->inherating($sty,'line-height', $c); |
| 217 | - } |
|
| 218 | - else{ |
|
| 202 | + } else{ |
|
| 219 | 203 | $sty['line-height']=self::LP; |
| 220 | 204 | } |
| 221 | 205 | } |
@@ -241,28 +225,23 @@ discard block |
||
| 241 | 225 | if($sty['img']['w']+$sty['img']['h']==0){ |
| 242 | 226 | $sty['img']['w']=$img[0]; |
| 243 | 227 | $sty['img']['h']=$img[1]; |
| 244 | - } |
|
| 245 | - elseif($sty['img']['w']==0){ |
|
| 228 | + } elseif($sty['img']['w']==0){ |
|
| 246 | 229 | $sty['img']['w']=$sty['img']['h']*$ration; |
| 247 | - } |
|
| 248 | - elseif($sty['img']['h']==0){ |
|
| 230 | + } elseif($sty['img']['h']==0){ |
|
| 249 | 231 | $sty['img']['h']=$sty['img']['w']/$ration; |
| 250 | 232 | } |
| 251 | - } |
|
| 252 | - else{ |
|
| 233 | + } else{ |
|
| 253 | 234 | $sty['img']='failed to open stream: file ' . $tmp[0] .' does not exist'; |
| 254 | 235 | } |
| 255 | 236 | } |
| 256 | 237 | if(is_numeric($sty['colspan']) && $sty['colspan']>0){ |
| 257 | 238 | $sty['colspan']--; |
| 258 | - } |
|
| 259 | - else{ |
|
| 239 | + } else{ |
|
| 260 | 240 | $sty['colspan']=0; |
| 261 | 241 | } |
| 262 | 242 | if(is_numeric($sty['rowspan']) && $sty['rowspan']>0){ |
| 263 | 243 | $sty['rowspan']--; |
| 264 | - } |
|
| 265 | - else{ |
|
| 244 | + } else{ |
|
| 266 | 245 | $sty['rowspan']=0; |
| 267 | 246 | } |
| 268 | 247 | if($sty['valign']==false && ($sty['rowspan']>0 || $sty['img']!==false)){ |
@@ -283,8 +262,7 @@ discard block |
||
| 283 | 262 | for($i=0; $i<strlen($tmp[1]); $i++){ |
| 284 | 263 | if(preg_match("/[LCRJ]/", $tmp[1][$i])!=0){ |
| 285 | 264 | $sty['c-align'][$i]=$tmp[1][$i]; |
| 286 | - } |
|
| 287 | - else{ |
|
| 265 | + } else{ |
|
| 288 | 266 | $sty['c-align'][$i]='L'; |
| 289 | 267 | } |
| 290 | 268 | } |
@@ -298,23 +276,19 @@ discard block |
||
| 298 | 276 | if($sty['align']!='L' && $sty['align']!='C' && $sty['align']!='R' && $sty['align']!='J'){ |
| 299 | 277 | if($c=='C'){ |
| 300 | 278 | $sty['align']=$this->row_style['c-align'][$pos]; |
| 301 | - } |
|
| 302 | - elseif($c=='R'){ |
|
| 279 | + } elseif($c=='R'){ |
|
| 303 | 280 | $sty['align']='L'; |
| 304 | 281 | $sty['c-align']=$this->table_style['c-align']; |
| 305 | - } |
|
| 306 | - else{ |
|
| 282 | + } else{ |
|
| 307 | 283 | $sty['align']='C'; |
| 308 | 284 | } |
| 309 | - } |
|
| 310 | - elseif($c=='T' && $sty['align']=='J'){ |
|
| 285 | + } elseif($c=='T' && $sty['align']=='J'){ |
|
| 311 | 286 | $sty['align']='C'; |
| 312 | 287 | } |
| 313 | 288 | if($sty['valign']!='T' && $sty['valign']!='M' && $sty['valign']!='B'){ |
| 314 | 289 | if($c=='C' || $c=='R'){ |
| 315 | 290 | $this->inherating($sty, 'valign', $c); |
| 316 | - } |
|
| 317 | - else{ |
|
| 291 | + } else{ |
|
| 318 | 292 | $sty['valign']='T'; |
| 319 | 293 | } |
| 320 | 294 | } |
@@ -348,8 +322,7 @@ discard block |
||
| 348 | 322 | if($split==0){ |
| 349 | 323 | $this->pdf_obj->Line($this->row_data[$i][6]+(1+$a[($j+2)%4])%2*$w, $y+(1+$a[($j+1)%4])%2 * $h, $this->row_data[$i][6]+$a[$j%4]*$w, $y+($a[($j+3)%4])%2 *$h); |
| 350 | 324 | } |
| 351 | - } |
|
| 352 | - else{ |
|
| 325 | + } else{ |
|
| 353 | 326 | $this->pdf_obj->Line($this->row_data[$i][6]+(1+$a[($j+2)%4])%2*$w, $y+(1+$a[($j+1)%4])%2 * $h, $this->row_data[$i][6]+$a[$j%4]*$w, $y+($a[($j+3)%4])%2 *$h); |
| 354 | 327 | } |
| 355 | 328 | } |
@@ -393,8 +366,7 @@ discard block |
||
| 393 | 366 | if($this->row_data[$i][1]['align']=='C'){ |
| 394 | 367 | $x-=$this->row_data[$i][1]['paddingX']; |
| 395 | 368 | $x+=($this->row_data[$i][2]-$this->row_data[$i][1]['img']['w'])/2; |
| 396 | - } |
|
| 397 | - elseif($this->row_data[$i][1]['align']=='R'){ |
|
| 369 | + } elseif($this->row_data[$i][1]['align']=='R'){ |
|
| 398 | 370 | $x+=$this->row_data[$i][2]-$this->row_data[$i][1]['img']['w']; |
| 399 | 371 | $x-=2*$this->row_data[$i][1]['paddingX']; |
| 400 | 372 | } |
@@ -441,14 +413,12 @@ discard block |
||
| 441 | 413 | if(!isset($rw[$j])){ |
| 442 | 414 | if($this->pdf_obj->PageBreak()-($T+$this->row_heights[$j])>=0){ |
| 443 | 415 | $h+=$this->row_heights[$j]; |
| 444 | - } |
|
| 445 | - else{ |
|
| 416 | + } else{ |
|
| 446 | 417 | $a=$j+1; |
| 447 | 418 | break; |
| 448 | 419 | } |
| 449 | 420 | } |
| 450 | - } |
|
| 451 | - else{ |
|
| 421 | + } else{ |
|
| 452 | 422 | $a=$j+1; |
| 453 | 423 | break; |
| 454 | 424 | } |
@@ -465,8 +435,7 @@ discard block |
||
| 465 | 435 | $this->print_text($index, $T, $split_cell); |
| 466 | 436 | if($split_cell==0){ |
| 467 | 437 | $tmp[$index]=$index; |
| 468 | - } |
|
| 469 | - else{ |
|
| 438 | + } else{ |
|
| 470 | 439 | $ztmp[]=$index; |
| 471 | 440 | } |
| 472 | 441 | } |
@@ -476,8 +445,7 @@ discard block |
||
| 476 | 445 | if($tw>=0){ |
| 477 | 446 | $h+=$this->row_heights[$j]; |
| 478 | 447 | $rw[$j]=$j; |
| 479 | - } |
|
| 480 | - else{ |
|
| 448 | + } else{ |
|
| 481 | 449 | $this->row_heights[$j]=$this->overflow-$tw; |
| 482 | 450 | } |
| 483 | 451 | } |
@@ -494,8 +462,7 @@ discard block |
||
| 494 | 462 | $this->overflow=0; |
| 495 | 463 | $ztmp=array(); |
| 496 | 464 | $this->pdf_obj->addPage($this->document_style['orientation']); |
| 497 | - } |
|
| 498 | - else{ |
|
| 465 | + } else{ |
|
| 499 | 466 | $y+=$h; |
| 500 | 467 | } |
| 501 | 468 | } |
@@ -508,8 +475,7 @@ discard block |
||
| 508 | 475 | $ls=$this->row_data[$i][1]['img']['h']; |
| 509 | 476 | if($this->row_data[$i][1]['valign']=='B'){ |
| 510 | 477 | $ls+=$li; |
| 511 | - } |
|
| 512 | - else{ |
|
| 478 | + } else{ |
|
| 513 | 479 | $li+=$this->row_data[$i][3]-$this->row_data[$i][1]['img']['h']; |
| 514 | 480 | $ls+=$li; |
| 515 | 481 | } |
@@ -555,8 +521,7 @@ discard block |
||
| 555 | 521 | } |
| 556 | 522 | $this->overflow=max($this->overflow, $mx); |
| 557 | 523 | $this->row_data[$index][8]=1; |
| 558 | - } |
|
| 559 | - else{ |
|
| 524 | + } else{ |
|
| 560 | 525 | $this->row_data[$index][8]=-1*$rr; |
| 561 | 526 | } |
| 562 | 527 | $this->row_data[$index][7]=$h; |
@@ -577,8 +542,7 @@ discard block |
||
| 577 | 542 | $this->row_heights=&$this->header_row['row_heights']; |
| 578 | 543 | $this->row_data=&$this->header_row['row_data']; |
| 579 | 544 | $this->rows=&$this->header_row['rows']; |
| 580 | - } |
|
| 581 | - else{ |
|
| 545 | + } else{ |
|
| 582 | 546 | $this->header_row['row_data']=$data['header_data']; |
| 583 | 547 | unset($this->row_heights, $this->row_data, $this->rows); |
| 584 | 548 | $this->row_heights=$data['row_heights']; |
@@ -649,8 +613,7 @@ discard block |
||
| 649 | 613 | if(is_int($num_cols) && $num_cols!=0){ |
| 650 | 614 | $this->col_num=abs($num_cols); |
| 651 | 615 | $this->col_width=array_pad(array(), abs($num_cols), $this->table_style['width']/abs($num_cols)); |
| 652 | - } |
|
| 653 | - elseif(is_string($num_cols)){ |
|
| 616 | + } elseif(is_string($num_cols)){ |
|
| 654 | 617 | $num_cols=trim($num_cols, '}, '); |
| 655 | 618 | if($num_cols[0]!='{' && $num_cols[0]!='%'){ |
| 656 | 619 | error_log('Bad format for columns in Table constructor'); |
@@ -668,8 +631,7 @@ discard block |
||
| 668 | 631 | if(abs($c)){ |
| 669 | 632 | $w+=abs($c); |
| 670 | 633 | $this->col_width[]=abs($c); |
| 671 | - } |
|
| 672 | - else{ |
|
| 634 | + } else{ |
|
| 673 | 635 | error_log('Column width can not be zero'); |
| 674 | 636 | } |
| 675 | 637 | } |
@@ -682,12 +644,10 @@ discard block |
||
| 682 | 644 | foreach($this->col_width as $i=>$c){ |
| 683 | 645 | $this->col_width[$i]=$c*$this->table_style['width']/100; |
| 684 | 646 | } |
| 685 | - } |
|
| 686 | - elseif($w!=$this->table_style['width'] && $w){ |
|
| 647 | + } elseif($w!=$this->table_style['width'] && $w){ |
|
| 687 | 648 | if($w<$this->document_style['document_width']){ |
| 688 | 649 | $this->table_style['width']=$w; |
| 689 | - } |
|
| 690 | - else{ |
|
| 650 | + } else{ |
|
| 691 | 651 | $this->table_style['width']=$this->document_style['document_width']; |
| 692 | 652 | $d=$this->table_style['width']/$w; |
| 693 | 653 | for($i=0; $i<count($num_cols); $i++){ |
@@ -703,15 +663,12 @@ discard block |
||
| 703 | 663 | $this->table_style['c-align']=array_pad($this->table_style['c-align'], $this->col_num, 'L'); |
| 704 | 664 | if($this->table_style['l-margin']){ |
| 705 | 665 | $this->baseX=$this->pdf_obj->get_margin('l')+min($this->table_style['l-margin'],$this->document_style['document_width']-$this->table_style['width']); |
| 706 | - } |
|
| 707 | - else{ |
|
| 666 | + } else{ |
|
| 708 | 667 | if($this->table_style['align']=='L'){ |
| 709 | 668 | $this->baseX=$this->pdf_obj->get_margin('l'); |
| 710 | - } |
|
| 711 | - elseif($this->table_style['align']=='R'){ |
|
| 669 | + } elseif($this->table_style['align']=='R'){ |
|
| 712 | 670 | $this->baseX=$this->pdf_obj->get_margin('l')+$this->document_style['document_width']-$this->table_style['width']; |
| 713 | - } |
|
| 714 | - else{ |
|
| 671 | + } else{ |
|
| 715 | 672 | $this->baseX=$this->pdf_obj->get_margin('l')+($this->document_style['document_width']-$this->table_style['width'])/2; |
| 716 | 673 | } |
| 717 | 674 | } |
@@ -863,8 +820,7 @@ discard block |
||
| 863 | 820 | |
| 864 | 821 | if($this->total_rowspan>0){ |
| 865 | 822 | $this->total_rowspan--; |
| 866 | - } |
|
| 867 | - else{ |
|
| 823 | + } else{ |
|
| 868 | 824 | $row_number=count($this->rows); |
| 869 | 825 | if(count($this->blocks)>0){ |
| 870 | 826 | |
@@ -898,8 +854,7 @@ discard block |
||
| 898 | 854 | $this->row_data[$index][1]['padding-y']=$this->row_data[$index][1]['paddingY']; |
| 899 | 855 | if($this->row_data[$index][1]['valign']=='M' || ($this->row_data[$index][1]['img'] && count($this->row_data[$index][0]))){ |
| 900 | 856 | $this->row_data[$index][1]['padding-y']=($this->row_data[$index][5]-$this->row_data[$index][3])/2; |
| 901 | - } |
|
| 902 | - elseif($this->row_data[$index][1]['valign']=='B'){ |
|
| 857 | + } elseif($this->row_data[$index][1]['valign']=='B'){ |
|
| 903 | 858 | $this->row_data[$index][1]['padding-y']=$this->row_data[$index][5]-($this->row_data[$index][3]+$this->row_data[$index][1]['paddingY']); |
| 904 | 859 | } |
| 905 | 860 | }); |
@@ -3,8 +3,9 @@ |
||
| 3 | 3 | $name = 'Courier-BoldOblique'; |
| 4 | 4 | $up = -100; |
| 5 | 5 | $ut = 50; |
| 6 | -for($i=0;$i<=255;$i++) |
|
| 6 | +for($i=0;$i<=255;$i++) { |
|
| 7 | 7 | $cw[chr($i)] = 600; |
| 8 | +} |
|
| 8 | 9 | $enc = 'cp1252'; |
| 9 | 10 | $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); |
| 10 | 11 | ?> |
@@ -3,8 +3,9 @@ |
||
| 3 | 3 | $name = 'Courier-Bold'; |
| 4 | 4 | $up = -100; |
| 5 | 5 | $ut = 50; |
| 6 | -for($i=0;$i<=255;$i++) |
|
| 6 | +for($i=0;$i<=255;$i++) { |
|
| 7 | 7 | $cw[chr($i)] = 600; |
| 8 | +} |
|
| 8 | 9 | $enc = 'cp1252'; |
| 9 | 10 | $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); |
| 10 | 11 | ?> |
@@ -3,8 +3,9 @@ |
||
| 3 | 3 | $name = 'Courier'; |
| 4 | 4 | $up = -100; |
| 5 | 5 | $ut = 50; |
| 6 | -for($i=0;$i<=255;$i++) |
|
| 6 | +for($i=0;$i<=255;$i++) { |
|
| 7 | 7 | $cw[chr($i)] = 600; |
| 8 | +} |
|
| 8 | 9 | $enc = 'cp1252'; |
| 9 | 10 | $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); |
| 10 | 11 | ?> |
@@ -3,8 +3,9 @@ |
||
| 3 | 3 | $name = 'Courier-Oblique'; |
| 4 | 4 | $up = -100; |
| 5 | 5 | $ut = 50; |
| 6 | -for($i=0;$i<=255;$i++) |
|
| 6 | +for($i=0;$i<=255;$i++) { |
|
| 7 | 7 | $cw[chr($i)] = 600; |
| 8 | +} |
|
| 8 | 9 | $enc = 'cp1252'; |
| 9 | 10 | $uv = array(0=>array(0,128),128=>8364,130=>8218,131=>402,132=>8222,133=>8230,134=>array(8224,2),136=>710,137=>8240,138=>352,139=>8249,140=>338,142=>381,145=>array(8216,2),147=>array(8220,2),149=>8226,150=>array(8211,2),152=>732,153=>8482,154=>353,155=>8250,156=>339,158=>382,159=>376,160=>array(160,96)); |
| 10 | 11 | ?> |
@@ -105,26 +105,28 @@ discard block |
||
| 105 | 105 | if(defined('FPDF_FONTPATH')) |
| 106 | 106 | { |
| 107 | 107 | $this->fontpath = FPDF_FONTPATH; |
| 108 | - if(substr($this->fontpath,-1)!='/' && substr($this->fontpath,-1)!='\\') |
|
| 109 | - $this->fontpath .= '/'; |
|
| 108 | + if(substr($this->fontpath,-1)!='/' && substr($this->fontpath,-1)!='\\') { |
|
| 109 | + $this->fontpath .= '/'; |
|
| 110 | + } |
|
| 111 | + } elseif(is_dir(dirname(__FILE__).'/font')) { |
|
| 112 | + $this->fontpath = dirname(__FILE__).'/font/'; |
|
| 113 | + } else { |
|
| 114 | + $this->fontpath = ''; |
|
| 110 | 115 | } |
| 111 | - elseif(is_dir(dirname(__FILE__).'/font')) |
|
| 112 | - $this->fontpath = dirname(__FILE__).'/font/'; |
|
| 113 | - else |
|
| 114 | - $this->fontpath = ''; |
|
| 115 | 116 | // Core fonts |
| 116 | 117 | $this->CoreFonts = array('courier', 'helvetica', 'times', 'symbol', 'zapfdingbats','verdana','calligra','Arimo-Regular'); |
| 117 | 118 | // Scale factor |
| 118 | - if($unit=='pt') |
|
| 119 | - $this->k = 1; |
|
| 120 | - elseif($unit=='mm') |
|
| 121 | - $this->k = 72/25.4; |
|
| 122 | - elseif($unit=='cm') |
|
| 123 | - $this->k = 72/2.54; |
|
| 124 | - elseif($unit=='in') |
|
| 125 | - $this->k = 72; |
|
| 126 | - else |
|
| 127 | - $this->Error('Incorrect unit: '.$unit); |
|
| 119 | + if($unit=='pt') { |
|
| 120 | + $this->k = 1; |
|
| 121 | + } elseif($unit=='mm') { |
|
| 122 | + $this->k = 72/25.4; |
|
| 123 | + } elseif($unit=='cm') { |
|
| 124 | + $this->k = 72/2.54; |
|
| 125 | + } elseif($unit=='in') { |
|
| 126 | + $this->k = 72; |
|
| 127 | + } else { |
|
| 128 | + $this->Error('Incorrect unit: '.$unit); |
|
| 129 | + } |
|
| 128 | 130 | // Page sizes |
| 129 | 131 | $this->StdPageSizes = array('a3'=>array(841.89,1190.55), 'a4'=>array(595.28,841.89), 'a5'=>array(420.94,595.28), |
| 130 | 132 | 'letter'=>array(612,792), 'legal'=>array(612,1008)); |
@@ -138,15 +140,14 @@ discard block |
||
| 138 | 140 | $this->DefOrientation = 'P'; |
| 139 | 141 | $this->w = $size[0]; |
| 140 | 142 | $this->h = $size[1]; |
| 141 | - } |
|
| 142 | - elseif($orientation=='l' || $orientation=='landscape') |
|
| 143 | + } elseif($orientation=='l' || $orientation=='landscape') |
|
| 143 | 144 | { |
| 144 | 145 | $this->DefOrientation = 'L'; |
| 145 | 146 | $this->w = $size[1]; |
| 146 | 147 | $this->h = $size[0]; |
| 148 | + } else { |
|
| 149 | + $this->Error('Incorrect orientation: '.$orientation); |
|
| 147 | 150 | } |
| 148 | - else |
|
| 149 | - $this->Error('Incorrect orientation: '.$orientation); |
|
| 150 | 151 | $this->CurOrientation = $this->DefOrientation; |
| 151 | 152 | $this->wPt = $this->w*$this->k; |
| 152 | 153 | $this->hPt = $this->h*$this->k; |
@@ -174,8 +175,9 @@ discard block |
||
| 174 | 175 | // Set left, top and right margins |
| 175 | 176 | $this->lMargin = $left; |
| 176 | 177 | $this->tMargin = $top; |
| 177 | - if($right===null) |
|
| 178 | - $right = $left; |
|
| 178 | + if($right===null) { |
|
| 179 | + $right = $left; |
|
| 180 | + } |
|
| 179 | 181 | $this->rMargin = $right; |
| 180 | 182 | } |
| 181 | 183 | |
@@ -183,9 +185,10 @@ discard block |
||
| 183 | 185 | { |
| 184 | 186 | // Set left margin |
| 185 | 187 | $this->lMargin = $margin; |
| 186 | - if($this->page>0 && $this->x<$margin) |
|
| 187 | - $this->x = $margin; |
|
| 188 | -} |
|
| 188 | + if($this->page>0 && $this->x<$margin) { |
|
| 189 | + $this->x = $margin; |
|
| 190 | + } |
|
| 191 | + } |
|
| 189 | 192 | |
| 190 | 193 | function SetTopMargin($margin) |
| 191 | 194 | { |
@@ -210,24 +213,27 @@ discard block |
||
| 210 | 213 | function SetDisplayMode($zoom, $layout='default') |
| 211 | 214 | { |
| 212 | 215 | // Set display mode in viewer |
| 213 | - if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) |
|
| 214 | - $this->ZoomMode = $zoom; |
|
| 215 | - else |
|
| 216 | - $this->Error('Incorrect zoom display mode: '.$zoom); |
|
| 217 | - if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') |
|
| 218 | - $this->LayoutMode = $layout; |
|
| 219 | - else |
|
| 220 | - $this->Error('Incorrect layout display mode: '.$layout); |
|
| 221 | -} |
|
| 216 | + if($zoom=='fullpage' || $zoom=='fullwidth' || $zoom=='real' || $zoom=='default' || !is_string($zoom)) { |
|
| 217 | + $this->ZoomMode = $zoom; |
|
| 218 | + } else { |
|
| 219 | + $this->Error('Incorrect zoom display mode: '.$zoom); |
|
| 220 | + } |
|
| 221 | + if($layout=='single' || $layout=='continuous' || $layout=='two' || $layout=='default') { |
|
| 222 | + $this->LayoutMode = $layout; |
|
| 223 | + } else { |
|
| 224 | + $this->Error('Incorrect layout display mode: '.$layout); |
|
| 225 | + } |
|
| 226 | + } |
|
| 222 | 227 | |
| 223 | 228 | function SetCompression($compress) |
| 224 | 229 | { |
| 225 | 230 | // Set page compression |
| 226 | - if(function_exists('gzcompress')) |
|
| 227 | - $this->compress = $compress; |
|
| 228 | - else |
|
| 229 | - $this->compress = false; |
|
| 230 | -} |
|
| 231 | + if(function_exists('gzcompress')) { |
|
| 232 | + $this->compress = $compress; |
|
| 233 | + } else { |
|
| 234 | + $this->compress = false; |
|
| 235 | + } |
|
| 236 | + } |
|
| 231 | 237 | |
| 232 | 238 | function SetTitle($title, $isUTF8=false) |
| 233 | 239 | { |
@@ -274,10 +280,12 @@ discard block |
||
| 274 | 280 | function Close() |
| 275 | 281 | { |
| 276 | 282 | // Terminate document |
| 277 | - if($this->state==3) |
|
| 278 | - return; |
|
| 279 | - if($this->page==0) |
|
| 280 | - $this->AddPage(); |
|
| 283 | + if($this->state==3) { |
|
| 284 | + return; |
|
| 285 | + } |
|
| 286 | + if($this->page==0) { |
|
| 287 | + $this->AddPage(); |
|
| 288 | + } |
|
| 281 | 289 | // Page footer |
| 282 | 290 | $this->InFooter = true; |
| 283 | 291 | $this->Footer(); |
@@ -291,8 +299,9 @@ discard block |
||
| 291 | 299 | function AddPage($orientation='', $size='', $rotation=0) |
| 292 | 300 | { |
| 293 | 301 | // Start a new page |
| 294 | - if($this->state==3) |
|
| 295 | - $this->Error('The document is closed'); |
|
| 302 | + if($this->state==3) { |
|
| 303 | + $this->Error('The document is closed'); |
|
| 304 | + } |
|
| 296 | 305 | $family = $this->FontFamily; |
| 297 | 306 | $style = $this->FontStyle.($this->underline ? 'U' : ''); |
| 298 | 307 | $fontsize = $this->FontSizePt; |
@@ -318,15 +327,18 @@ discard block |
||
| 318 | 327 | $this->LineWidth = $lw; |
| 319 | 328 | $this->_out(sprintf('%.2F w',$lw*$this->k)); |
| 320 | 329 | // Set font |
| 321 | - if($family) |
|
| 322 | - $this->SetFont($family,$style,$fontsize); |
|
| 330 | + if($family) { |
|
| 331 | + $this->SetFont($family,$style,$fontsize); |
|
| 332 | + } |
|
| 323 | 333 | // Set colors |
| 324 | 334 | $this->DrawColor = $dc; |
| 325 | - if($dc!='0 G') |
|
| 326 | - $this->_out($dc); |
|
| 335 | + if($dc!='0 G') { |
|
| 336 | + $this->_out($dc); |
|
| 337 | + } |
|
| 327 | 338 | $this->FillColor = $fc; |
| 328 | - if($fc!='0 g') |
|
| 329 | - $this->_out($fc); |
|
| 339 | + if($fc!='0 g') { |
|
| 340 | + $this->_out($fc); |
|
| 341 | + } |
|
| 330 | 342 | $this->TextColor = $tc; |
| 331 | 343 | $this->ColorFlag = $cf; |
| 332 | 344 | // Page header |
@@ -340,8 +352,9 @@ discard block |
||
| 340 | 352 | $this->_out(sprintf('%.2F w',$lw*$this->k)); |
| 341 | 353 | } |
| 342 | 354 | // Restore font |
| 343 | - if($family) |
|
| 344 | - $this->SetFont($family,$style,$fontsize); |
|
| 355 | + if($family) { |
|
| 356 | + $this->SetFont($family,$style,$fontsize); |
|
| 357 | + } |
|
| 345 | 358 | // Restore colors |
| 346 | 359 | if($this->DrawColor!=$dc) |
| 347 | 360 | { |
@@ -376,33 +389,38 @@ discard block |
||
| 376 | 389 | function SetDrawColor($r, $g=null, $b=null) |
| 377 | 390 | { |
| 378 | 391 | // Set color for all stroking operations |
| 379 | - if(($r==0 && $g==0 && $b==0) || $g===null) |
|
| 380 | - $this->DrawColor = sprintf('%.3F G',$r/255); |
|
| 381 | - else |
|
| 382 | - $this->DrawColor = sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255); |
|
| 383 | - if($this->page>0) |
|
| 384 | - $this->_out($this->DrawColor); |
|
| 385 | -} |
|
| 392 | + if(($r==0 && $g==0 && $b==0) || $g===null) { |
|
| 393 | + $this->DrawColor = sprintf('%.3F G',$r/255); |
|
| 394 | + } else { |
|
| 395 | + $this->DrawColor = sprintf('%.3F %.3F %.3F RG',$r/255,$g/255,$b/255); |
|
| 396 | + } |
|
| 397 | + if($this->page>0) { |
|
| 398 | + $this->_out($this->DrawColor); |
|
| 399 | + } |
|
| 400 | + } |
|
| 386 | 401 | |
| 387 | 402 | function SetFillColor($r, $g=null, $b=null) |
| 388 | 403 | { |
| 389 | 404 | // Set color for all filling operations |
| 390 | - if(($r==0 && $g==0 && $b==0) || $g===null) |
|
| 391 | - $this->FillColor = sprintf('%.3F g',$r/255); |
|
| 392 | - else |
|
| 393 | - $this->FillColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
| 405 | + if(($r==0 && $g==0 && $b==0) || $g===null) { |
|
| 406 | + $this->FillColor = sprintf('%.3F g',$r/255); |
|
| 407 | + } else { |
|
| 408 | + $this->FillColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
| 409 | + } |
|
| 394 | 410 | $this->ColorFlag = ($this->FillColor!=$this->TextColor); |
| 395 | - if($this->page>0) |
|
| 396 | - $this->_out($this->FillColor); |
|
| 397 | -} |
|
| 411 | + if($this->page>0) { |
|
| 412 | + $this->_out($this->FillColor); |
|
| 413 | + } |
|
| 414 | + } |
|
| 398 | 415 | |
| 399 | 416 | function SetTextColor($r, $g=null, $b=null) |
| 400 | 417 | { |
| 401 | 418 | // Set color for text |
| 402 | - if(($r==0 && $g==0 && $b==0) || $g===null) |
|
| 403 | - $this->TextColor = sprintf('%.3F g',$r/255); |
|
| 404 | - else |
|
| 405 | - $this->TextColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
| 419 | + if(($r==0 && $g==0 && $b==0) || $g===null) { |
|
| 420 | + $this->TextColor = sprintf('%.3F g',$r/255); |
|
| 421 | + } else { |
|
| 422 | + $this->TextColor = sprintf('%.3F %.3F %.3F rg',$r/255,$g/255,$b/255); |
|
| 423 | + } |
|
| 406 | 424 | $this->ColorFlag = ($this->FillColor!=$this->TextColor); |
| 407 | 425 | } |
| 408 | 426 | |
@@ -413,8 +431,9 @@ discard block |
||
| 413 | 431 | $cw = &$this->CurrentFont['cw']; |
| 414 | 432 | $w = 0; |
| 415 | 433 | $l = strlen($s); |
| 416 | - for($i=0;$i<$l;$i++) |
|
| 417 | - $w += $cw[$s[$i]]; |
|
| 434 | + for($i=0;$i<$l;$i++) { |
|
| 435 | + $w += $cw[$s[$i]]; |
|
| 436 | + } |
|
| 418 | 437 | return $w*$this->FontSize/1000; |
| 419 | 438 | } |
| 420 | 439 | |
@@ -422,9 +441,10 @@ discard block |
||
| 422 | 441 | { |
| 423 | 442 | // Set line width |
| 424 | 443 | $this->LineWidth = $width; |
| 425 | - if($this->page>0) |
|
| 426 | - $this->_out(sprintf('%.2F w',$width*$this->k)); |
|
| 427 | -} |
|
| 444 | + if($this->page>0) { |
|
| 445 | + $this->_out(sprintf('%.2F w',$width*$this->k)); |
|
| 446 | + } |
|
| 447 | + } |
|
| 428 | 448 | |
| 429 | 449 | function Line($x1, $y1, $x2, $y2) |
| 430 | 450 | { |
@@ -435,12 +455,13 @@ discard block |
||
| 435 | 455 | function Rect($x, $y, $w, $h, $style='') |
| 436 | 456 | { |
| 437 | 457 | // Draw a rectangle |
| 438 | - if($style=='F') |
|
| 439 | - $op = 'f'; |
|
| 440 | - elseif($style=='FD' || $style=='DF') |
|
| 441 | - $op = 'B'; |
|
| 442 | - else |
|
| 443 | - $op = 'S'; |
|
| 458 | + if($style=='F') { |
|
| 459 | + $op = 'f'; |
|
| 460 | + } elseif($style=='FD' || $style=='DF') { |
|
| 461 | + $op = 'B'; |
|
| 462 | + } else { |
|
| 463 | + $op = 'S'; |
|
| 464 | + } |
|
| 444 | 465 | $this->_out(sprintf('%.2F %.2F %.2F %.2F re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op)); |
| 445 | 466 | } |
| 446 | 467 | |
@@ -448,23 +469,27 @@ discard block |
||
| 448 | 469 | { |
| 449 | 470 | // Add a TrueType, OpenType or Type1 font |
| 450 | 471 | $family = strtolower($family); |
| 451 | - if($file=='') |
|
| 452 | - $file = str_replace(' ','',$family).strtolower($style).'.php'; |
|
| 472 | + if($file=='') { |
|
| 473 | + $file = str_replace(' ','',$family).strtolower($style).'.php'; |
|
| 474 | + } |
|
| 453 | 475 | $style = strtoupper($style); |
| 454 | - if($style=='IB') |
|
| 455 | - $style = 'BI'; |
|
| 476 | + if($style=='IB') { |
|
| 477 | + $style = 'BI'; |
|
| 478 | + } |
|
| 456 | 479 | $fontkey = $family.$style; |
| 457 | - if(isset($this->fonts[$fontkey])) |
|
| 458 | - return; |
|
| 480 | + if(isset($this->fonts[$fontkey])) { |
|
| 481 | + return; |
|
| 482 | + } |
|
| 459 | 483 | $info = $this->_loadfont($file); |
| 460 | 484 | $info['i'] = count($this->fonts)+1; |
| 461 | 485 | if(!empty($info['file'])) |
| 462 | 486 | { |
| 463 | 487 | // Embedded font |
| 464 | - if($info['type']=='TrueType') |
|
| 465 | - $this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']); |
|
| 466 | - else |
|
| 467 | - $this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']); |
|
| 488 | + if($info['type']=='TrueType') { |
|
| 489 | + $this->FontFiles[$info['file']] = array('length1'=>$info['originalsize']); |
|
| 490 | + } else { |
|
| 491 | + $this->FontFiles[$info['file']] = array('length1'=>$info['size1'], 'length2'=>$info['size2']); |
|
| 492 | + } |
|
| 468 | 493 | } |
| 469 | 494 | $this->fonts[$fontkey] = $info; |
| 470 | 495 | } |
@@ -472,42 +497,49 @@ discard block |
||
| 472 | 497 | function SetFont($family, $style='', $size=0) |
| 473 | 498 | { |
| 474 | 499 | // Select a font; size given in points |
| 475 | - if($family=='') |
|
| 476 | - $family = $this->FontFamily; |
|
| 477 | - else |
|
| 478 | - $family = strtolower($family); |
|
| 500 | + if($family=='') { |
|
| 501 | + $family = $this->FontFamily; |
|
| 502 | + } else { |
|
| 503 | + $family = strtolower($family); |
|
| 504 | + } |
|
| 479 | 505 | $style = strtoupper($style); |
| 480 | 506 | if(strpos($style,'U')!==false) |
| 481 | 507 | { |
| 482 | 508 | $this->underline = true; |
| 483 | 509 | $style = str_replace('U','',$style); |
| 510 | + } else { |
|
| 511 | + $this->underline = false; |
|
| 512 | + } |
|
| 513 | + if($style=='IB') { |
|
| 514 | + $style = 'BI'; |
|
| 515 | + } |
|
| 516 | + if($size==0) { |
|
| 517 | + $size = $this->FontSizePt; |
|
| 484 | 518 | } |
| 485 | - else |
|
| 486 | - $this->underline = false; |
|
| 487 | - if($style=='IB') |
|
| 488 | - $style = 'BI'; |
|
| 489 | - if($size==0) |
|
| 490 | - $size = $this->FontSizePt; |
|
| 491 | 519 | // Test if font is already selected |
| 492 | - if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) |
|
| 493 | - return; |
|
| 520 | + if($this->FontFamily==$family && $this->FontStyle==$style && $this->FontSizePt==$size) { |
|
| 521 | + return; |
|
| 522 | + } |
|
| 494 | 523 | // Test if font is already loaded |
| 495 | 524 | $fontkey = $family.$style; |
| 496 | 525 | if(!isset($this->fonts[$fontkey])) |
| 497 | 526 | { |
| 498 | 527 | // Test if one of the core fonts |
| 499 | - if($family=='arial') |
|
| 500 | - $family = 'helvetica'; |
|
| 528 | + if($family=='arial') { |
|
| 529 | + $family = 'helvetica'; |
|
| 530 | + } |
|
| 501 | 531 | if(in_array($family,$this->CoreFonts)) |
| 502 | 532 | { |
| 503 | - if($family=='symbol' || $family=='zapfdingbats') |
|
| 504 | - $style = ''; |
|
| 533 | + if($family=='symbol' || $family=='zapfdingbats') { |
|
| 534 | + $style = ''; |
|
| 535 | + } |
|
| 505 | 536 | $fontkey = $family.$style; |
| 506 | - if(!isset($this->fonts[$fontkey])) |
|
| 507 | - $this->AddFont($family,$style); |
|
| 537 | + if(!isset($this->fonts[$fontkey])) { |
|
| 538 | + $this->AddFont($family,$style); |
|
| 539 | + } |
|
| 540 | + } else { |
|
| 541 | + $this->Error('Undefined font: '.$family.' '.$style); |
|
| 508 | 542 | } |
| 509 | - else |
|
| 510 | - $this->Error('Undefined font: '.$family.' '.$style); |
|
| 511 | 543 | } |
| 512 | 544 | // Select it |
| 513 | 545 | $this->FontFamily = $family; |
@@ -515,20 +547,23 @@ discard block |
||
| 515 | 547 | $this->FontSizePt = $size; |
| 516 | 548 | $this->FontSize = $size/$this->k; |
| 517 | 549 | $this->CurrentFont = &$this->fonts[$fontkey]; |
| 518 | - if($this->page>0) |
|
| 519 | - $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
| 520 | -} |
|
| 550 | + if($this->page>0) { |
|
| 551 | + $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
| 552 | + } |
|
| 553 | + } |
|
| 521 | 554 | |
| 522 | 555 | function SetFontSize($size) |
| 523 | 556 | { |
| 524 | 557 | // Set font size in points |
| 525 | - if($this->FontSizePt==$size) |
|
| 526 | - return; |
|
| 558 | + if($this->FontSizePt==$size) { |
|
| 559 | + return; |
|
| 560 | + } |
|
| 527 | 561 | $this->FontSizePt = $size; |
| 528 | 562 | $this->FontSize = $size/$this->k; |
| 529 | - if($this->page>0) |
|
| 530 | - $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
| 531 | -} |
|
| 563 | + if($this->page>0) { |
|
| 564 | + $this->_out(sprintf('BT /F%d %.2F Tf ET',$this->CurrentFont['i'],$this->FontSizePt)); |
|
| 565 | + } |
|
| 566 | + } |
|
| 532 | 567 | |
| 533 | 568 | function AddLink() |
| 534 | 569 | { |
@@ -541,10 +576,12 @@ discard block |
||
| 541 | 576 | function SetLink($link, $y=0, $page=-1) |
| 542 | 577 | { |
| 543 | 578 | // Set destination of internal link |
| 544 | - if($y==-1) |
|
| 545 | - $y = $this->y; |
|
| 546 | - if($page==-1) |
|
| 547 | - $page = $this->page; |
|
| 579 | + if($y==-1) { |
|
| 580 | + $y = $this->y; |
|
| 581 | + } |
|
| 582 | + if($page==-1) { |
|
| 583 | + $page = $this->page; |
|
| 584 | + } |
|
| 548 | 585 | $this->links[$link] = array($page, $y); |
| 549 | 586 | } |
| 550 | 587 | |
@@ -557,13 +594,16 @@ discard block |
||
| 557 | 594 | function Text($x, $y, $txt) |
| 558 | 595 | { |
| 559 | 596 | // Output a string |
| 560 | - if(!isset($this->CurrentFont)) |
|
| 561 | - $this->Error('No font has been set'); |
|
| 597 | + if(!isset($this->CurrentFont)) { |
|
| 598 | + $this->Error('No font has been set'); |
|
| 599 | + } |
|
| 562 | 600 | $s = sprintf('BT %.2F %.2F Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt)); |
| 563 | - if($this->underline && $txt!='') |
|
| 564 | - $s .= ' '.$this->_dounderline($x,$y,$txt); |
|
| 565 | - if($this->ColorFlag) |
|
| 566 | - $s = 'q '.$this->TextColor.' '.$s.' Q'; |
|
| 601 | + if($this->underline && $txt!='') { |
|
| 602 | + $s .= ' '.$this->_dounderline($x,$y,$txt); |
|
| 603 | + } |
|
| 604 | + if($this->ColorFlag) { |
|
| 605 | + $s = 'q '.$this->TextColor.' '.$s.' Q'; |
|
| 606 | + } |
|
| 567 | 607 | $this->_out($s); |
| 568 | 608 | } |
| 569 | 609 | |
@@ -595,77 +635,94 @@ discard block |
||
| 595 | 635 | $this->_out(sprintf('%.3F Tw',$ws*$k)); |
| 596 | 636 | } |
| 597 | 637 | } |
| 598 | - if($w==0) |
|
| 599 | - $w = $this->w-$this->rMargin-$this->x; |
|
| 638 | + if($w==0) { |
|
| 639 | + $w = $this->w-$this->rMargin-$this->x; |
|
| 640 | + } |
|
| 600 | 641 | $s = ''; |
| 601 | 642 | if($fill || $border==1) |
| 602 | 643 | { |
| 603 | - if($fill) |
|
| 604 | - $op = ($border==1) ? 'B' : 'f'; |
|
| 605 | - else |
|
| 606 | - $op = 'S'; |
|
| 644 | + if($fill) { |
|
| 645 | + $op = ($border==1) ? 'B' : 'f'; |
|
| 646 | + } else { |
|
| 647 | + $op = 'S'; |
|
| 648 | + } |
|
| 607 | 649 | $s = sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op); |
| 608 | 650 | } |
| 609 | 651 | if(is_string($border)) |
| 610 | 652 | { |
| 611 | 653 | $x = $this->x; |
| 612 | 654 | $y = $this->y; |
| 613 | - if(strpos($border,'L')!==false) |
|
| 614 | - $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); |
|
| 615 | - if(strpos($border,'T')!==false) |
|
| 616 | - $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); |
|
| 617 | - if(strpos($border,'R')!==false) |
|
| 618 | - $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
| 619 | - if(strpos($border,'B')!==false) |
|
| 620 | - $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
| 655 | + if(strpos($border,'L')!==false) { |
|
| 656 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); |
|
| 657 | + } |
|
| 658 | + if(strpos($border,'T')!==false) { |
|
| 659 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); |
|
| 660 | + } |
|
| 661 | + if(strpos($border,'R')!==false) { |
|
| 662 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
| 663 | + } |
|
| 664 | + if(strpos($border,'B')!==false) { |
|
| 665 | + $s .= sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); |
|
| 666 | + } |
|
| 621 | 667 | } |
| 622 | 668 | if($txt!=='') |
| 623 | 669 | { |
| 624 | - if(!isset($this->CurrentFont)) |
|
| 625 | - $this->Error('No font has been set'); |
|
| 626 | - if($align=='R') |
|
| 627 | - $dx = $w-$this->cMargin-$this->GetStringWidth($txt); |
|
| 628 | - elseif($align=='C') |
|
| 629 | - $dx = ($w-$this->GetStringWidth($txt))/2; |
|
| 630 | - else |
|
| 631 | - $dx = $this->cMargin; |
|
| 632 | - if($this->ColorFlag) |
|
| 633 | - $s .= 'q '.$this->TextColor.' '; |
|
| 670 | + if(!isset($this->CurrentFont)) { |
|
| 671 | + $this->Error('No font has been set'); |
|
| 672 | + } |
|
| 673 | + if($align=='R') { |
|
| 674 | + $dx = $w-$this->cMargin-$this->GetStringWidth($txt); |
|
| 675 | + } elseif($align=='C') { |
|
| 676 | + $dx = ($w-$this->GetStringWidth($txt))/2; |
|
| 677 | + } else { |
|
| 678 | + $dx = $this->cMargin; |
|
| 679 | + } |
|
| 680 | + if($this->ColorFlag) { |
|
| 681 | + $s .= 'q '.$this->TextColor.' '; |
|
| 682 | + } |
|
| 634 | 683 | $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)); |
| 635 | - if($this->underline) |
|
| 636 | - $s .= ' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); |
|
| 637 | - if($this->ColorFlag) |
|
| 638 | - $s .= ' Q'; |
|
| 639 | - if($link) |
|
| 640 | - $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link); |
|
| 641 | - } |
|
| 642 | - if($s) |
|
| 643 | - $this->_out($s); |
|
| 684 | + if($this->underline) { |
|
| 685 | + $s .= ' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); |
|
| 686 | + } |
|
| 687 | + if($this->ColorFlag) { |
|
| 688 | + $s .= ' Q'; |
|
| 689 | + } |
|
| 690 | + if($link) { |
|
| 691 | + $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link); |
|
| 692 | + } |
|
| 693 | + } |
|
| 694 | + if($s) { |
|
| 695 | + $this->_out($s); |
|
| 696 | + } |
|
| 644 | 697 | $this->lasth = $h; |
| 645 | 698 | if($ln>0) |
| 646 | 699 | { |
| 647 | 700 | // Go to next line |
| 648 | 701 | $this->y += $h; |
| 649 | - if($ln==1) |
|
| 650 | - $this->x = $this->lMargin; |
|
| 702 | + if($ln==1) { |
|
| 703 | + $this->x = $this->lMargin; |
|
| 704 | + } |
|
| 705 | + } else { |
|
| 706 | + $this->x += $w; |
|
| 707 | + } |
|
| 651 | 708 | } |
| 652 | - else |
|
| 653 | - $this->x += $w; |
|
| 654 | -} |
|
| 655 | 709 | |
| 656 | 710 | function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false) |
| 657 | 711 | { |
| 658 | 712 | // Output text with automatic or explicit line breaks |
| 659 | - if(!isset($this->CurrentFont)) |
|
| 660 | - $this->Error('No font has been set'); |
|
| 713 | + if(!isset($this->CurrentFont)) { |
|
| 714 | + $this->Error('No font has been set'); |
|
| 715 | + } |
|
| 661 | 716 | $cw = &$this->CurrentFont['cw']; |
| 662 | - if($w==0) |
|
| 663 | - $w = $this->w-$this->rMargin-$this->x; |
|
| 717 | + if($w==0) { |
|
| 718 | + $w = $this->w-$this->rMargin-$this->x; |
|
| 719 | + } |
|
| 664 | 720 | $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; |
| 665 | 721 | $s = str_replace("\r",'',$txt); |
| 666 | 722 | $nb = strlen($s); |
| 667 | - if($nb>0 && $s[$nb-1]=="\n") |
|
| 668 | - $nb--; |
|
| 723 | + if($nb>0 && $s[$nb-1]=="\n") { |
|
| 724 | + $nb--; |
|
| 725 | + } |
|
| 669 | 726 | $b = 0; |
| 670 | 727 | if($border) |
| 671 | 728 | { |
@@ -674,14 +731,15 @@ discard block |
||
| 674 | 731 | $border = 'LTRB'; |
| 675 | 732 | $b = 'LRT'; |
| 676 | 733 | $b2 = 'LR'; |
| 677 | - } |
|
| 678 | - else |
|
| 734 | + } else |
|
| 679 | 735 | { |
| 680 | 736 | $b2 = ''; |
| 681 | - if(strpos($border,'L')!==false) |
|
| 682 | - $b2 .= 'L'; |
|
| 683 | - if(strpos($border,'R')!==false) |
|
| 684 | - $b2 .= 'R'; |
|
| 737 | + if(strpos($border,'L')!==false) { |
|
| 738 | + $b2 .= 'L'; |
|
| 739 | + } |
|
| 740 | + if(strpos($border,'R')!==false) { |
|
| 741 | + $b2 .= 'R'; |
|
| 742 | + } |
|
| 685 | 743 | $b = (strpos($border,'T')!==false) ? $b2.'T' : $b2; |
| 686 | 744 | } |
| 687 | 745 | } |
@@ -710,8 +768,9 @@ discard block |
||
| 710 | 768 | $l = 0; |
| 711 | 769 | $ns = 0; |
| 712 | 770 | $nl++; |
| 713 | - if($border && $nl==2) |
|
| 714 | - $b = $b2; |
|
| 771 | + if($border && $nl==2) { |
|
| 772 | + $b = $b2; |
|
| 773 | + } |
|
| 715 | 774 | continue; |
| 716 | 775 | } |
| 717 | 776 | if($c==' ') |
@@ -726,16 +785,16 @@ discard block |
||
| 726 | 785 | // Automatic line break |
| 727 | 786 | if($sep==-1) |
| 728 | 787 | { |
| 729 | - if($i==$j) |
|
| 730 | - $i++; |
|
| 788 | + if($i==$j) { |
|
| 789 | + $i++; |
|
| 790 | + } |
|
| 731 | 791 | if($this->ws>0) |
| 732 | 792 | { |
| 733 | 793 | $this->ws = 0; |
| 734 | 794 | $this->_out('0 Tw'); |
| 735 | 795 | } |
| 736 | 796 | $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
| 737 | - } |
|
| 738 | - else |
|
| 797 | + } else |
|
| 739 | 798 | { |
| 740 | 799 | if($align=='J') |
| 741 | 800 | { |
@@ -750,11 +809,12 @@ discard block |
||
| 750 | 809 | $l = 0; |
| 751 | 810 | $ns = 0; |
| 752 | 811 | $nl++; |
| 753 | - if($border && $nl==2) |
|
| 754 | - $b = $b2; |
|
| 812 | + if($border && $nl==2) { |
|
| 813 | + $b = $b2; |
|
| 814 | + } |
|
| 815 | + } else { |
|
| 816 | + $i++; |
|
| 755 | 817 | } |
| 756 | - else |
|
| 757 | - $i++; |
|
| 758 | 818 | } |
| 759 | 819 | // Last chunk |
| 760 | 820 | if($this->ws>0) |
@@ -762,8 +822,9 @@ discard block |
||
| 762 | 822 | $this->ws = 0; |
| 763 | 823 | $this->_out('0 Tw'); |
| 764 | 824 | } |
| 765 | - if($border && strpos($border,'B')!==false) |
|
| 766 | - $b .= 'B'; |
|
| 825 | + if($border && strpos($border,'B')!==false) { |
|
| 826 | + $b .= 'B'; |
|
| 827 | + } |
|
| 767 | 828 | $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); |
| 768 | 829 | $this->x = $this->lMargin; |
| 769 | 830 | } |
@@ -771,8 +832,9 @@ discard block |
||
| 771 | 832 | function Write($h, $txt, $link='') |
| 772 | 833 | { |
| 773 | 834 | // Output text in flowing mode |
| 774 | - if(!isset($this->CurrentFont)) |
|
| 775 | - $this->Error('No font has been set'); |
|
| 835 | + if(!isset($this->CurrentFont)) { |
|
| 836 | + $this->Error('No font has been set'); |
|
| 837 | + } |
|
| 776 | 838 | $cw = &$this->CurrentFont['cw']; |
| 777 | 839 | $w = $this->w-$this->rMargin-$this->x; |
| 778 | 840 | $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; |
@@ -804,8 +866,9 @@ discard block |
||
| 804 | 866 | $nl++; |
| 805 | 867 | continue; |
| 806 | 868 | } |
| 807 | - if($c==' ') |
|
| 808 | - $sep = $i; |
|
| 869 | + if($c==' ') { |
|
| 870 | + $sep = $i; |
|
| 871 | + } |
|
| 809 | 872 | $l += $cw[$c]; |
| 810 | 873 | if($l>$wmax) |
| 811 | 874 | { |
@@ -823,11 +886,11 @@ discard block |
||
| 823 | 886 | $nl++; |
| 824 | 887 | continue; |
| 825 | 888 | } |
| 826 | - if($i==$j) |
|
| 827 | - $i++; |
|
| 889 | + if($i==$j) { |
|
| 890 | + $i++; |
|
| 891 | + } |
|
| 828 | 892 | $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',false,$link); |
| 829 | - } |
|
| 830 | - else |
|
| 893 | + } else |
|
| 831 | 894 | { |
| 832 | 895 | $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',false,$link); |
| 833 | 896 | $i = $sep+1; |
@@ -842,52 +905,58 @@ discard block |
||
| 842 | 905 | $wmax = ($w-2*$this->cMargin)*1000/$this->FontSize; |
| 843 | 906 | } |
| 844 | 907 | $nl++; |
| 908 | + } else { |
|
| 909 | + $i++; |
|
| 845 | 910 | } |
| 846 | - else |
|
| 847 | - $i++; |
|
| 848 | 911 | } |
| 849 | 912 | // Last chunk |
| 850 | - if($i!=$j) |
|
| 851 | - $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',false,$link); |
|
| 852 | -} |
|
| 913 | + if($i!=$j) { |
|
| 914 | + $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j),0,0,'',false,$link); |
|
| 915 | + } |
|
| 916 | + } |
|
| 853 | 917 | |
| 854 | 918 | function Ln($h=null) |
| 855 | 919 | { |
| 856 | 920 | // Line feed; default value is the last cell height |
| 857 | 921 | $this->x = $this->lMargin; |
| 858 | - if($h===null) |
|
| 859 | - $this->y += $this->lasth; |
|
| 860 | - else |
|
| 861 | - $this->y += $h; |
|
| 862 | -} |
|
| 922 | + if($h===null) { |
|
| 923 | + $this->y += $this->lasth; |
|
| 924 | + } else { |
|
| 925 | + $this->y += $h; |
|
| 926 | + } |
|
| 927 | + } |
|
| 863 | 928 | |
| 864 | 929 | function Image($file, $x=null, $y=null, $w=0, $h=0, $type='', $link='') |
| 865 | 930 | { |
| 866 | 931 | // Put an image on the page |
| 867 | - if($file=='') |
|
| 868 | - $this->Error('Image file name is empty'); |
|
| 932 | + if($file=='') { |
|
| 933 | + $this->Error('Image file name is empty'); |
|
| 934 | + } |
|
| 869 | 935 | if(!isset($this->images[$file])) |
| 870 | 936 | { |
| 871 | 937 | // First use of this image, get info |
| 872 | 938 | if($type=='') |
| 873 | 939 | { |
| 874 | 940 | $pos = strrpos($file,'.'); |
| 875 | - if(!$pos) |
|
| 876 | - $this->Error('Image file has no extension and no type was specified: '.$file); |
|
| 941 | + if(!$pos) { |
|
| 942 | + $this->Error('Image file has no extension and no type was specified: '.$file); |
|
| 943 | + } |
|
| 877 | 944 | $type = substr($file,$pos+1); |
| 878 | 945 | } |
| 879 | 946 | $type = strtolower($type); |
| 880 | - if($type=='jpeg') |
|
| 881 | - $type = 'jpg'; |
|
| 947 | + if($type=='jpeg') { |
|
| 948 | + $type = 'jpg'; |
|
| 949 | + } |
|
| 882 | 950 | $mtd = '_parse'.$type; |
| 883 | - if(!method_exists($this,$mtd)) |
|
| 884 | - $this->Error('Unsupported image type: '.$type); |
|
| 951 | + if(!method_exists($this,$mtd)) { |
|
| 952 | + $this->Error('Unsupported image type: '.$type); |
|
| 953 | + } |
|
| 885 | 954 | $info = $this->$mtd($file); |
| 886 | 955 | $info['i'] = count($this->images)+1; |
| 887 | 956 | $this->images[$file] = $info; |
| 957 | + } else { |
|
| 958 | + $info = $this->images[$file]; |
|
| 888 | 959 | } |
| 889 | - else |
|
| 890 | - $info = $this->images[$file]; |
|
| 891 | 960 | |
| 892 | 961 | // Automatic width and height calculation if needed |
| 893 | 962 | if($w==0 && $h==0) |
@@ -896,14 +965,18 @@ discard block |
||
| 896 | 965 | $w = -96; |
| 897 | 966 | $h = -96; |
| 898 | 967 | } |
| 899 | - if($w<0) |
|
| 900 | - $w = -$info['w']*72/$w/$this->k; |
|
| 901 | - if($h<0) |
|
| 902 | - $h = -$info['h']*72/$h/$this->k; |
|
| 903 | - if($w==0) |
|
| 904 | - $w = $h*$info['w']/$info['h']; |
|
| 905 | - if($h==0) |
|
| 906 | - $h = $w*$info['h']/$info['w']; |
|
| 968 | + if($w<0) { |
|
| 969 | + $w = -$info['w']*72/$w/$this->k; |
|
| 970 | + } |
|
| 971 | + if($h<0) { |
|
| 972 | + $h = -$info['h']*72/$h/$this->k; |
|
| 973 | + } |
|
| 974 | + if($w==0) { |
|
| 975 | + $w = $h*$info['w']/$info['h']; |
|
| 976 | + } |
|
| 977 | + if($h==0) { |
|
| 978 | + $h = $w*$info['h']/$info['w']; |
|
| 979 | + } |
|
| 907 | 980 | |
| 908 | 981 | // Flowing mode |
| 909 | 982 | if($y===null) |
@@ -919,12 +992,14 @@ discard block |
||
| 919 | 992 | $this->y += $h; |
| 920 | 993 | } |
| 921 | 994 | |
| 922 | - if($x===null) |
|
| 923 | - $x = $this->x; |
|
| 995 | + if($x===null) { |
|
| 996 | + $x = $this->x; |
|
| 997 | + } |
|
| 924 | 998 | $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'])); |
| 925 | - if($link) |
|
| 926 | - $this->Link($x,$y,$w,$h,$link); |
|
| 927 | -} |
|
| 999 | + if($link) { |
|
| 1000 | + $this->Link($x,$y,$w,$h,$link); |
|
| 1001 | + } |
|
| 1002 | + } |
|
| 928 | 1003 | |
| 929 | 1004 | function GetPageWidth() |
| 930 | 1005 | { |
@@ -947,11 +1022,12 @@ discard block |
||
| 947 | 1022 | function SetX($x) |
| 948 | 1023 | { |
| 949 | 1024 | // Set x position |
| 950 | - if($x>=0) |
|
| 951 | - $this->x = $x; |
|
| 952 | - else |
|
| 953 | - $this->x = $this->w+$x; |
|
| 954 | -} |
|
| 1025 | + if($x>=0) { |
|
| 1026 | + $this->x = $x; |
|
| 1027 | + } else { |
|
| 1028 | + $this->x = $this->w+$x; |
|
| 1029 | + } |
|
| 1030 | + } |
|
| 955 | 1031 | |
| 956 | 1032 | function GetY() |
| 957 | 1033 | { |
@@ -962,13 +1038,15 @@ discard block |
||
| 962 | 1038 | function SetY($y, $resetX=true) |
| 963 | 1039 | { |
| 964 | 1040 | // Set y position and optionally reset x |
| 965 | - if($y>=0) |
|
| 966 | - $this->y = $y; |
|
| 967 | - else |
|
| 968 | - $this->y = $this->h+$y; |
|
| 969 | - if($resetX) |
|
| 970 | - $this->x = $this->lMargin; |
|
| 971 | -} |
|
| 1041 | + if($y>=0) { |
|
| 1042 | + $this->y = $y; |
|
| 1043 | + } else { |
|
| 1044 | + $this->y = $this->h+$y; |
|
| 1045 | + } |
|
| 1046 | + if($resetX) { |
|
| 1047 | + $this->x = $this->lMargin; |
|
| 1048 | + } |
|
| 1049 | + } |
|
| 972 | 1050 | |
| 973 | 1051 | function SetXY($x, $y) |
| 974 | 1052 | { |
@@ -988,10 +1066,12 @@ discard block |
||
| 988 | 1066 | $dest = $name; |
| 989 | 1067 | $name = $tmp; |
| 990 | 1068 | } |
| 991 | - if($dest=='') |
|
| 992 | - $dest = 'I'; |
|
| 993 | - if($name=='') |
|
| 994 | - $name = 'doc.pdf'; |
|
| 1069 | + if($dest=='') { |
|
| 1070 | + $dest = 'I'; |
|
| 1071 | + } |
|
| 1072 | + if($name=='') { |
|
| 1073 | + $name = 'doc.pdf'; |
|
| 1074 | + } |
|
| 995 | 1075 | switch(strtoupper($dest)) |
| 996 | 1076 | { |
| 997 | 1077 | case 'I': |
@@ -1018,8 +1098,9 @@ discard block |
||
| 1018 | 1098 | break; |
| 1019 | 1099 | case 'F': |
| 1020 | 1100 | // Save to local file |
| 1021 | - if(!file_put_contents($name,$this->buffer)) |
|
| 1022 | - $this->Error('Unable to create output file: '.$name); |
|
| 1101 | + if(!file_put_contents($name,$this->buffer)) { |
|
| 1102 | + $this->Error('Unable to create output file: '.$name); |
|
| 1103 | + } |
|
| 1023 | 1104 | break; |
| 1024 | 1105 | case 'S': |
| 1025 | 1106 | // Return as a string |
@@ -1037,16 +1118,18 @@ discard block |
||
| 1037 | 1118 | protected function _dochecks() |
| 1038 | 1119 | { |
| 1039 | 1120 | // Check mbstring overloading |
| 1040 | - if(ini_get('mbstring.func_overload') & 2) |
|
| 1041 | - $this->Error('mbstring overloading must be disabled'); |
|
| 1042 | -} |
|
| 1121 | + if(ini_get('mbstring.func_overload') & 2) { |
|
| 1122 | + $this->Error('mbstring overloading must be disabled'); |
|
| 1123 | + } |
|
| 1124 | + } |
|
| 1043 | 1125 | |
| 1044 | 1126 | protected function _checkoutput() |
| 1045 | 1127 | { |
| 1046 | 1128 | if(PHP_SAPI!='cli') |
| 1047 | 1129 | { |
| 1048 | - if(headers_sent($file,$line)) |
|
| 1049 | - $this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)"); |
|
| 1130 | + if(headers_sent($file,$line)) { |
|
| 1131 | + $this->Error("Some data has already been output, can't send PDF file (output started at $file:$line)"); |
|
| 1132 | + } |
|
| 1050 | 1133 | } |
| 1051 | 1134 | if(ob_get_length()) |
| 1052 | 1135 | { |
@@ -1055,9 +1138,9 @@ discard block |
||
| 1055 | 1138 | { |
| 1056 | 1139 | // It contains only a UTF-8 BOM and/or whitespace, let's clean it |
| 1057 | 1140 | ob_clean(); |
| 1141 | + } else { |
|
| 1142 | + $this->Error("Some data has already been output, can't send PDF file"); |
|
| 1058 | 1143 | } |
| 1059 | - else |
|
| 1060 | - $this->Error("Some data has already been output, can't send PDF file"); |
|
| 1061 | 1144 | } |
| 1062 | 1145 | } |
| 1063 | 1146 | |
@@ -1066,17 +1149,18 @@ discard block |
||
| 1066 | 1149 | if(is_string($size)) |
| 1067 | 1150 | { |
| 1068 | 1151 | $size = strtolower($size); |
| 1069 | - if(!isset($this->StdPageSizes[$size])) |
|
| 1070 | - $this->Error('Unknown page size: '.$size); |
|
| 1152 | + if(!isset($this->StdPageSizes[$size])) { |
|
| 1153 | + $this->Error('Unknown page size: '.$size); |
|
| 1154 | + } |
|
| 1071 | 1155 | $a = $this->StdPageSizes[$size]; |
| 1072 | 1156 | return array($a[0]/$this->k, $a[1]/$this->k); |
| 1073 | - } |
|
| 1074 | - else |
|
| 1157 | + } else |
|
| 1075 | 1158 | { |
| 1076 | - if($size[0]>$size[1]) |
|
| 1077 | - return array($size[1], $size[0]); |
|
| 1078 | - else |
|
| 1079 | - return $size; |
|
| 1159 | + if($size[0]>$size[1]) { |
|
| 1160 | + return array($size[1], $size[0]); |
|
| 1161 | + } else { |
|
| 1162 | + return $size; |
|
| 1163 | + } |
|
| 1080 | 1164 | } |
| 1081 | 1165 | } |
| 1082 | 1166 | |
@@ -1090,14 +1174,16 @@ discard block |
||
| 1090 | 1174 | $this->y = $this->tMargin; |
| 1091 | 1175 | $this->FontFamily = ''; |
| 1092 | 1176 | // Check page size and orientation |
| 1093 | - if($orientation=='') |
|
| 1094 | - $orientation = $this->DefOrientation; |
|
| 1095 | - else |
|
| 1096 | - $orientation = strtoupper($orientation[0]); |
|
| 1097 | - if($size=='') |
|
| 1098 | - $size = $this->DefPageSize; |
|
| 1099 | - else |
|
| 1100 | - $size = $this->_getpagesize($size); |
|
| 1177 | + if($orientation=='') { |
|
| 1178 | + $orientation = $this->DefOrientation; |
|
| 1179 | + } else { |
|
| 1180 | + $orientation = strtoupper($orientation[0]); |
|
| 1181 | + } |
|
| 1182 | + if($size=='') { |
|
| 1183 | + $size = $this->DefPageSize; |
|
| 1184 | + } else { |
|
| 1185 | + $size = $this->_getpagesize($size); |
|
| 1186 | + } |
|
| 1101 | 1187 | if($orientation!=$this->CurOrientation || $size[0]!=$this->CurPageSize[0] || $size[1]!=$this->CurPageSize[1]) |
| 1102 | 1188 | { |
| 1103 | 1189 | // New size or orientation |
@@ -1105,8 +1191,7 @@ discard block |
||
| 1105 | 1191 | { |
| 1106 | 1192 | $this->w = $size[0]; |
| 1107 | 1193 | $this->h = $size[1]; |
| 1108 | - } |
|
| 1109 | - else |
|
| 1194 | + } else |
|
| 1110 | 1195 | { |
| 1111 | 1196 | $this->w = $size[1]; |
| 1112 | 1197 | $this->h = $size[0]; |
@@ -1117,12 +1202,14 @@ discard block |
||
| 1117 | 1202 | $this->CurOrientation = $orientation; |
| 1118 | 1203 | $this->CurPageSize = $size; |
| 1119 | 1204 | } |
| 1120 | - if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1]) |
|
| 1121 | - $this->PageInfo[$this->page]['size'] = array($this->wPt, $this->hPt); |
|
| 1205 | + if($orientation!=$this->DefOrientation || $size[0]!=$this->DefPageSize[0] || $size[1]!=$this->DefPageSize[1]) { |
|
| 1206 | + $this->PageInfo[$this->page]['size'] = array($this->wPt, $this->hPt); |
|
| 1207 | + } |
|
| 1122 | 1208 | if($rotation!=0) |
| 1123 | 1209 | { |
| 1124 | - if($rotation%90!=0) |
|
| 1125 | - $this->Error('Incorrect rotation value: '.$rotation); |
|
| 1210 | + if($rotation%90!=0) { |
|
| 1211 | + $this->Error('Incorrect rotation value: '.$rotation); |
|
| 1212 | + } |
|
| 1126 | 1213 | $this->CurRotation = $rotation; |
| 1127 | 1214 | $this->PageInfo[$this->page]['rotation'] = $rotation; |
| 1128 | 1215 | } |
@@ -1136,15 +1223,19 @@ discard block |
||
| 1136 | 1223 | protected function _loadfont($font) |
| 1137 | 1224 | { |
| 1138 | 1225 | // Load a font definition file from the font directory |
| 1139 | - if(strpos($font,'/')!==false || strpos($font,"\\")!==false) |
|
| 1140 | - $this->Error('Incorrect font definition file name: '.$font); |
|
| 1226 | + if(strpos($font,'/')!==false || strpos($font,"\\")!==false) { |
|
| 1227 | + $this->Error('Incorrect font definition file name: '.$font); |
|
| 1228 | + } |
|
| 1141 | 1229 | include($this->fontpath.$font); |
| 1142 | - if(!isset($name)) |
|
| 1143 | - $this->Error('Could not include font definition file'); |
|
| 1144 | - if(isset($enc)) |
|
| 1145 | - $enc = strtolower($enc); |
|
| 1146 | - if(!isset($subsetted)) |
|
| 1147 | - $subsetted = false; |
|
| 1230 | + if(!isset($name)) { |
|
| 1231 | + $this->Error('Could not include font definition file'); |
|
| 1232 | + } |
|
| 1233 | + if(isset($enc)) { |
|
| 1234 | + $enc = strtolower($enc); |
|
| 1235 | + } |
|
| 1236 | + if(!isset($subsetted)) { |
|
| 1237 | + $subsetted = false; |
|
| 1238 | + } |
|
| 1148 | 1239 | return get_defined_vars(); |
| 1149 | 1240 | } |
| 1150 | 1241 | |
@@ -1154,8 +1245,9 @@ discard block |
||
| 1154 | 1245 | $nb = strlen($s); |
| 1155 | 1246 | for($i=0;$i<$nb;$i++) |
| 1156 | 1247 | { |
| 1157 | - if(ord($s[$i])>127) |
|
| 1158 | - return false; |
|
| 1248 | + if(ord($s[$i])>127) { |
|
| 1249 | + return false; |
|
| 1250 | + } |
|
| 1159 | 1251 | } |
| 1160 | 1252 | return true; |
| 1161 | 1253 | } |
@@ -1163,15 +1255,18 @@ discard block |
||
| 1163 | 1255 | protected function _httpencode($param, $value, $isUTF8) |
| 1164 | 1256 | { |
| 1165 | 1257 | // Encode HTTP header field parameter |
| 1166 | - if($this->_isascii($value)) |
|
| 1167 | - return $param.'="'.$value.'"'; |
|
| 1168 | - if(!$isUTF8) |
|
| 1169 | - $value = utf8_encode($value); |
|
| 1170 | - if(strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')!==false) |
|
| 1171 | - return $param.'="'.rawurlencode($value).'"'; |
|
| 1172 | - else |
|
| 1173 | - return $param."*=UTF-8''".rawurlencode($value); |
|
| 1174 | -} |
|
| 1258 | + if($this->_isascii($value)) { |
|
| 1259 | + return $param.'="'.$value.'"'; |
|
| 1260 | + } |
|
| 1261 | + if(!$isUTF8) { |
|
| 1262 | + $value = utf8_encode($value); |
|
| 1263 | + } |
|
| 1264 | + if(strpos($_SERVER['HTTP_USER_AGENT'],'MSIE')!==false) { |
|
| 1265 | + return $param.'="'.rawurlencode($value).'"'; |
|
| 1266 | + } else { |
|
| 1267 | + return $param."*=UTF-8''".rawurlencode($value); |
|
| 1268 | + } |
|
| 1269 | + } |
|
| 1175 | 1270 | |
| 1176 | 1271 | protected function _UTF8toUTF16($s) |
| 1177 | 1272 | { |
@@ -1189,15 +1284,13 @@ discard block |
||
| 1189 | 1284 | $c3 = ord($s[$i++]); |
| 1190 | 1285 | $res .= chr((($c1 & 0x0F)<<4) + (($c2 & 0x3C)>>2)); |
| 1191 | 1286 | $res .= chr((($c2 & 0x03)<<6) + ($c3 & 0x3F)); |
| 1192 | - } |
|
| 1193 | - elseif($c1>=192) |
|
| 1287 | + } elseif($c1>=192) |
|
| 1194 | 1288 | { |
| 1195 | 1289 | // 2-byte character |
| 1196 | 1290 | $c2 = ord($s[$i++]); |
| 1197 | 1291 | $res .= chr(($c1 & 0x1C)>>2); |
| 1198 | 1292 | $res .= chr((($c1 & 0x03)<<6) + ($c2 & 0x3F)); |
| 1199 | - } |
|
| 1200 | - else |
|
| 1293 | + } else |
|
| 1201 | 1294 | { |
| 1202 | 1295 | // Single-byte character |
| 1203 | 1296 | $res .= "\0".chr($c1); |
@@ -1209,17 +1302,19 @@ discard block |
||
| 1209 | 1302 | protected function _escape($s) |
| 1210 | 1303 | { |
| 1211 | 1304 | // Escape special characters |
| 1212 | - if(strpos($s,'(')!==false || strpos($s,')')!==false || strpos($s,'\\')!==false || strpos($s,"\r")!==false) |
|
| 1213 | - return str_replace(array('\\','(',')',"\r"), array('\\\\','\\(','\\)','\\r'), $s); |
|
| 1214 | - else |
|
| 1215 | - return $s; |
|
| 1216 | -} |
|
| 1305 | + if(strpos($s,'(')!==false || strpos($s,')')!==false || strpos($s,'\\')!==false || strpos($s,"\r")!==false) { |
|
| 1306 | + return str_replace(array('\\','(',')',"\r"), array('\\\\','\\(','\\)','\\r'), $s); |
|
| 1307 | + } else { |
|
| 1308 | + return $s; |
|
| 1309 | + } |
|
| 1310 | + } |
|
| 1217 | 1311 | |
| 1218 | 1312 | protected function _textstring($s) |
| 1219 | 1313 | { |
| 1220 | 1314 | // Format a text string |
| 1221 | - if(!$this->_isascii($s)) |
|
| 1222 | - $s = $this->_UTF8toUTF16($s); |
|
| 1315 | + if(!$this->_isascii($s)) { |
|
| 1316 | + $s = $this->_UTF8toUTF16($s); |
|
| 1317 | + } |
|
| 1223 | 1318 | return '('.$this->_escape($s).')'; |
| 1224 | 1319 | } |
| 1225 | 1320 | |
@@ -1236,16 +1331,19 @@ discard block |
||
| 1236 | 1331 | { |
| 1237 | 1332 | // Extract info from a JPEG file |
| 1238 | 1333 | $a = getimagesize($file); |
| 1239 | - if(!$a) |
|
| 1240 | - $this->Error('Missing or incorrect image file: '.$file); |
|
| 1241 | - if($a[2]!=2) |
|
| 1242 | - $this->Error('Not a JPEG file: '.$file); |
|
| 1243 | - if(!isset($a['channels']) || $a['channels']==3) |
|
| 1244 | - $colspace = 'DeviceRGB'; |
|
| 1245 | - elseif($a['channels']==4) |
|
| 1246 | - $colspace = 'DeviceCMYK'; |
|
| 1247 | - else |
|
| 1248 | - $colspace = 'DeviceGray'; |
|
| 1334 | + if(!$a) { |
|
| 1335 | + $this->Error('Missing or incorrect image file: '.$file); |
|
| 1336 | + } |
|
| 1337 | + if($a[2]!=2) { |
|
| 1338 | + $this->Error('Not a JPEG file: '.$file); |
|
| 1339 | + } |
|
| 1340 | + if(!isset($a['channels']) || $a['channels']==3) { |
|
| 1341 | + $colspace = 'DeviceRGB'; |
|
| 1342 | + } elseif($a['channels']==4) { |
|
| 1343 | + $colspace = 'DeviceCMYK'; |
|
| 1344 | + } else { |
|
| 1345 | + $colspace = 'DeviceGray'; |
|
| 1346 | + } |
|
| 1249 | 1347 | $bpc = isset($a['bits']) ? $a['bits'] : 8; |
| 1250 | 1348 | $data = file_get_contents($file); |
| 1251 | 1349 | return array('w'=>$a[0], 'h'=>$a[1], 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'DCTDecode', 'data'=>$data); |
@@ -1255,8 +1353,9 @@ discard block |
||
| 1255 | 1353 | { |
| 1256 | 1354 | // Extract info from a PNG file |
| 1257 | 1355 | $f = fopen($file,'rb'); |
| 1258 | - if(!$f) |
|
| 1259 | - $this->Error('Can\'t open image file: '.$file); |
|
| 1356 | + if(!$f) { |
|
| 1357 | + $this->Error('Can\'t open image file: '.$file); |
|
| 1358 | + } |
|
| 1260 | 1359 | $info = $this->_parsepngstream($f,$file); |
| 1261 | 1360 | fclose($f); |
| 1262 | 1361 | return $info; |
@@ -1265,33 +1364,40 @@ discard block |
||
| 1265 | 1364 | protected function _parsepngstream($f, $file) |
| 1266 | 1365 | { |
| 1267 | 1366 | // Check signature |
| 1268 | - if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) |
|
| 1269 | - $this->Error('Not a PNG file: '.$file); |
|
| 1367 | + if($this->_readstream($f,8)!=chr(137).'PNG'.chr(13).chr(10).chr(26).chr(10)) { |
|
| 1368 | + $this->Error('Not a PNG file: '.$file); |
|
| 1369 | + } |
|
| 1270 | 1370 | |
| 1271 | 1371 | // Read header chunk |
| 1272 | 1372 | $this->_readstream($f,4); |
| 1273 | - if($this->_readstream($f,4)!='IHDR') |
|
| 1274 | - $this->Error('Incorrect PNG file: '.$file); |
|
| 1373 | + if($this->_readstream($f,4)!='IHDR') { |
|
| 1374 | + $this->Error('Incorrect PNG file: '.$file); |
|
| 1375 | + } |
|
| 1275 | 1376 | $w = $this->_readint($f); |
| 1276 | 1377 | $h = $this->_readint($f); |
| 1277 | 1378 | $bpc = ord($this->_readstream($f,1)); |
| 1278 | - if($bpc>8) |
|
| 1279 | - $this->Error('16-bit depth not supported: '.$file); |
|
| 1379 | + if($bpc>8) { |
|
| 1380 | + $this->Error('16-bit depth not supported: '.$file); |
|
| 1381 | + } |
|
| 1280 | 1382 | $ct = ord($this->_readstream($f,1)); |
| 1281 | - if($ct==0 || $ct==4) |
|
| 1282 | - $colspace = 'DeviceGray'; |
|
| 1283 | - elseif($ct==2 || $ct==6) |
|
| 1284 | - $colspace = 'DeviceRGB'; |
|
| 1285 | - elseif($ct==3) |
|
| 1286 | - $colspace = 'Indexed'; |
|
| 1287 | - else |
|
| 1288 | - $this->Error('Unknown color type: '.$file); |
|
| 1289 | - if(ord($this->_readstream($f,1))!=0) |
|
| 1290 | - $this->Error('Unknown compression method: '.$file); |
|
| 1291 | - if(ord($this->_readstream($f,1))!=0) |
|
| 1292 | - $this->Error('Unknown filter method: '.$file); |
|
| 1293 | - if(ord($this->_readstream($f,1))!=0) |
|
| 1294 | - $this->Error('Interlacing not supported: '.$file); |
|
| 1383 | + if($ct==0 || $ct==4) { |
|
| 1384 | + $colspace = 'DeviceGray'; |
|
| 1385 | + } elseif($ct==2 || $ct==6) { |
|
| 1386 | + $colspace = 'DeviceRGB'; |
|
| 1387 | + } elseif($ct==3) { |
|
| 1388 | + $colspace = 'Indexed'; |
|
| 1389 | + } else { |
|
| 1390 | + $this->Error('Unknown color type: '.$file); |
|
| 1391 | + } |
|
| 1392 | + if(ord($this->_readstream($f,1))!=0) { |
|
| 1393 | + $this->Error('Unknown compression method: '.$file); |
|
| 1394 | + } |
|
| 1395 | + if(ord($this->_readstream($f,1))!=0) { |
|
| 1396 | + $this->Error('Unknown filter method: '.$file); |
|
| 1397 | + } |
|
| 1398 | + if(ord($this->_readstream($f,1))!=0) { |
|
| 1399 | + $this->Error('Interlacing not supported: '.$file); |
|
| 1400 | + } |
|
| 1295 | 1401 | $this->_readstream($f,4); |
| 1296 | 1402 | $dp = '/Predictor 15 /Colors '.($colspace=='DeviceRGB' ? 3 : 1).' /BitsPerComponent '.$bpc.' /Columns '.$w; |
| 1297 | 1403 | |
@@ -1308,44 +1414,45 @@ discard block |
||
| 1308 | 1414 | // Read palette |
| 1309 | 1415 | $pal = $this->_readstream($f,$n); |
| 1310 | 1416 | $this->_readstream($f,4); |
| 1311 | - } |
|
| 1312 | - elseif($type=='tRNS') |
|
| 1417 | + } elseif($type=='tRNS') |
|
| 1313 | 1418 | { |
| 1314 | 1419 | // Read transparency info |
| 1315 | 1420 | $t = $this->_readstream($f,$n); |
| 1316 | - if($ct==0) |
|
| 1317 | - $trns = array(ord(substr($t,1,1))); |
|
| 1318 | - elseif($ct==2) |
|
| 1319 | - $trns = array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1))); |
|
| 1320 | - else |
|
| 1421 | + if($ct==0) { |
|
| 1422 | + $trns = array(ord(substr($t,1,1))); |
|
| 1423 | + } elseif($ct==2) { |
|
| 1424 | + $trns = array(ord(substr($t,1,1)), ord(substr($t,3,1)), ord(substr($t,5,1))); |
|
| 1425 | + } else |
|
| 1321 | 1426 | { |
| 1322 | 1427 | $pos = strpos($t,chr(0)); |
| 1323 | - if($pos!==false) |
|
| 1324 | - $trns = array($pos); |
|
| 1428 | + if($pos!==false) { |
|
| 1429 | + $trns = array($pos); |
|
| 1430 | + } |
|
| 1325 | 1431 | } |
| 1326 | 1432 | $this->_readstream($f,4); |
| 1327 | - } |
|
| 1328 | - elseif($type=='IDAT') |
|
| 1433 | + } elseif($type=='IDAT') |
|
| 1329 | 1434 | { |
| 1330 | 1435 | // Read image data block |
| 1331 | 1436 | $data .= $this->_readstream($f,$n); |
| 1332 | 1437 | $this->_readstream($f,4); |
| 1438 | + } elseif($type=='IEND') { |
|
| 1439 | + break; |
|
| 1440 | + } else { |
|
| 1441 | + $this->_readstream($f,$n+4); |
|
| 1333 | 1442 | } |
| 1334 | - elseif($type=='IEND') |
|
| 1335 | - break; |
|
| 1336 | - else |
|
| 1337 | - $this->_readstream($f,$n+4); |
|
| 1338 | 1443 | } |
| 1339 | 1444 | while($n); |
| 1340 | 1445 | |
| 1341 | - if($colspace=='Indexed' && empty($pal)) |
|
| 1342 | - $this->Error('Missing palette in '.$file); |
|
| 1446 | + if($colspace=='Indexed' && empty($pal)) { |
|
| 1447 | + $this->Error('Missing palette in '.$file); |
|
| 1448 | + } |
|
| 1343 | 1449 | $info = array('w'=>$w, 'h'=>$h, 'cs'=>$colspace, 'bpc'=>$bpc, 'f'=>'FlateDecode', 'dp'=>$dp, 'pal'=>$pal, 'trns'=>$trns); |
| 1344 | 1450 | if($ct>=4) |
| 1345 | 1451 | { |
| 1346 | 1452 | // Extract alpha channel |
| 1347 | - if(!function_exists('gzuncompress')) |
|
| 1348 | - $this->Error('Zlib not available, can\'t handle alpha channel: '.$file); |
|
| 1453 | + if(!function_exists('gzuncompress')) { |
|
| 1454 | + $this->Error('Zlib not available, can\'t handle alpha channel: '.$file); |
|
| 1455 | + } |
|
| 1349 | 1456 | $data = gzuncompress($data); |
| 1350 | 1457 | $color = ''; |
| 1351 | 1458 | $alpha = ''; |
@@ -1362,8 +1469,7 @@ discard block |
||
| 1362 | 1469 | $color .= preg_replace('/(.)./s','$1',$line); |
| 1363 | 1470 | $alpha .= preg_replace('/.(.)/s','$1',$line); |
| 1364 | 1471 | } |
| 1365 | - } |
|
| 1366 | - else |
|
| 1472 | + } else |
|
| 1367 | 1473 | { |
| 1368 | 1474 | // RGB image |
| 1369 | 1475 | $len = 4*$w; |
@@ -1381,8 +1487,9 @@ discard block |
||
| 1381 | 1487 | $data = gzcompress($color); |
| 1382 | 1488 | $info['smask'] = gzcompress($alpha); |
| 1383 | 1489 | $this->WithAlpha = true; |
| 1384 | - if($this->PDFVersion<'1.4') |
|
| 1385 | - $this->PDFVersion = '1.4'; |
|
| 1490 | + if($this->PDFVersion<'1.4') { |
|
| 1491 | + $this->PDFVersion = '1.4'; |
|
| 1492 | + } |
|
| 1386 | 1493 | } |
| 1387 | 1494 | $info['data'] = $data; |
| 1388 | 1495 | return $info; |
@@ -1395,13 +1502,15 @@ discard block |
||
| 1395 | 1502 | while($n>0 && !feof($f)) |
| 1396 | 1503 | { |
| 1397 | 1504 | $s = fread($f,$n); |
| 1398 | - if($s===false) |
|
| 1399 | - $this->Error('Error while reading stream'); |
|
| 1505 | + if($s===false) { |
|
| 1506 | + $this->Error('Error while reading stream'); |
|
| 1507 | + } |
|
| 1400 | 1508 | $n -= strlen($s); |
| 1401 | 1509 | $res .= $s; |
| 1402 | 1510 | } |
| 1403 | - if($n>0) |
|
| 1404 | - $this->Error('Unexpected end of stream'); |
|
| 1511 | + if($n>0) { |
|
| 1512 | + $this->Error('Unexpected end of stream'); |
|
| 1513 | + } |
|
| 1405 | 1514 | return $res; |
| 1406 | 1515 | } |
| 1407 | 1516 | |
@@ -1415,21 +1524,25 @@ discard block |
||
| 1415 | 1524 | protected function _parsegif($file) |
| 1416 | 1525 | { |
| 1417 | 1526 | // Extract info from a GIF file (via PNG conversion) |
| 1418 | - if(!function_exists('imagepng')) |
|
| 1419 | - $this->Error('GD extension is required for GIF support'); |
|
| 1420 | - if(!function_exists('imagecreatefromgif')) |
|
| 1421 | - $this->Error('GD has no GIF read support'); |
|
| 1527 | + if(!function_exists('imagepng')) { |
|
| 1528 | + $this->Error('GD extension is required for GIF support'); |
|
| 1529 | + } |
|
| 1530 | + if(!function_exists('imagecreatefromgif')) { |
|
| 1531 | + $this->Error('GD has no GIF read support'); |
|
| 1532 | + } |
|
| 1422 | 1533 | $im = imagecreatefromgif($file); |
| 1423 | - if(!$im) |
|
| 1424 | - $this->Error('Missing or incorrect image file: '.$file); |
|
| 1534 | + if(!$im) { |
|
| 1535 | + $this->Error('Missing or incorrect image file: '.$file); |
|
| 1536 | + } |
|
| 1425 | 1537 | imageinterlace($im,0); |
| 1426 | 1538 | ob_start(); |
| 1427 | 1539 | imagepng($im); |
| 1428 | 1540 | $data = ob_get_clean(); |
| 1429 | 1541 | imagedestroy($im); |
| 1430 | 1542 | $f = fopen('php://temp','rb+'); |
| 1431 | - if(!$f) |
|
| 1432 | - $this->Error('Unable to create memory stream'); |
|
| 1543 | + if(!$f) { |
|
| 1544 | + $this->Error('Unable to create memory stream'); |
|
| 1545 | + } |
|
| 1433 | 1546 | fwrite($f,$data); |
| 1434 | 1547 | rewind($f); |
| 1435 | 1548 | $info = $this->_parsepngstream($f,$file); |
@@ -1440,15 +1553,16 @@ discard block |
||
| 1440 | 1553 | protected function _out($s) |
| 1441 | 1554 | { |
| 1442 | 1555 | // Add a line to the document |
| 1443 | - if($this->state==2) |
|
| 1444 | - $this->pages[$this->page] .= $s."\n"; |
|
| 1445 | - elseif($this->state==1) |
|
| 1446 | - $this->_put($s); |
|
| 1447 | - elseif($this->state==0) |
|
| 1448 | - $this->Error('No page has been added yet'); |
|
| 1449 | - elseif($this->state==3) |
|
| 1450 | - $this->Error('The document is closed'); |
|
| 1451 | -} |
|
| 1556 | + if($this->state==2) { |
|
| 1557 | + $this->pages[$this->page] .= $s."\n"; |
|
| 1558 | + } elseif($this->state==1) { |
|
| 1559 | + $this->_put($s); |
|
| 1560 | + } elseif($this->state==0) { |
|
| 1561 | + $this->Error('No page has been added yet'); |
|
| 1562 | + } elseif($this->state==3) { |
|
| 1563 | + $this->Error('The document is closed'); |
|
| 1564 | + } |
|
| 1565 | + } |
|
| 1452 | 1566 | |
| 1453 | 1567 | protected function _put($s) |
| 1454 | 1568 | { |
@@ -1463,8 +1577,9 @@ discard block |
||
| 1463 | 1577 | protected function _newobj($n=null) |
| 1464 | 1578 | { |
| 1465 | 1579 | // Begin a new object |
| 1466 | - if($n===null) |
|
| 1467 | - $n = ++$this->n; |
|
| 1580 | + if($n===null) { |
|
| 1581 | + $n = ++$this->n; |
|
| 1582 | + } |
|
| 1468 | 1583 | $this->offsets[$n] = $this->_getoffset(); |
| 1469 | 1584 | $this->_put($n.' 0 obj'); |
| 1470 | 1585 | } |
@@ -1482,9 +1597,9 @@ discard block |
||
| 1482 | 1597 | { |
| 1483 | 1598 | $entries = '/Filter /FlateDecode '; |
| 1484 | 1599 | $data = gzcompress($data); |
| 1600 | + } else { |
|
| 1601 | + $entries = ''; |
|
| 1485 | 1602 | } |
| 1486 | - else |
|
| 1487 | - $entries = ''; |
|
| 1488 | 1603 | $entries .= '/Length '.strlen($data); |
| 1489 | 1604 | $this->_newobj(); |
| 1490 | 1605 | $this->_put('<<'.$entries.'>>'); |
@@ -1497,41 +1612,47 @@ discard block |
||
| 1497 | 1612 | $this->_newobj(); |
| 1498 | 1613 | $this->_put('<</Type /Page'); |
| 1499 | 1614 | $this->_put('/Parent 1 0 R'); |
| 1500 | - if(isset($this->PageInfo[$n]['size'])) |
|
| 1501 | - $this->_put(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageInfo[$n]['size'][0],$this->PageInfo[$n]['size'][1])); |
|
| 1502 | - if(isset($this->PageInfo[$n]['rotation'])) |
|
| 1503 | - $this->_put('/Rotate '.$this->PageInfo[$n]['rotation']); |
|
| 1615 | + if(isset($this->PageInfo[$n]['size'])) { |
|
| 1616 | + $this->_put(sprintf('/MediaBox [0 0 %.2F %.2F]',$this->PageInfo[$n]['size'][0],$this->PageInfo[$n]['size'][1])); |
|
| 1617 | + } |
|
| 1618 | + if(isset($this->PageInfo[$n]['rotation'])) { |
|
| 1619 | + $this->_put('/Rotate '.$this->PageInfo[$n]['rotation']); |
|
| 1620 | + } |
|
| 1504 | 1621 | $this->_put('/Resources 2 0 R'); |
| 1505 | 1622 | if(!empty($this->PageLinks[$n])) |
| 1506 | 1623 | { |
| 1507 | 1624 | $s = '/Annots ['; |
| 1508 | - foreach($this->PageLinks[$n] as $pl) |
|
| 1509 | - $s .= $pl[5].' 0 R '; |
|
| 1625 | + foreach($this->PageLinks[$n] as $pl) { |
|
| 1626 | + $s .= $pl[5].' 0 R '; |
|
| 1627 | + } |
|
| 1510 | 1628 | $s .= ']'; |
| 1511 | 1629 | $this->_put($s); |
| 1512 | 1630 | } |
| 1513 | - if($this->WithAlpha) |
|
| 1514 | - $this->_put('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>'); |
|
| 1631 | + if($this->WithAlpha) { |
|
| 1632 | + $this->_put('/Group <</Type /Group /S /Transparency /CS /DeviceRGB>>'); |
|
| 1633 | + } |
|
| 1515 | 1634 | $this->_put('/Contents '.($this->n+1).' 0 R>>'); |
| 1516 | 1635 | $this->_put('endobj'); |
| 1517 | 1636 | // Page content |
| 1518 | - if(!empty($this->AliasNbPages)) |
|
| 1519 | - $this->pages[$n] = str_replace($this->AliasNbPages,$this->page,$this->pages[$n]); |
|
| 1637 | + if(!empty($this->AliasNbPages)) { |
|
| 1638 | + $this->pages[$n] = str_replace($this->AliasNbPages,$this->page,$this->pages[$n]); |
|
| 1639 | + } |
|
| 1520 | 1640 | $this->_putstreamobject($this->pages[$n]); |
| 1521 | 1641 | // Annotations |
| 1522 | 1642 | foreach($this->PageLinks[$n] as $pl) |
| 1523 | 1643 | { |
| 1524 | 1644 | $rect = sprintf('%.2F %.2F %.2F %.2F',$pl[0],$pl[1],$pl[0]+$pl[2],$pl[1]-$pl[3]); |
| 1525 | 1645 | $s = '<</Type /Annot /Subtype /Link /Rect ['.$rect.'] /Border [0 0 0] '; |
| 1526 | - if(is_string($pl[4])) |
|
| 1527 | - $s .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>'; |
|
| 1528 | - else |
|
| 1646 | + if(is_string($pl[4])) { |
|
| 1647 | + $s .= '/A <</S /URI /URI '.$this->_textstring($pl[4]).'>>>>'; |
|
| 1648 | + } else |
|
| 1529 | 1649 | { |
| 1530 | 1650 | $l = $this->links[$pl[4]]; |
| 1531 | - if(isset($this->PageInfo[$l[0]]['size'])) |
|
| 1532 | - $h = $this->PageInfo[$l[0]]['size'][1]; |
|
| 1533 | - else |
|
| 1534 | - $h = ($this->DefOrientation=='P') ? $this->DefPageSize[1]*$this->k : $this->DefPageSize[0]*$this->k; |
|
| 1651 | + if(isset($this->PageInfo[$l[0]]['size'])) { |
|
| 1652 | + $h = $this->PageInfo[$l[0]]['size'][1]; |
|
| 1653 | + } else { |
|
| 1654 | + $h = ($this->DefOrientation=='P') ? $this->DefPageSize[1]*$this->k : $this->DefPageSize[0]*$this->k; |
|
| 1655 | + } |
|
| 1535 | 1656 | $s .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>',$this->PageInfo[$l[0]]['n'],$h-$l[1]*$this->k); |
| 1536 | 1657 | } |
| 1537 | 1658 | $this->_newobj(); |
@@ -1548,18 +1669,21 @@ discard block |
||
| 1548 | 1669 | { |
| 1549 | 1670 | $this->PageInfo[$i]['n'] = ++$n; |
| 1550 | 1671 | $n++; |
| 1551 | - foreach($this->PageLinks[$i] as &$pl) |
|
| 1552 | - $pl[5] = ++$n; |
|
| 1672 | + foreach($this->PageLinks[$i] as &$pl) { |
|
| 1673 | + $pl[5] = ++$n; |
|
| 1674 | + } |
|
| 1553 | 1675 | unset($pl); |
| 1554 | 1676 | } |
| 1555 | - for($i=1;$i<=$nb;$i++) |
|
| 1556 | - $this->_putpage($i); |
|
| 1677 | + for($i=1;$i<=$nb;$i++) { |
|
| 1678 | + $this->_putpage($i); |
|
| 1679 | + } |
|
| 1557 | 1680 | // Pages root |
| 1558 | 1681 | $this->_newobj(1); |
| 1559 | 1682 | $this->_put('<</Type /Pages'); |
| 1560 | 1683 | $kids = '/Kids ['; |
| 1561 | - for($i=1;$i<=$nb;$i++) |
|
| 1562 | - $kids .= $this->PageInfo[$i]['n'].' 0 R '; |
|
| 1684 | + for($i=1;$i<=$nb;$i++) { |
|
| 1685 | + $kids .= $this->PageInfo[$i]['n'].' 0 R '; |
|
| 1686 | + } |
|
| 1563 | 1687 | $kids .= ']'; |
| 1564 | 1688 | $this->_put($kids); |
| 1565 | 1689 | $this->_put('/Count '.$nb); |
@@ -1567,8 +1691,7 @@ discard block |
||
| 1567 | 1691 | { |
| 1568 | 1692 | $w = $this->DefPageSize[0]; |
| 1569 | 1693 | $h = $this->DefPageSize[1]; |
| 1570 | - } |
|
| 1571 | - else |
|
| 1694 | + } else |
|
| 1572 | 1695 | { |
| 1573 | 1696 | $w = $this->DefPageSize[1]; |
| 1574 | 1697 | $h = $this->DefPageSize[0]; |
@@ -1586,17 +1709,21 @@ discard block |
||
| 1586 | 1709 | $this->_newobj(); |
| 1587 | 1710 | $this->FontFiles[$file]['n'] = $this->n; |
| 1588 | 1711 | $font = file_get_contents($this->fontpath.$file,true); |
| 1589 | - if(!$font) |
|
| 1590 | - $this->Error('Font file not found: '.$file); |
|
| 1712 | + if(!$font) { |
|
| 1713 | + $this->Error('Font file not found: '.$file); |
|
| 1714 | + } |
|
| 1591 | 1715 | $compressed = (substr($file,-2)=='.z'); |
| 1592 | - if(!$compressed && isset($info['length2'])) |
|
| 1593 | - $font = substr($font,6,$info['length1']).substr($font,6+$info['length1']+6,$info['length2']); |
|
| 1716 | + if(!$compressed && isset($info['length2'])) { |
|
| 1717 | + $font = substr($font,6,$info['length1']).substr($font,6+$info['length1']+6,$info['length2']); |
|
| 1718 | + } |
|
| 1594 | 1719 | $this->_put('<</Length '.strlen($font)); |
| 1595 | - if($compressed) |
|
| 1596 | - $this->_put('/Filter /FlateDecode'); |
|
| 1720 | + if($compressed) { |
|
| 1721 | + $this->_put('/Filter /FlateDecode'); |
|
| 1722 | + } |
|
| 1597 | 1723 | $this->_put('/Length1 '.$info['length1']); |
| 1598 | - if(isset($info['length2'])) |
|
| 1599 | - $this->_put('/Length2 '.$info['length2'].' /Length3 0'); |
|
| 1724 | + if(isset($info['length2'])) { |
|
| 1725 | + $this->_put('/Length2 '.$info['length2'].' /Length3 0'); |
|
| 1726 | + } |
|
| 1600 | 1727 | $this->_put('>>'); |
| 1601 | 1728 | $this->_putstream($font); |
| 1602 | 1729 | $this->_put('endobj'); |
@@ -1617,10 +1744,11 @@ discard block |
||
| 1617 | 1744 | // ToUnicode CMap |
| 1618 | 1745 | if(isset($font['uv'])) |
| 1619 | 1746 | { |
| 1620 | - if(isset($font['enc'])) |
|
| 1621 | - $cmapkey = $font['enc']; |
|
| 1622 | - else |
|
| 1623 | - $cmapkey = $font['name']; |
|
| 1747 | + if(isset($font['enc'])) { |
|
| 1748 | + $cmapkey = $font['enc']; |
|
| 1749 | + } else { |
|
| 1750 | + $cmapkey = $font['name']; |
|
| 1751 | + } |
|
| 1624 | 1752 | if(!isset($this->cmaps[$cmapkey])) |
| 1625 | 1753 | { |
| 1626 | 1754 | $cmap = $this->_tounicodecmap($font['uv']); |
@@ -1632,8 +1760,9 @@ discard block |
||
| 1632 | 1760 | $this->fonts[$k]['n'] = $this->n+1; |
| 1633 | 1761 | $type = $font['type']; |
| 1634 | 1762 | $name = $font['name']; |
| 1635 | - if($font['subsetted']) |
|
| 1636 | - $name = 'AAAAAA+'.$name; |
|
| 1763 | + if($font['subsetted']) { |
|
| 1764 | + $name = 'AAAAAA+'.$name; |
|
| 1765 | + } |
|
| 1637 | 1766 | if($type=='Core') |
| 1638 | 1767 | { |
| 1639 | 1768 | // Core font |
@@ -1641,14 +1770,15 @@ discard block |
||
| 1641 | 1770 | $this->_put('<</Type /Font'); |
| 1642 | 1771 | $this->_put('/BaseFont /'.$name); |
| 1643 | 1772 | $this->_put('/Subtype /Type1'); |
| 1644 | - if($name!='Symbol' && $name!='ZapfDingbats') |
|
| 1645 | - $this->_put('/Encoding /WinAnsiEncoding'); |
|
| 1646 | - if(isset($font['uv'])) |
|
| 1647 | - $this->_put('/ToUnicode '.$this->cmaps[$cmapkey].' 0 R'); |
|
| 1773 | + if($name!='Symbol' && $name!='ZapfDingbats') { |
|
| 1774 | + $this->_put('/Encoding /WinAnsiEncoding'); |
|
| 1775 | + } |
|
| 1776 | + if(isset($font['uv'])) { |
|
| 1777 | + $this->_put('/ToUnicode '.$this->cmaps[$cmapkey].' 0 R'); |
|
| 1778 | + } |
|
| 1648 | 1779 | $this->_put('>>'); |
| 1649 | 1780 | $this->_put('endobj'); |
| 1650 | - } |
|
| 1651 | - elseif($type=='Type1' || $type=='TrueType') |
|
| 1781 | + } elseif($type=='Type1' || $type=='TrueType') |
|
| 1652 | 1782 | { |
| 1653 | 1783 | // Additional Type1 or TrueType/OpenType font |
| 1654 | 1784 | $this->_newobj(); |
@@ -1658,38 +1788,43 @@ discard block |
||
| 1658 | 1788 | $this->_put('/FirstChar 32 /LastChar 255'); |
| 1659 | 1789 | $this->_put('/Widths '.($this->n+1).' 0 R'); |
| 1660 | 1790 | $this->_put('/FontDescriptor '.($this->n+2).' 0 R'); |
| 1661 | - if(isset($font['diff'])) |
|
| 1662 | - $this->_put('/Encoding '.$this->encodings[$font['enc']].' 0 R'); |
|
| 1663 | - else |
|
| 1664 | - $this->_put('/Encoding /WinAnsiEncoding'); |
|
| 1665 | - if(isset($font['uv'])) |
|
| 1666 | - $this->_put('/ToUnicode '.$this->cmaps[$cmapkey].' 0 R'); |
|
| 1791 | + if(isset($font['diff'])) { |
|
| 1792 | + $this->_put('/Encoding '.$this->encodings[$font['enc']].' 0 R'); |
|
| 1793 | + } else { |
|
| 1794 | + $this->_put('/Encoding /WinAnsiEncoding'); |
|
| 1795 | + } |
|
| 1796 | + if(isset($font['uv'])) { |
|
| 1797 | + $this->_put('/ToUnicode '.$this->cmaps[$cmapkey].' 0 R'); |
|
| 1798 | + } |
|
| 1667 | 1799 | $this->_put('>>'); |
| 1668 | 1800 | $this->_put('endobj'); |
| 1669 | 1801 | // Widths |
| 1670 | 1802 | $this->_newobj(); |
| 1671 | 1803 | $cw = &$font['cw']; |
| 1672 | 1804 | $s = '['; |
| 1673 | - for($i=32;$i<=255;$i++) |
|
| 1674 | - $s .= $cw[chr($i)].' '; |
|
| 1805 | + for($i=32;$i<=255;$i++) { |
|
| 1806 | + $s .= $cw[chr($i)].' '; |
|
| 1807 | + } |
|
| 1675 | 1808 | $this->_put($s.']'); |
| 1676 | 1809 | $this->_put('endobj'); |
| 1677 | 1810 | // Descriptor |
| 1678 | 1811 | $this->_newobj(); |
| 1679 | 1812 | $s = '<</Type /FontDescriptor /FontName /'.$name; |
| 1680 | - foreach($font['desc'] as $k=>$v) |
|
| 1681 | - $s .= ' /'.$k.' '.$v; |
|
| 1682 | - if(!empty($font['file'])) |
|
| 1683 | - $s .= ' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$font['file']]['n'].' 0 R'; |
|
| 1813 | + foreach($font['desc'] as $k=>$v) { |
|
| 1814 | + $s .= ' /'.$k.' '.$v; |
|
| 1815 | + } |
|
| 1816 | + if(!empty($font['file'])) { |
|
| 1817 | + $s .= ' /FontFile'.($type=='Type1' ? '' : '2').' '.$this->FontFiles[$font['file']]['n'].' 0 R'; |
|
| 1818 | + } |
|
| 1684 | 1819 | $this->_put($s.'>>'); |
| 1685 | 1820 | $this->_put('endobj'); |
| 1686 | - } |
|
| 1687 | - else |
|
| 1821 | + } else |
|
| 1688 | 1822 | { |
| 1689 | 1823 | // Allow for additional types |
| 1690 | 1824 | $mtd = '_put'.strtolower($type); |
| 1691 | - if(!method_exists($this,$mtd)) |
|
| 1692 | - $this->Error('Unsupported font type: '.$type); |
|
| 1825 | + if(!method_exists($this,$mtd)) { |
|
| 1826 | + $this->Error('Unsupported font type: '.$type); |
|
| 1827 | + } |
|
| 1693 | 1828 | $this->$mtd($font); |
| 1694 | 1829 | } |
| 1695 | 1830 | } |
@@ -1707,8 +1842,7 @@ discard block |
||
| 1707 | 1842 | { |
| 1708 | 1843 | $ranges .= sprintf("<%02X> <%02X> <%04X>\n",$c,$c+$v[1]-1,$v[0]); |
| 1709 | 1844 | $nbr++; |
| 1710 | - } |
|
| 1711 | - else |
|
| 1845 | + } else |
|
| 1712 | 1846 | { |
| 1713 | 1847 | $chars .= sprintf("<%02X> <%04X>\n",$c,$v); |
| 1714 | 1848 | $nbc++; |
@@ -1764,28 +1898,33 @@ discard block |
||
| 1764 | 1898 | $this->_put('/Subtype /Image'); |
| 1765 | 1899 | $this->_put('/Width '.$info['w']); |
| 1766 | 1900 | $this->_put('/Height '.$info['h']); |
| 1767 | - if($info['cs']=='Indexed') |
|
| 1768 | - $this->_put('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]'); |
|
| 1769 | - else |
|
| 1901 | + if($info['cs']=='Indexed') { |
|
| 1902 | + $this->_put('/ColorSpace [/Indexed /DeviceRGB '.(strlen($info['pal'])/3-1).' '.($this->n+1).' 0 R]'); |
|
| 1903 | + } else |
|
| 1770 | 1904 | { |
| 1771 | 1905 | $this->_put('/ColorSpace /'.$info['cs']); |
| 1772 | - if($info['cs']=='DeviceCMYK') |
|
| 1773 | - $this->_put('/Decode [1 0 1 0 1 0 1 0]'); |
|
| 1906 | + if($info['cs']=='DeviceCMYK') { |
|
| 1907 | + $this->_put('/Decode [1 0 1 0 1 0 1 0]'); |
|
| 1908 | + } |
|
| 1774 | 1909 | } |
| 1775 | 1910 | $this->_put('/BitsPerComponent '.$info['bpc']); |
| 1776 | - if(isset($info['f'])) |
|
| 1777 | - $this->_put('/Filter /'.$info['f']); |
|
| 1778 | - if(isset($info['dp'])) |
|
| 1779 | - $this->_put('/DecodeParms <<'.$info['dp'].'>>'); |
|
| 1911 | + if(isset($info['f'])) { |
|
| 1912 | + $this->_put('/Filter /'.$info['f']); |
|
| 1913 | + } |
|
| 1914 | + if(isset($info['dp'])) { |
|
| 1915 | + $this->_put('/DecodeParms <<'.$info['dp'].'>>'); |
|
| 1916 | + } |
|
| 1780 | 1917 | if(isset($info['trns']) && is_array($info['trns'])) |
| 1781 | 1918 | { |
| 1782 | 1919 | $trns = ''; |
| 1783 | - for($i=0;$i<count($info['trns']);$i++) |
|
| 1784 | - $trns .= $info['trns'][$i].' '.$info['trns'][$i].' '; |
|
| 1920 | + for($i=0;$i<count($info['trns']);$i++) { |
|
| 1921 | + $trns .= $info['trns'][$i].' '.$info['trns'][$i].' '; |
|
| 1922 | + } |
|
| 1785 | 1923 | $this->_put('/Mask ['.$trns.']'); |
| 1786 | 1924 | } |
| 1787 | - if(isset($info['smask'])) |
|
| 1788 | - $this->_put('/SMask '.($this->n+1).' 0 R'); |
|
| 1925 | + if(isset($info['smask'])) { |
|
| 1926 | + $this->_put('/SMask '.($this->n+1).' 0 R'); |
|
| 1927 | + } |
|
| 1789 | 1928 | $this->_put('/Length '.strlen($info['data']).'>>'); |
| 1790 | 1929 | $this->_putstream($info['data']); |
| 1791 | 1930 | $this->_put('endobj'); |
@@ -1797,22 +1936,25 @@ discard block |
||
| 1797 | 1936 | $this->_putimage($smask); |
| 1798 | 1937 | } |
| 1799 | 1938 | // Palette |
| 1800 | - if($info['cs']=='Indexed') |
|
| 1801 | - $this->_putstreamobject($info['pal']); |
|
| 1802 | -} |
|
| 1939 | + if($info['cs']=='Indexed') { |
|
| 1940 | + $this->_putstreamobject($info['pal']); |
|
| 1941 | + } |
|
| 1942 | + } |
|
| 1803 | 1943 | |
| 1804 | 1944 | protected function _putxobjectdict() |
| 1805 | 1945 | { |
| 1806 | - foreach($this->images as $image) |
|
| 1807 | - $this->_put('/I'.$image['i'].' '.$image['n'].' 0 R'); |
|
| 1808 | -} |
|
| 1946 | + foreach($this->images as $image) { |
|
| 1947 | + $this->_put('/I'.$image['i'].' '.$image['n'].' 0 R'); |
|
| 1948 | + } |
|
| 1949 | + } |
|
| 1809 | 1950 | |
| 1810 | 1951 | protected function _putresourcedict() |
| 1811 | 1952 | { |
| 1812 | 1953 | $this->_put('/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]'); |
| 1813 | 1954 | $this->_put('/Font <<'); |
| 1814 | - foreach($this->fonts as $font) |
|
| 1815 | - $this->_put('/F'.$font['i'].' '.$font['n'].' 0 R'); |
|
| 1955 | + foreach($this->fonts as $font) { |
|
| 1956 | + $this->_put('/F'.$font['i'].' '.$font['n'].' 0 R'); |
|
| 1957 | + } |
|
| 1816 | 1958 | $this->_put('>>'); |
| 1817 | 1959 | $this->_put('/XObject <<'); |
| 1818 | 1960 | $this->_putxobjectdict(); |
@@ -1835,30 +1977,33 @@ discard block |
||
| 1835 | 1977 | { |
| 1836 | 1978 | $this->metadata['Producer'] = 'FPDF '.FPDF_VERSION; |
| 1837 | 1979 | $this->metadata['CreationDate'] = 'D:'.@date('YmdHis'); |
| 1838 | - foreach($this->metadata as $key=>$value) |
|
| 1839 | - $this->_put('/'.$key.' '.$this->_textstring($value)); |
|
| 1840 | -} |
|
| 1980 | + foreach($this->metadata as $key=>$value) { |
|
| 1981 | + $this->_put('/'.$key.' '.$this->_textstring($value)); |
|
| 1982 | + } |
|
| 1983 | + } |
|
| 1841 | 1984 | |
| 1842 | 1985 | protected function _putcatalog() |
| 1843 | 1986 | { |
| 1844 | 1987 | $n = $this->PageInfo[1]['n']; |
| 1845 | 1988 | $this->_put('/Type /Catalog'); |
| 1846 | 1989 | $this->_put('/Pages 1 0 R'); |
| 1847 | - if($this->ZoomMode=='fullpage') |
|
| 1848 | - $this->_put('/OpenAction ['.$n.' 0 R /Fit]'); |
|
| 1849 | - elseif($this->ZoomMode=='fullwidth') |
|
| 1850 | - $this->_put('/OpenAction ['.$n.' 0 R /FitH null]'); |
|
| 1851 | - elseif($this->ZoomMode=='real') |
|
| 1852 | - $this->_put('/OpenAction ['.$n.' 0 R /XYZ null null 1]'); |
|
| 1853 | - elseif(!is_string($this->ZoomMode)) |
|
| 1854 | - $this->_put('/OpenAction ['.$n.' 0 R /XYZ null null '.sprintf('%.2F',$this->ZoomMode/100).']'); |
|
| 1855 | - if($this->LayoutMode=='single') |
|
| 1856 | - $this->_put('/PageLayout /SinglePage'); |
|
| 1857 | - elseif($this->LayoutMode=='continuous') |
|
| 1858 | - $this->_put('/PageLayout /OneColumn'); |
|
| 1859 | - elseif($this->LayoutMode=='two') |
|
| 1860 | - $this->_put('/PageLayout /TwoColumnLeft'); |
|
| 1861 | -} |
|
| 1990 | + if($this->ZoomMode=='fullpage') { |
|
| 1991 | + $this->_put('/OpenAction ['.$n.' 0 R /Fit]'); |
|
| 1992 | + } elseif($this->ZoomMode=='fullwidth') { |
|
| 1993 | + $this->_put('/OpenAction ['.$n.' 0 R /FitH null]'); |
|
| 1994 | + } elseif($this->ZoomMode=='real') { |
|
| 1995 | + $this->_put('/OpenAction ['.$n.' 0 R /XYZ null null 1]'); |
|
| 1996 | + } elseif(!is_string($this->ZoomMode)) { |
|
| 1997 | + $this->_put('/OpenAction ['.$n.' 0 R /XYZ null null '.sprintf('%.2F',$this->ZoomMode/100).']'); |
|
| 1998 | + } |
|
| 1999 | + if($this->LayoutMode=='single') { |
|
| 2000 | + $this->_put('/PageLayout /SinglePage'); |
|
| 2001 | + } elseif($this->LayoutMode=='continuous') { |
|
| 2002 | + $this->_put('/PageLayout /OneColumn'); |
|
| 2003 | + } elseif($this->LayoutMode=='two') { |
|
| 2004 | + $this->_put('/PageLayout /TwoColumnLeft'); |
|
| 2005 | + } |
|
| 2006 | + } |
|
| 1862 | 2007 | |
| 1863 | 2008 | protected function _putheader() |
| 1864 | 2009 | { |
@@ -1894,8 +2039,9 @@ discard block |
||
| 1894 | 2039 | $this->_put('xref'); |
| 1895 | 2040 | $this->_put('0 '.($this->n+1)); |
| 1896 | 2041 | $this->_put('0000000000 65535 f '); |
| 1897 | - for($i=1;$i<=$this->n;$i++) |
|
| 1898 | - $this->_put(sprintf('%010d 00000 n ',$this->offsets[$i])); |
|
| 2042 | + for($i=1;$i<=$this->n;$i++) { |
|
| 2043 | + $this->_put(sprintf('%010d 00000 n ',$this->offsets[$i])); |
|
| 2044 | + } |
|
| 1899 | 2045 | // Trailer |
| 1900 | 2046 | $this->_put('trailer'); |
| 1901 | 2047 | $this->_put('<<'); |
@@ -216,7 +216,7 @@ discard block |
||
| 216 | 216 | $lista[] = $item->info_adicional($item); |
| 217 | 217 | } |
| 218 | 218 | return $lista; |
| 219 | - }else{ |
|
| 219 | + } else{ |
|
| 220 | 220 | return false; |
| 221 | 221 | } |
| 222 | 222 | } |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | if($data){ |
| 236 | 236 | $item = new residentes_informacion($data[0]); |
| 237 | 237 | return $item->info_adicional($item); |
| 238 | - }else{ |
|
| 238 | + } else{ |
|
| 239 | 239 | return false; |
| 240 | 240 | } |
| 241 | 241 | } |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | $lista[] = $item->info_adicional($item); |
| 258 | 258 | } |
| 259 | 259 | return $lista; |
| 260 | - }else{ |
|
| 260 | + } else{ |
|
| 261 | 261 | return false; |
| 262 | 262 | } |
| 263 | 263 | } |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | public function exists() { |
| 266 | 266 | if(!$this->get($this->codcliente)){ |
| 267 | 267 | return false; |
| 268 | - }else{ |
|
| 268 | + } else{ |
|
| 269 | 269 | return $this->get($this->codcliente); |
| 270 | 270 | } |
| 271 | 271 | } |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | "vehiculos = ".$this->intval($this->vehiculos)." ". |
| 297 | 297 | "WHERE codcliente = ".$this->var2str($this->codcliente).";"; |
| 298 | 298 | return $this->db->exec($sql); |
| 299 | - }else{ |
|
| 299 | + } else{ |
|
| 300 | 300 | $sql = "INSERT INTO ".$this->table_name." (codcliente, codigo, ocupantes, ocupantes5anos, ocupantes12anos, ocupantes18anos, ocupantes30anos, ocupantes50anos, ocupantes70anos, ocupantes71anos, informacion_discapacidad, propietario, profesion, ocupacion, ca_nombres, ca_apellidos, ca_telefono, ca_email, ca_propietario, ca_parentesco, ca_parentesco_obs, vehiculos) VALUES (". |
| 301 | 301 | $this->var2str($this->codcliente).", ". |
| 302 | 302 | $this->var2str($this->codigo).", ". |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | $this->intval($this->vehiculos).");"; |
| 323 | 323 | if($this->db->exec($sql)){ |
| 324 | 324 | return true; |
| 325 | - }else{ |
|
| 325 | + } else{ |
|
| 326 | 326 | return false; |
| 327 | 327 | } |
| 328 | 328 | } |