00001 <?php
00002
00003 include_once('class.pdf.php');
00004
00005 class Cezpdf extends Cpdf {
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 var $ez=array('fontSize'=>10);
00022 var $y;
00023 var $ezPages=array();
00024 var $ezPageCount=0;
00025
00026
00027
00028 function Cezpdf($paper='a4',$orientation='portrait'){
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 if (!is_array($paper)){
00044 switch (strtoupper($paper)){
00045 case '4A0': {$size = array(0,0,4767.87,6740.79); break;}
00046 case '2A0': {$size = array(0,0,3370.39,4767.87); break;}
00047 case 'A0': {$size = array(0,0,2383.94,3370.39); break;}
00048 case 'A1': {$size = array(0,0,1683.78,2383.94); break;}
00049 case 'A2': {$size = array(0,0,1190.55,1683.78); break;}
00050 case 'A3': {$size = array(0,0,841.89,1190.55); break;}
00051 case 'A4': default: {$size = array(0,0,595.28,841.89); break;}
00052 case 'A5': {$size = array(0,0,419.53,595.28); break;}
00053 case 'A6': {$size = array(0,0,297.64,419.53); break;}
00054 case 'A7': {$size = array(0,0,209.76,297.64); break;}
00055 case 'A8': {$size = array(0,0,147.40,209.76); break;}
00056 case 'A9': {$size = array(0,0,104.88,147.40); break;}
00057 case 'A10': {$size = array(0,0,73.70,104.88); break;}
00058 case 'B0': {$size = array(0,0,2834.65,4008.19); break;}
00059 case 'B1': {$size = array(0,0,2004.09,2834.65); break;}
00060 case 'B2': {$size = array(0,0,1417.32,2004.09); break;}
00061 case 'B3': {$size = array(0,0,1000.63,1417.32); break;}
00062 case 'B4': {$size = array(0,0,708.66,1000.63); break;}
00063 case 'B5': {$size = array(0,0,498.90,708.66); break;}
00064 case 'B6': {$size = array(0,0,354.33,498.90); break;}
00065 case 'B7': {$size = array(0,0,249.45,354.33); break;}
00066 case 'B8': {$size = array(0,0,175.75,249.45); break;}
00067 case 'B9': {$size = array(0,0,124.72,175.75); break;}
00068 case 'B10': {$size = array(0,0,87.87,124.72); break;}
00069 case 'C0': {$size = array(0,0,2599.37,3676.54); break;}
00070 case 'C1': {$size = array(0,0,1836.85,2599.37); break;}
00071 case 'C2': {$size = array(0,0,1298.27,1836.85); break;}
00072 case 'C3': {$size = array(0,0,918.43,1298.27); break;}
00073 case 'C4': {$size = array(0,0,649.13,918.43); break;}
00074 case 'C5': {$size = array(0,0,459.21,649.13); break;}
00075 case 'C6': {$size = array(0,0,323.15,459.21); break;}
00076 case 'C7': {$size = array(0,0,229.61,323.15); break;}
00077 case 'C8': {$size = array(0,0,161.57,229.61); break;}
00078 case 'C9': {$size = array(0,0,113.39,161.57); break;}
00079 case 'C10': {$size = array(0,0,79.37,113.39); break;}
00080 case 'RA0': {$size = array(0,0,2437.80,3458.27); break;}
00081 case 'RA1': {$size = array(0,0,1729.13,2437.80); break;}
00082 case 'RA2': {$size = array(0,0,1218.90,1729.13); break;}
00083 case 'RA3': {$size = array(0,0,864.57,1218.90); break;}
00084 case 'RA4': {$size = array(0,0,609.45,864.57); break;}
00085 case 'SRA0': {$size = array(0,0,2551.18,3628.35); break;}
00086 case 'SRA1': {$size = array(0,0,1814.17,2551.18); break;}
00087 case 'SRA2': {$size = array(0,0,1275.59,1814.17); break;}
00088 case 'SRA3': {$size = array(0,0,907.09,1275.59); break;}
00089 case 'SRA4': {$size = array(0,0,637.80,907.09); break;}
00090 case 'LETTER': {$size = array(0,0,612.00,792.00); break;}
00091 case 'LEGAL': {$size = array(0,0,612.00,1008.00); break;}
00092 case 'EXECUTIVE': {$size = array(0,0,521.86,756.00); break;}
00093 case 'FOLIO': {$size = array(0,0,612.00,936.00); break;}
00094 }
00095 switch (strtolower($orientation)){
00096 case 'landscape':
00097 $a=$size[3];
00098 $size[3]=$size[2];
00099 $size[2]=$a;
00100 break;
00101 }
00102 } else {
00103 if (count($paper)>2) {
00104
00105 $size = $paper;
00106 }
00107 else {
00108 $size[0] = 0;
00109 $size[1] = 0;
00110 $size[2] = ( $paper[0] / 2.54 ) * 72;
00111 $size[3] = ( $paper[1] / 2.54 ) * 72;
00112 }
00113 }
00114 $this->Cpdf($size);
00115 $this->ez['pageWidth']=$size[2];
00116 $this->ez['pageHeight']=$size[3];
00117
00118
00119 $this->ez['topMargin']=30;
00120 $this->ez['bottomMargin']=30;
00121 $this->ez['leftMargin']=30;
00122 $this->ez['rightMargin']=30;
00123
00124
00125 $this->y = $this->ez['pageHeight']-$this->ez['topMargin'];
00126
00127 $this->ezPages[1]=$this->getFirstPageId();
00128 $this->ezPageCount=1;
00129 }
00130
00131
00132
00133
00134 function ezSetCmMargins($top,$bottom,$left,$right){
00135 $top = ( $top / 2.54 ) * 72;
00136 $bottom = ( $bottom / 2.54 ) * 72;
00137 $left = ( $left / 2.54 ) * 72;
00138 $right = ( $right / 2.54 ) * 72;
00139 $this->ezSetMargins($top,$bottom,$left,$right);
00140 }
00141
00142
00143
00144 function ezColumnsStart($options=array()){
00145
00146 if (isset($this->ez['columns']) && $this->ez['columns']==1){
00147
00148 return;
00149 }
00150 $def=array('gap'=>10,'num'=>2);
00151 foreach($def as $k=>$v){
00152 if (!isset($options[$k])){
00153 $options[$k]=$v;
00154 }
00155 }
00156
00157 $this->ez['columns']=array('on'=>1,'colNum'=>1);
00158
00159
00160 $this->ez['columns']['margins']=array(
00161 $this->ez['leftMargin']
00162 ,$this->ez['rightMargin']
00163 ,$this->ez['topMargin']
00164 ,$this->ez['bottomMargin']
00165 );
00166
00167 $this->ez['columns']['options']=$options;
00168
00169
00170 $this->ez['topMargin']=$this->ez['pageHeight']-$this->y;
00171 $width=($this->ez['pageWidth']-$this->ez['leftMargin']-$this->ez['rightMargin']-($options['num']-1)*$options['gap'])/$options['num'];
00172 $this->ez['columns']['width']=$width;
00173 $this->ez['rightMargin']=$this->ez['pageWidth']-$this->ez['leftMargin']-$width;
00174
00175 }
00176
00177 function ezColumnsStop(){
00178 if (isset($this->ez['columns']) && $this->ez['columns']['on']==1){
00179 $this->ez['columns']['on']=0;
00180 $this->ez['leftMargin']=$this->ez['columns']['margins'][0];
00181 $this->ez['rightMargin']=$this->ez['columns']['margins'][1];
00182 $this->ez['topMargin']=$this->ez['columns']['margins'][2];
00183 $this->ez['bottomMargin']=$this->ez['columns']['margins'][3];
00184 }
00185 }
00186
00187 function ezInsertMode($status=1,$pageNum=1,$pos='before'){
00188
00189
00190 switch($status){
00191 case '1':
00192 if (isset($this->ezPages[$pageNum])){
00193 $this->ez['insertMode']=1;
00194 $this->ez['insertOptions']=array('id'=>$this->ezPages[$pageNum],'pos'=>$pos);
00195 }
00196 break;
00197 case '0':
00198 $this->ez['insertMode']=0;
00199 break;
00200 }
00201 }
00202
00203
00204 function ezNewPage(){
00205 $pageRequired=1;
00206 if (isset($this->ez['columns']) && $this->ez['columns']['on']==1){
00207
00208
00209
00210 $this->ez['columns']['colNum']++;
00211
00212 if ($this->ez['columns']['colNum'] <= $this->ez['columns']['options']['num']){
00213
00214 $pageRequired=0;
00215 } else {
00216 $this->ez['columns']['colNum']=1;
00217 $this->ez['topMargin']=$this->ez['columns']['margins'][2];
00218 }
00219
00220 $width = $this->ez['columns']['width'];
00221 $this->ez['leftMargin']=$this->ez['columns']['margins'][0]+($this->ez['columns']['colNum']-1)*($this->ez['columns']['options']['gap']+$width);
00222 $this->ez['rightMargin']=$this->ez['pageWidth']-$this->ez['leftMargin']-$width;
00223 }
00224
00225
00226 if ($pageRequired){
00227
00228 $this->y = $this->ez['pageHeight']-$this->ez['topMargin'];
00229
00230 $this->ezPageCount++;
00231 if (isset($this->ez['insertMode']) && $this->ez['insertMode']==1){
00232 $id = $this->ezPages[$this->ezPageCount] = $this->newPage(1,$this->ez['insertOptions']['id'],$this->ez['insertOptions']['pos']);
00233
00234 $this->ez['insertOptions']['id']=$id;
00235 $this->ez['insertOptions']['pos']='after';
00236 } else {
00237 $this->ezPages[$this->ezPageCount] = $this->newPage();
00238 }
00239 } else {
00240 $this->y = $this->ez['pageHeight']-$this->ez['topMargin'];
00241 }
00242 }
00243
00244
00245
00246 function ezSetMargins($top,$bottom,$left,$right){
00247
00248 $this->ez['topMargin']=$top;
00249 $this->ez['bottomMargin']=$bottom;
00250 $this->ez['leftMargin']=$left;
00251 $this->ez['rightMargin']=$right;
00252
00253
00254 if ($this->y > $this->ez['pageHeight']-$top){
00255
00256 $this->y = $this->ez['pageHeight']-$top;
00257 }
00258 if ( $this->y < $bottom){
00259
00260 $this->ezNewPage();
00261 }
00262 }
00263
00264
00265
00266 function ezGetCurrentPageNumber(){
00267
00268 return $this->ezPageCount;
00269 }
00270
00271
00272
00273 function ezStartPageNumbers($x,$y,$size,$pos='left',$pattern='{PAGENUM} of {TOTALPAGENUM}',$num=''){
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283 if (!$pos || !strlen($pos)){
00284 $pos='left';
00285 }
00286 if (!$pattern || !strlen($pattern)){
00287 $pattern='{PAGENUM} of {TOTALPAGENUM}';
00288 }
00289 if (!isset($this->ez['pageNumbering'])){
00290 $this->ez['pageNumbering']=array();
00291 }
00292 $i = count($this->ez['pageNumbering']);
00293 $this->ez['pageNumbering'][$i][$this->ezPageCount]=array('x'=>$x,'y'=>$y,'pos'=>$pos,'pattern'=>$pattern,'num'=>$num,'size'=>$size);
00294 return $i;
00295 }
00296
00297
00298
00299 function ezWhatPageNumber($pageNum,$i=0){
00300
00301
00302 $num=0;
00303 $start=1;
00304 $startNum=1;
00305 if (!isset($this->ez['pageNumbering']))
00306 {
00307 $this->addMessage('WARNING: page numbering called for and wasn\'t started with ezStartPageNumbers');
00308 return 0;
00309 }
00310 foreach($this->ez['pageNumbering'][$i] as $k=>$v){
00311 if ($k<=$pageNum){
00312 if (is_array($v)){
00313
00314 if (strlen($v['num'])){
00315
00316 $start=$v['num'];
00317 $startNum=$k;
00318 $num=$pageNum-$startNum+$start;
00319 }
00320 } else {
00321
00322 $num=0;
00323 }
00324 }
00325 }
00326 return $num;
00327 }
00328
00329
00330
00331 function ezStopPageNumbers($stopTotal=0,$next=0,$i=0){
00332
00333
00334
00335 if (!isset($this->ez['pageNumbering'])){
00336 $this->ez['pageNumbering']=array();
00337 }
00338 if ($next && isset($this->ez['pageNumbering'][$i][$this->ezPageCount]) && is_array($this->ez['pageNumbering'][$i][$this->ezPageCount])){
00339
00340
00341 if ($stopTotal){
00342 $this->ez['pageNumbering'][$i][$this->ezPageCount]['stoptn']=1;
00343 } else {
00344 $this->ez['pageNumbering'][$i][$this->ezPageCount]['stopn']=1;
00345 }
00346 } else {
00347 if ($stopTotal){
00348 $this->ez['pageNumbering'][$i][$this->ezPageCount]='stopt';
00349 } else {
00350 $this->ez['pageNumbering'][$i][$this->ezPageCount]='stop';
00351 }
00352 if ($next){
00353 $this->ez['pageNumbering'][$i][$this->ezPageCount].='n';
00354 }
00355 }
00356 }
00357
00358
00359
00360 function ezPRVTpageNumberSearch($lbl,&$tmp){
00361 foreach($tmp as $i=>$v){
00362 if (is_array($v)){
00363 if (isset($v[$lbl])){
00364 return $i;
00365 }
00366 } else {
00367 if ($v==$lbl){
00368 return $i;
00369 }
00370 }
00371 }
00372 return 0;
00373 }
00374
00375
00376
00377 function ezPRVTaddPageNumbers(){
00378
00379 if (isset($this->ez['pageNumbering'])){
00380 $totalPages1 = $this->ezPageCount;
00381 $tmp1=$this->ez['pageNumbering'];
00382 $status=0;
00383 foreach($tmp1 as $i=>$tmp){
00384
00385
00386 $k = $this->ezPRVTpageNumberSearch('stopt',$tmp);
00387 if ($k && $k>0){
00388 $totalPages = $k-1;
00389 } else {
00390 $l = $this->ezPRVTpageNumberSearch('stoptn',$tmp);
00391 if ($l && $l>0){
00392 $totalPages = $l;
00393 } else {
00394 $totalPages = $totalPages1;
00395 }
00396 }
00397 foreach ($this->ezPages as $pageNum=>$id){
00398 if (isset($tmp[$pageNum])){
00399 if (is_array($tmp[$pageNum])){
00400
00401 $status=1;
00402 $info = $tmp[$pageNum];
00403 $info['dnum']=$info['num']-$pageNum;
00404
00405 if (isset($info['stopn']) || isset($info['stoptn']) ){
00406 $status=2;
00407 }
00408 } else if ($tmp[$pageNum]=='stop' || $tmp[$pageNum]=='stopt'){
00409
00410 $status=0;
00411 } else if ($status==1 && ($tmp[$pageNum]=='stoptn' || $tmp[$pageNum]=='stopn')){
00412
00413 $status=2;
00414 }
00415 }
00416 if ($status){
00417
00418 if (strlen($info['num'])){
00419 $num=$pageNum+$info['dnum'];
00420 } else {
00421 $num=$pageNum;
00422 }
00423 $total = $totalPages+$num-$pageNum;
00424 $pat = str_replace('{PAGENUM}',$num,$info['pattern']);
00425 $pat = str_replace('{TOTALPAGENUM}',$total,$pat);
00426 $this->reopenObject($id);
00427 switch($info['pos']){
00428 case 'right':
00429 $this->addText($info['x'],$info['y'],$info['size'],$pat);
00430 break;
00431 default:
00432 $w=$this->getTextWidth($info['size'],$pat);
00433 $this->addText($info['x']-$w,$info['y'],$info['size'],$pat);
00434 break;
00435 }
00436 $this->closeObject();
00437 }
00438 if ($status==2){
00439 $status=0;
00440 }
00441 }
00442 }
00443 }
00444 }
00445
00446
00447
00448 function ezPRVTcleanUp(){
00449 $this->ezPRVTaddPageNumbers();
00450 }
00451
00452
00453
00454 function ezStream($options=''){
00455 $this->ezPRVTcleanUp();
00456 $this->stream($options);
00457 }
00458
00459
00460
00461 function ezOutput($options=0){
00462 $this->ezPRVTcleanUp();
00463 return $this->output($options);
00464 }
00465
00466
00467
00468 function ezSetY($y){
00469
00470 $this->y = $y;
00471 if ( $this->y < $this->ez['bottomMargin']){
00472
00473 $this->ezNewPage();
00474 }
00475 }
00476
00477
00478
00479 function ezSetDy($dy,$mod=''){
00480
00481
00482
00483
00484
00485 $this->y += $dy;
00486 if ( $this->y < $this->ez['bottomMargin']){
00487
00488 $this->ezNewPage();
00489 if ($mod=='makeSpace'){
00490 $this->y += $dy;
00491 }
00492 }
00493 }
00494
00495
00496
00497 function ezPrvtTableDrawLines($pos,$gap,$x0,$x1,$y0,$y1,$y2,$col,$inner,$outer,$opt=1){
00498 $x0=1000;
00499 $x1=0;
00500 $this->setStrokeColor($col[0],$col[1],$col[2]);
00501 $cnt=0;
00502 $n = count($pos);
00503 foreach($pos as $x){
00504 $cnt++;
00505 if ($cnt==1 || $cnt==$n){
00506 $this->setLineStyle($outer);
00507 } else {
00508 $this->setLineStyle($inner);
00509 }
00510 $this->line($x-$gap/2,$y0,$x-$gap/2,$y2);
00511 if ($x>$x1){ $x1=$x; };
00512 if ($x<$x0){ $x0=$x; };
00513 }
00514 $this->setLineStyle($outer);
00515 $this->line($x0-$gap/2-$outer/2,$y0,$x1-$gap/2+$outer/2,$y0);
00516
00517
00518 if ($y0!=$y1 && $opt<2){
00519 $this->line($x0-$gap/2,$y1,$x1-$gap/2,$y1);
00520 }
00521 $this->line($x0-$gap/2-$outer/2,$y2,$x1-$gap/2+$outer/2,$y2);
00522 }
00523
00524
00525
00526 function ezPrvtTableColumnHeadings($cols,$pos,$maxWidth,$height,$decender,$gap,$size,&$y,$optionsAll=array()){
00527
00528
00529
00530
00531 if (isset($optionsAll['cols'])){
00532 $options = $optionsAll['cols'];
00533 } else {
00534 $options = array();
00535 }
00536
00537 $mx=0;
00538 $startPage = $this->ezPageCount;
00539 $secondGo=0;
00540
00541
00542
00543
00544
00545
00546
00547
00548 $this->transaction('start');
00549 $ok=0;
00550
00551 $y-=$gap;
00552 while ($ok==0){
00553 foreach($cols as $colName=>$colHeading){
00554 $this->ezSetY($y);
00555 if (isset($options[$colName]) && isset($options[$colName]['justification'])){
00556 $justification = $options[$colName]['justification'];
00557 } else {
00558 $justification = 'left';
00559 }
00560 $this->ezText($colHeading,$size,array('aleft'=> $pos[$colName],'aright'=>($maxWidth[$colName]+$pos[$colName]),'justification'=>$justification));
00561 $dy = $y-$this->y;
00562 if ($dy>$mx){
00563 $mx=$dy;
00564 }
00565 }
00566 $y = $y - $mx - $gap + $decender;
00567
00568
00569
00570
00571 if ($this->ezPageCount != $startPage && $secondGo==0){
00572 $this->transaction('rewind');
00573 $this->ezNewPage();
00574 $y = $this->y - $gap-$decender;
00575 $ok=0;
00576 $secondGo=1;
00577
00578 $mx=0;
00579
00580 } else {
00581 $this->transaction('commit');
00582 $ok=1;
00583 }
00584 }
00585
00586 return $mx+$gap*2-$decender;
00587 }
00588
00589
00590
00591 function ezPrvtGetTextWidth($size,$text){
00592
00593
00594 $mx=0;
00595 $lines = explode("\n",$text);
00596 foreach ($lines as $line){
00597 $w = $this->getTextWidth($size,$line);
00598 if ($w>$mx){
00599 $mx=$w;
00600 }
00601 }
00602 return $mx;
00603 }
00604
00605
00606
00607 function ezTable(&$data,$cols='',$title='',$options=''){
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645 if (!is_array($data)){
00646 return;
00647 }
00648
00649 if (!is_array($cols)){
00650
00651 reset($data);
00652 list($k,$v)=each($data);
00653 if (!is_array($v)){
00654 return;
00655 }
00656 $cols=array();
00657 foreach($v as $k1=>$v1){
00658 $cols[$k1]=$k1;
00659 }
00660 }
00661
00662 if (!is_array($options)){
00663 $options=array();
00664 }
00665
00666 $defaults = array(
00667 'shaded'=>1,'showLines'=>1,'shadeCol'=>array(0.8,0.8,0.8),'shadeCol2'=>array(0.7,0.7,0.7),'fontSize'=>10,'titleFontSize'=>12
00668 ,'titleGap'=>5,'lineCol'=>array(0,0,0),'gap'=>5,'xPos'=>'centre','xOrientation'=>'centre'
00669 ,'showHeadings'=>1,'textCol'=>array(0,0,0),'width'=>0,'maxWidth'=>0,'cols'=>array(),'minRowSpace'=>-100,'rowGap'=>2,'colGap'=>5
00670 ,'innerLineThickness'=>1,'outerLineThickness'=>1,'splitRows'=>0,'protectRows'=>1
00671 );
00672
00673 foreach($defaults as $key=>$value){
00674 if (is_array($value)){
00675 if (!isset($options[$key]) || !is_array($options[$key])){
00676 $options[$key]=$value;
00677 }
00678 } else {
00679 if (!isset($options[$key])){
00680 $options[$key]=$value;
00681 }
00682 }
00683 }
00684 $options['gap']=2*$options['colGap'];
00685
00686 $middle = ($this->ez['pageWidth']-$this->ez['rightMargin'])/2+($this->ez['leftMargin'])/2;
00687
00688 $maxWidth=array();
00689 foreach($cols as $colName=>$colHeading){
00690 $maxWidth[$colName]=0;
00691 }
00692
00693 foreach($data as $row){
00694 foreach($cols as $colName=>$colHeading){
00695 $w = $this->ezPrvtGetTextWidth($options['fontSize'],(string)$row[$colName])*1.01;
00696 if ($w > $maxWidth[$colName]){
00697 $maxWidth[$colName]=$w;
00698 }
00699 }
00700 }
00701
00702 foreach($cols as $colName=>$colTitle){
00703 $w = $this->ezPrvtGetTextWidth($options['fontSize'],(string)$colTitle)*1.01;
00704 if ($w > $maxWidth[$colName]){
00705 $maxWidth[$colName]=$w;
00706 }
00707 }
00708
00709
00710 $pos=array();
00711 $x=0;
00712 $t=$x;
00713 $adjustmentWidth=0;
00714 $setWidth=0;
00715 foreach($maxWidth as $colName => $w){
00716 $pos[$colName]=$t;
00717
00718
00719 if (isset($options['cols'][$colName]) && isset($options['cols'][$colName]['width']) && $options['cols'][$colName]['width']>0){
00720 $t=$t+$options['cols'][$colName]['width'];
00721 $maxWidth[$colName] = $options['cols'][$colName]['width']-$options['gap'];
00722 $setWidth += $options['cols'][$colName]['width'];
00723 } else {
00724 $t=$t+$w+$options['gap'];
00725 $adjustmentWidth += $w;
00726 $setWidth += $options['gap'];
00727 }
00728 }
00729 $pos['_end_']=$t;
00730
00731
00732
00733 if ($options['width']==0 && $options['maxWidth'] && ($t-$x)>$options['maxWidth']){
00734
00735 $options['width']=$options['maxWidth'];
00736 }
00737
00738 if ($options['width'] && $adjustmentWidth>0 && $setWidth<$options['width']){
00739
00740 $cols0 = array();
00741 $cols1 = array();
00742 $xq=0;
00743 $presentWidth=0;
00744 $last='';
00745 foreach($pos as $colName=>$p){
00746 if (!isset($options['cols'][$last]) || !isset($options['cols'][$last]['width']) || $options['cols'][$last]['width']<=0){
00747 if (strlen($last)){
00748 $cols0[$last]=$p-$xq -$options['gap'];
00749 $presentWidth += ($p-$xq - $options['gap']);
00750 }
00751 } else {
00752 $cols1[$last]=$p-$xq;
00753 }
00754 $last=$colName;
00755 $xq=$p;
00756 }
00757
00758 $neededWidth = $options['width']-$setWidth;
00759
00760 if ($presentWidth<$neededWidth){
00761 foreach($cols0 as $colName=>$w){
00762 $cols0[$colName]+= ($neededWidth-$presentWidth)/count($cols0);
00763 }
00764 } else {
00765
00766 $cnt=0;
00767 while ($presentWidth>$neededWidth && $cnt<100){
00768 $cnt++;
00769
00770 $aWidest = array();
00771 $nWidest=0;
00772 $widest=0;
00773 foreach($cols0 as $colName=>$w){
00774 if ($w>$widest){
00775 $aWidest=array($colName);
00776 $nWidest = $widest;
00777 $widest=$w;
00778 } else if ($w==$widest){
00779 $aWidest[]=$colName;
00780 }
00781 }
00782
00783 $newWidestWidth = $widest - ($presentWidth-$neededWidth)/count($aWidest);
00784 if ($newWidestWidth > $nWidest){
00785
00786 foreach($aWidest as $colName){
00787 $cols0[$colName] = $newWidestWidth;
00788 }
00789 $presentWidth=$neededWidth;
00790 } else {
00791
00792
00793 foreach($aWidest as $colName){
00794 $cols0[$colName] = $nWidest;
00795 }
00796 $presentWidth=$presentWidth-($widest-$nWidest)*count($aWidest);
00797 }
00798 }
00799 }
00800
00801
00802 $xq=0;
00803 foreach($pos as $colName=>$p){
00804 $pos[$colName]=$xq;
00805 if (!isset($options['cols'][$colName]) || !isset($options['cols'][$colName]['width']) || $options['cols'][$colName]['width']<=0){
00806 if (isset($cols0[$colName])){
00807 $xq += $cols0[$colName] + $options['gap'];
00808 $maxWidth[$colName]=$cols0[$colName];
00809 }
00810 } else {
00811 if (isset($cols1[$colName])){
00812 $xq += $cols1[$colName];
00813 }
00814 }
00815 }
00816
00817 $t=$x+$options['width'];
00818 $pos['_end_']=$t;
00819 }
00820
00821
00822 switch ($options['xPos']){
00823 case 'left':
00824 $xref = $this->ez['leftMargin'];
00825 break;
00826 case 'right':
00827 $xref = $this->ez['pageWidth'] - $this->ez['rightMargin'];
00828 break;
00829 case 'centre':
00830 case 'center':
00831 $xref = $middle;
00832 break;
00833 default:
00834 $xref = $options['xPos'];
00835 break;
00836 }
00837 switch ($options['xOrientation']){
00838 case 'left':
00839 $dx = $xref-$t;
00840 break;
00841 case 'right':
00842 $dx = $xref;
00843 break;
00844 case 'centre':
00845 case 'center':
00846 $dx = $xref-$t/2;
00847 break;
00848 }
00849
00850
00851 foreach($pos as $k=>$v){
00852 $pos[$k]=$v+$dx;
00853 }
00854 $x0=$x+$dx;
00855 $x1=$t+$dx;
00856
00857 $baseLeftMargin = $this->ez['leftMargin'];
00858 $basePos = $pos;
00859 $baseX0 = $x0;
00860 $baseX1 = $x1;
00861
00862
00863 $this->setColor($options['textCol'][0],$options['textCol'][1],$options['textCol'][2]);
00864 $this->setStrokeColor($options['shadeCol'][0],$options['shadeCol'][1],$options['shadeCol'][2]);
00865
00866 $middle = ($x1+$x0)/2;
00867
00868
00869 if ($options['protectRows']>0){
00870 $this->transaction('start');
00871 $movedOnce=0;
00872 }
00873 $abortTable = 1;
00874 while ($abortTable){
00875 $abortTable=0;
00876
00877 $dm = $this->ez['leftMargin']-$baseLeftMargin;
00878 foreach($basePos as $k=>$v){
00879 $pos[$k]=$v+$dm;
00880 }
00881 $x0=$baseX0+$dm;
00882 $x1=$baseX1+$dm;
00883 $middle = ($x1+$x0)/2;
00884
00885
00886
00887 if (strlen($title)){
00888 $w = $this->getTextWidth($options['titleFontSize'],$title);
00889 $this->y -= $this->getFontHeight($options['titleFontSize']);
00890 if ($this->y < $this->ez['bottomMargin']){
00891 $this->ezNewPage();
00892
00893 $dm = $this->ez['leftMargin']-$baseLeftMargin;
00894 foreach($basePos as $k=>$v){
00895 $pos[$k]=$v+$dm;
00896 }
00897 $x0=$baseX0+$dm;
00898 $x1=$baseX1+$dm;
00899 $middle = ($x1+$x0)/2;
00900 $this->y -= $this->getFontHeight($options['titleFontSize']);
00901 }
00902 $this->addText($middle-$w/2,$this->y,$options['titleFontSize'],$title);
00903 $this->y -= $options['titleGap'];
00904 }
00905
00906
00907 $dm = $this->ez['leftMargin']-$baseLeftMargin;
00908 foreach($basePos as $k=>$v){
00909 $pos[$k]=$v+$dm;
00910 }
00911 $x0=$baseX0+$dm;
00912 $x1=$baseX1+$dm;
00913
00914 $y=$this->y;
00915
00916
00917 $height = $this->getFontHeight($options['fontSize']);
00918 $decender = $this->getFontDecender($options['fontSize']);
00919
00920
00921
00922 $y0=$y+$decender;
00923 $dy=0;
00924 if ($options['showHeadings']){
00925
00926 $headingHeight = $this->ezPrvtTableColumnHeadings($cols,$pos,$maxWidth,$height,$decender,$options['rowGap'],$options['fontSize'],$y,$options);
00927 $y0 = $y+$headingHeight;
00928 $y1 = $y;
00929
00930
00931 $dm = $this->ez['leftMargin']-$baseLeftMargin;
00932 foreach($basePos as $k=>$v){
00933 $pos[$k]=$v+$dm;
00934 }
00935 $x0=$baseX0+$dm;
00936 $x1=$baseX1+$dm;
00937
00938 } else {
00939 $y1 = $y0;
00940 }
00941 $firstLine=1;
00942
00943
00944
00945 if ($options['shaded']){
00946 $this->saveState();
00947 $textObjectId = $this->openObject();
00948 $this->closeObject();
00949 $this->addObject($textObjectId);
00950 $this->reopenObject($textObjectId);
00951 }
00952
00953 $cnt=0;
00954 $newPage=0;
00955 foreach($data as $row){
00956 $cnt++;
00957
00958 if ($options['splitRows']==0){
00959 $pageStart = $this->ezPageCount;
00960 if (isset($this->ez['columns']) && $this->ez['columns']['on']==1){
00961 $columnStart = $this->ez['columns']['colNum'];
00962 }
00963 $this->transaction('start');
00964 $row_orig = $row;
00965 $y_orig = $y;
00966 $y0_orig = $y0;
00967 $y1_orig = $y1;
00968 }
00969 $ok=0;
00970 $secondTurn=0;
00971 while(!$abortTable && $ok == 0){
00972
00973 $mx=0;
00974 $newRow=1;
00975 while(!$abortTable && ($newPage || $newRow)){
00976
00977 $y-=$height;
00978 if ($newPage || $y<$this->ez['bottomMargin'] || (isset($options['minRowSpace']) && $y<($this->ez['bottomMargin']+$options['minRowSpace'])) ){
00979
00980 if ($options['protectRows']>0 && $movedOnce==0 && $cnt<=$options['protectRows']){
00981
00982 $movedOnce = 1;
00983 $abortTable = 1;
00984 }
00985
00986 $y2=$y-$mx+2*$height+$decender-$newRow*$height;
00987 if ($options['showLines']){
00988 if (!$options['showHeadings']){
00989 $y0=$y1;
00990 }
00991 $this->ezPrvtTableDrawLines($pos,$options['gap'],$x0,$x1,$y0,$y1,$y2,$options['lineCol'],$options['innerLineThickness'],$options['outerLineThickness'],$options['showLines']);
00992 }
00993 if ($options['shaded']){
00994 $this->closeObject();
00995 $this->restoreState();
00996 }
00997 $this->ezNewPage();
00998
00999
01000
01001 $dm = $this->ez['leftMargin']-$baseLeftMargin;
01002 foreach($basePos as $k=>$v){
01003 $pos[$k]=$v+$dm;
01004 }
01005
01006
01007 $x0=$baseX0+$dm;
01008 $x1=$baseX1+$dm;
01009
01010 if ($options['shaded']){
01011 $this->saveState();
01012 $textObjectId = $this->openObject();
01013 $this->closeObject();
01014 $this->addObject($textObjectId);
01015 $this->reopenObject($textObjectId);
01016 }
01017 $this->setColor($options['textCol'][0],$options['textCol'][1],$options['textCol'][2],1);
01018 $y = $this->ez['pageHeight']-$this->ez['topMargin'];
01019 $y0=$y+$decender;
01020 $mx=0;
01021 if ($options['showHeadings']){
01022 $this->ezPrvtTableColumnHeadings($cols,$pos,$maxWidth,$height,$decender,$options['rowGap'],$options['fontSize'],$y,$options);
01023 $y1=$y;
01024 } else {
01025 $y1=$y0;
01026 }
01027 $firstLine=1;
01028 $y -= $height;
01029 }
01030 $newRow=0;
01031
01032
01033
01034 $newPage=0;
01035 $leftOvers=array();
01036
01037 foreach($cols as $colName=>$colTitle){
01038 $this->ezSetY($y+$height);
01039 $colNewPage=0;
01040 if (isset($row[$colName])){
01041 if (isset($options['cols'][$colName]) && isset($options['cols'][$colName]['link']) && strlen($options['cols'][$colName]['link'])){
01042
01043 $lines = explode("\n",$row[$colName]);
01044 if (isset($row[$options['cols'][$colName]['link']]) && strlen($row[$options['cols'][$colName]['link']])){
01045 foreach($lines as $k=>$v){
01046 $lines[$k]='<c:alink:'.$row[$options['cols'][$colName]['link']].'>'.$v.'</c:alink>';
01047 }
01048 }
01049 } else {
01050 $lines = explode("\n",$row[$colName]);
01051 }
01052 } else {
01053 $lines = array();
01054 }
01055 $this->y -= $options['rowGap'];
01056 foreach ($lines as $line){
01057 $line = $this->ezProcessText($line);
01058 $start=1;
01059
01060 while (strlen($line) || $start){
01061 $start=0;
01062 if (!$colNewPage){
01063 $this->y=$this->y-$height;
01064 }
01065 if ($this->y < $this->ez['bottomMargin']){
01066
01067 $newPage=1;
01068 $colNewPage=1;
01069 }
01070 if ($colNewPage){
01071 if (isset($leftOvers[$colName])){
01072 $leftOvers[$colName].="\n".$line;
01073 } else {
01074 $leftOvers[$colName] = $line;
01075 }
01076 $line='';
01077 } else {
01078 if (isset($options['cols'][$colName]) && isset($options['cols'][$colName]['justification']) ){
01079 $just = $options['cols'][$colName]['justification'];
01080 } else {
01081 $just='left';
01082 }
01083
01084 $line=$this->addTextWrap($pos[$colName],$this->y,$maxWidth[$colName],$options['fontSize'],$line,$just);
01085 }
01086 }
01087 }
01088
01089 $dy=$y+$height-$this->y+$options['rowGap'];
01090 if ($dy-$height*$newPage>$mx){
01091 $mx=$dy-$height*$newPage;
01092 }
01093 }
01094
01095 $row = $leftOvers;
01096
01097 if ($options['shaded'] && $cnt%2==0){
01098 $this->closeObject();
01099 $this->setColor($options['shadeCol'][0],$options['shadeCol'][1],$options['shadeCol'][2],1);
01100 $this->filledRectangle($x0-$options['gap']/2,$y+$decender+$height-$mx,$x1-$x0,$mx);
01101 $this->reopenObject($textObjectId);
01102 }
01103
01104 if ($options['shaded']==2 && $cnt%2==1){
01105 $this->closeObject();
01106 $this->setColor($options['shadeCol2'][0],$options['shadeCol2'][1],$options['shadeCol2'][2],1);
01107 $this->filledRectangle($x0-$options['gap']/2,$y+$decender+$height-$mx,$x1-$x0,$mx);
01108 $this->reopenObject($textObjectId);
01109 }
01110
01111 if ($options['showLines']>1){
01112
01113
01114 $this->saveState();
01115 $this->setStrokeColor($options['lineCol'][0],$options['lineCol'][1],$options['lineCol'][2],1);
01116
01117 if ($firstLine){
01118 $this->setLineStyle($options['outerLineThickness']);
01119 $firstLine=0;
01120 } else {
01121 $this->setLineStyle($options['innerLineThickness']);
01122 }
01123 $this->line($x0-$options['gap']/2,$y+$decender+$height,$x1-$options['gap']/2,$y+$decender+$height);
01124 $this->restoreState();
01125
01126 }
01127 }
01128 $y=$y-$mx+$height;
01129
01130
01131 if ($options['splitRows']==0){
01132 if ( ( ($this->ezPageCount != $pageStart) || (isset($this->ez['columns']) && $this->ez['columns']['on']==1 && $columnStart != $this->ez['columns']['colNum'] )) && $secondTurn==0){
01133
01134 $newPage=1;
01135 $secondTurn=1;
01136 $this->transaction('rewind');
01137 $row = $row_orig;
01138 $y = $y_orig;
01139 $y0 = $y0_orig;
01140 $y1 = $y1_orig;
01141 $ok=0;
01142
01143 $dm = $this->ez['leftMargin']-$baseLeftMargin;
01144 foreach($basePos as $k=>$v){
01145 $pos[$k]=$v+$dm;
01146 }
01147 $x0=$baseX0+$dm;
01148 $x1=$baseX1+$dm;
01149
01150 } else {
01151 $this->transaction('commit');
01152 $ok=1;
01153 }
01154 } else {
01155 $ok=1;
01156 }
01157
01158 }
01159 if ($abortTable){
01160 if ($ok==0){
01161 $this->transaction('abort');
01162 }
01163
01164 $this->transaction('rewind');
01165 $this->ezNewPage();
01166 break;
01167 }
01168
01169 }
01170
01171 }
01172
01173
01174 $this->transaction('commit');
01175
01176 $y2=$y+$decender;
01177 if ($options['showLines']){
01178 if (!$options['showHeadings']){
01179 $y0=$y1;
01180 }
01181 $this->ezPrvtTableDrawLines($pos,$options['gap'],$x0,$x1,$y0,$y1,$y2,$options['lineCol'],$options['innerLineThickness'],$options['outerLineThickness'],$options['showLines']);
01182 }
01183
01184
01185 if ($options['shaded']){
01186 $this->closeObject();
01187 $this->restoreState();
01188 }
01189
01190 $this->y=$y;
01191 return $y;
01192 }
01193
01194
01195 function ezProcessText($text){
01196
01197
01198 $search = array('<u>','<U>','</u>','</U>');
01199 $replace = array('<c:uline>','<c:uline>','</c:uline>','</c:uline>');
01200 return str_replace($search,$replace,$text);
01201 }
01202
01203
01204
01205 function ezText($text,$size=0,$options=array(),$test=0){
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01223
01224
01225
01226 $text = $this->ezProcessText($text);
01227
01228 $newPage=false;
01229 $store_y = $this->y;
01230
01231 if (is_array($options) && isset($options['aleft'])){
01232 $left=$options['aleft'];
01233 } else {
01234 $left = $this->ez['leftMargin'] + ((is_array($options) && isset($options['left']))?$options['left']:0);
01235 }
01236 if (is_array($options) && isset($options['aright'])){
01237 $right=$options['aright'];
01238 } else {
01239 $right = $this->ez['pageWidth'] - $this->ez['rightMargin'] - ((is_array($options) && isset($options['right']))?$options['right']:0);
01240 }
01241 if ($size<=0){
01242 $size = $this->ez['fontSize'];
01243 } else {
01244 $this->ez['fontSize']=$size;
01245 }
01246
01247 if (is_array($options) && isset($options['justification'])){
01248 $just = $options['justification'];
01249 } else {
01250 $just = 'left';
01251 }
01252
01253
01254 if (is_array($options) && isset($options['leading'])) { ## use leading instead of spacing
01255 $height = $options['leading'];
01256 } else if (is_array($options) && isset($options['spacing'])) {
01257 $height = $this->getFontHeight($size) * $options['spacing'];
01258 } else {
01259 $height = $this->getFontHeight($size);
01260 }
01261
01262
01263 $lines = explode("\n",$text);
01264 foreach ($lines as $line){
01265 $start=1;
01266 while (strlen($line) || $start){
01267 $start=0;
01268 $this->y=$this->y-$height;
01269 if ($this->y < $this->ez['bottomMargin']){
01270 if ($test){
01271 $newPage=true;
01272 } else {
01273 $this->ezNewPage();
01274
01275 }
01276 }
01277 if (is_array($options) && isset($options['aleft'])){
01278 $left=$options['aleft'];
01279 } else {
01280 $left = $this->ez['leftMargin'] + ((is_array($options) && isset($options['left']))?$options['left']:0);
01281 }
01282 if (is_array($options) && isset($options['aright'])){
01283 $right=$options['aright'];
01284 } else {
01285 $right = $this->ez['pageWidth'] - $this->ez['rightMargin'] - ((is_array($options) && isset($options['right']))?$options['right']:0);
01286 }
01287 $line=$this->addTextWrap($left,$this->y,$right-$left,$size,$line,$just,0,$test);
01288 }
01289 }
01290
01291 if ($test){
01292 $this->y=$store_y;
01293 return $newPage;
01294 } else {
01295 return $this->y;
01296 }
01297 }
01298
01299
01300
01301 function ezImage($image,$pad = 5,$width = 0,$resize = 'full',$just = 'center',$border = ''){
01302
01303 if (stristr($image,':
01304 {
01305 $fp = @fopen($image,"rb");
01306 while(!feof($fp))
01307 {
01308 $cont.= fread($fp,1024);
01309 }
01310 fclose($fp);
01311 $image = tempnam ("/tmp", "php-pdf");
01312 $fp2 = @fopen($image,"w");
01313 fwrite($fp2,$cont);
01314 fclose($fp2);
01315 $temp = true;
01316 }
01317
01318 if (!(file_exists($image))) return false;
01319 $imageInfo = getimagesize($image);
01320 switch ($imageInfo[2]){
01321 case 2:
01322 $type = "jpeg";
01323 break;
01324 case 3:
01325 $type = "png";
01326 break;
01327 default:
01328 return false;
01329 }
01330 if ($width == 0) $width = $imageInfo[0];
01331 $ratio = $imageInfo[0]/$imageInfo[1];
01332
01333
01334 if (isset($this->ez['columns']) && $this->ez['columns']['on'] == 1)
01335 {
01336 $bigwidth = $this->ez['columns']['width'] - ($pad * 2);
01337 }
01338 else
01339 {
01340 $bigwidth = $this->ez['pageWidth'] - ($pad * 2);
01341 }
01342
01343 if ($resize == 'full' || $resize == 'width' || $width > $bigwidth)
01344 {
01345 $width = $bigwidth;
01346
01347 }
01348
01349 $height = ($width/$ratio);
01350
01351
01352 if ($height > ($this->y - $this->ez['bottomMargin'] - ($pad * 2)))
01353 {
01354 if ($resize != 'full')
01355 {
01356 $this->ezNewPage();
01357 }
01358 else
01359 {
01360 $height = ($this->y - $this->ez['bottomMargin'] - ($pad * 2));
01361 $width = ($height*$ratio);
01362 }
01363 }
01364
01365
01366 if ($width < $bigwidth)
01367 {
01368
01369 if ($just == 'center')
01370 {
01371 $offset = ($bigwidth - $width) / 2;
01372 }
01373
01374 if ($just == 'right')
01375 {
01376 $offset = ($bigwidth - $width);
01377 }
01378
01379 if ($just == 'left')
01380 {
01381 $offset = 0;
01382 }
01383 }
01384
01385
01386
01387 if ($type == "jpeg"){
01388 $this->addJpegFromFile($image,$this->ez['leftMargin'] + $pad + $offset, $this->y + $this->getFontHeight($this->ez['fontSize']) - $pad - $height,$width);
01389 }
01390
01391 if ($type == "png"){
01392 $this->addPngFromFile($image,$this->ez['leftMargin'] + $pad + $offset, $this->y + $this->getFontHeight($this->ez['fontSize']) - $pad - $height,$width);
01393 }
01394
01395 if ($border != '')
01396 {
01397 if (!(isset($border['color'])))
01398 {
01399 $border['color']['red'] = .5;
01400 $border['color']['blue'] = .5;
01401 $border['color']['green'] = .5;
01402 }
01403 if (!(isset($border['width']))) $border['width'] = 1;
01404 if (!(isset($border['cap']))) $border['cap'] = 'round';
01405 if (!(isset($border['join']))) $border['join'] = 'round';
01406
01407
01408 $this->setStrokeColor($border['color']['red'],$border['color']['green'],$border['color']['blue']);
01409 $this->setLineStyle($border['width'],$border['cap'],$border['join']);
01410 $this->rectangle($this->ez['leftMargin'] + $pad + $offset, $this->y + $this->getFontHeight($this->ez['fontSize']) - $pad - $height,$width,$height);
01411
01412 }
01413
01414 $this->y = $this->y - $pad - $height;
01415
01416 if ($temp == true) unlink($image);
01417
01418 }
01419
01420
01421
01422
01423 function loadTemplate($templateFile){
01424
01425
01426
01427
01428 if (!file_exists($templateFile)){
01429 return -1;
01430 }
01431
01432 $code = implode('',file($templateFile));
01433 if (!strlen($code)){
01434 return;
01435 }
01436
01437 $code = trim($code);
01438 if (substr($code,0,5)=='<?php'){
01439 $code = substr($code,5);
01440 }
01441 if (substr($code,-2)=='?>'){
01442 $code = substr($code,0,strlen($code)-2);
01443 }
01444 if (isset($this->ez['numTemplates'])){
01445 $newNum = $this->ez['numTemplates'];
01446 $this->ez['numTemplates']++;
01447 } else {
01448 $newNum=0;
01449 $this->ez['numTemplates']=1;
01450 $this->ez['templates']=array();
01451 }
01452
01453 $this->ez['templates'][$newNum]['code']=$code;
01454
01455 return $newNum;
01456 }
01457
01458
01459
01460 function execTemplate($id,$data=array(),$options=array()){
01461
01462 if (!isset($this->ez['templates'][$id])){
01463 return;
01464 }
01465 eval($this->ez['templates'][$id]['code']);
01466 }
01467
01468
01469 function ilink($info){
01470 $this->alink($info,1);
01471 }
01472
01473 function alink($info,$internal=0){
01474
01475 $lineFactor=0.05;
01476 switch($info['status']){
01477 case 'start':
01478 case 'sol':
01479
01480
01481 if (!isset($this->ez['links'])){
01482 $this->ez['links']=array();
01483 }
01484 $i = $info['nCallback'];
01485 $this->ez['links'][$i] = array('x'=>$info['x'],'y'=>$info['y'],'angle'=>$info['angle'],'decender'=>$info['decender'],'height'=>$info['height'],'url'=>$info['p']);
01486 if ($internal==0){
01487 $this->saveState();
01488 $this->setColor(0,0,1);
01489 $this->setStrokeColor(0,0,1);
01490 $thick = $info['height']*$lineFactor;
01491 $this->setLineStyle($thick);
01492 }
01493 break;
01494 case 'end':
01495 case 'eol':
01496
01497
01498 $i = $info['nCallback'];
01499 $start = $this->ez['links'][$i];
01500
01501 if ($internal){
01502 $this->addInternalLink($start['url'],$start['x'],$start['y']+$start['decender'],$info['x'],$start['y']+$start['decender']+$start['height']);
01503 } else {
01504 $a = deg2rad((float)$start['angle']-90.0);
01505 $drop = $start['height']*$lineFactor*1.5;
01506 $dropx = cos($a)*$drop;
01507 $dropy = -sin($a)*$drop;
01508 $this->line($start['x']-$dropx,$start['y']-$dropy,$info['x']-$dropx,$info['y']-$dropy);
01509 $this->addLink($start['url'],$start['x'],$start['y']+$start['decender'],$info['x'],$start['y']+$start['decender']+$start['height']);
01510 $this->restoreState();
01511 }
01512 break;
01513 }
01514 }
01515
01516
01517
01518 function uline($info){
01519
01520 $lineFactor=0.05;
01521 switch($info['status']){
01522 case 'start':
01523 case 'sol':
01524
01525
01526 if (!isset($this->ez['links'])){
01527 $this->ez['links']=array();
01528 }
01529 $i = $info['nCallback'];
01530 $this->ez['links'][$i] = array('x'=>$info['x'],'y'=>$info['y'],'angle'=>$info['angle'],'decender'=>$info['decender'],'height'=>$info['height']);
01531 $this->saveState();
01532 $thick = $info['height']*$lineFactor;
01533 $this->setLineStyle($thick);
01534 break;
01535 case 'end':
01536 case 'eol':
01537
01538
01539 $i = $info['nCallback'];
01540 $start = $this->ez['links'][$i];
01541
01542 $a = deg2rad((float)$start['angle']-90.0);
01543 $drop = $start['height']*$lineFactor*1.5;
01544 $dropx = cos($a)*$drop;
01545 $dropy = -sin($a)*$drop;
01546 $this->line($start['x']-$dropx,$start['y']-$dropy,$info['x']-$dropx,$info['y']-$dropy);
01547 $this->restoreState();
01548 break;
01549 }
01550 }
01551
01552
01553
01554 }
01555 ?>