Server IP : 202.29.229.35 / Your IP : 18.225.235.148 Web Server : Apache System : Linux aapanel2 4.15.0-213-generic #224-Ubuntu SMP Mon Jun 19 13:30:12 UTC 2023 x86_64 User : www ( 1001) PHP Version : 5.5.38 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/www.ivecr2.ac.th/pdfNew/fpdf/ |
Upload File : |
<?php /******************************************************************************* * FPDF Thai Positioning Improve * * * * Version: 1.01 * * Date: 2009-10-08 * * Advisor: Mr. Wittawas Puntumchinda * * Coding: Mr. Sirichai Fuangfoo * * License: FPDF * *******************************************************************************/ require('fpdf.php'); class FPDF_Thai extends FPDF { var $txt_error; var $s_error; var $string_th; var $s_th; var $pointX; var $pointY; var $curPointX; var $checkFill; var $array_th; /**************************************************************************************** * »ÃÐàÀ·: Function ¢Í§ Class FPDF_TH * ÍéÒ§ÍÔ§: Function MultiCell ¢Í§ Class FPDF * ¡Ò÷ӧҹ: ãªé㹡ÒþÔÁ¾ì¢éͤÇÒÁËÅÒºÃ÷Ѵ¢Í§àÍ¡ÊÒà PDF * ÃٺẺ: MultiCell ( $w = ¤ÇÒÁ¡ÇéÒ§¢Í§Cell, * $h = ¤ÇÒÁÊÙ§¢Í§Cell, * $txt = ¢éͤÇÒÁ·Õè¨Ð¾ÔÁ¾ì, * $border = ¡Ó˹´¡ÒÃáÊ´§àÊ鹡Ãͺ(0 = äÁèáÊ´§, 1= áÊ´§) , * $align = µÓá˹觢éͤÇÒÁ(L = «éÒÂ, R = ¢ÇÒ, C = ¡Öè§¡ÅÒ§, J = ¡ÃШÒÂ), * $fill = ¡Ó˹´¡ÒÃáÊ´§ÊբͧCell(false = äÁèáÊ´§, true = áÊ´§) * ) *****************************************************************************************/ function MultiCell($w, $h, $txt, $border=0, $align='J', $fill=false) { //Output text with automatic or explicit line breaks $cw=&$this->CurrentFont['cw']; if($w==0) $w=$this->w-$this->rMargin-$this->x; $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; $s=str_replace("\r",'',$txt); $nb=strlen($s); if($nb>0 && $s[$nb-1]=="\n") $nb--; $b=0; if($border) { if($border==1) { $border='LTRB'; $b='LRT'; $b2='LR'; } else { $b2=''; if(strpos($border,'L')!==false) $b2.='L'; if(strpos($border,'R')!==false) $b2.='R'; $b=(strpos($border,'T')!==false) ? $b2.'T' : $b2; } } $sep=-1; $i=0; $j=0; $l=0; $ns=0; $nl=1; while($i<$nb) { //Get next character $c=$s{$i}; if($c=="\n") { //Explicit line break if($this->ws>0) { $this->ws=0; $this->_out('0 Tw'); } $this->MCell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); $i++; $sep=-1; $j=$i; $l=0; $ns=0; $nl++; if($border && $nl==2) $b=$b2; continue; } if($c==' ') { $sep=$i; $ls=$l; $ns++; } $l+=$cw[$c]; if($l>$wmax) { //Automatic line break if($sep==-1) { if($i==$j) $i++; if($this->ws>0) { $this->ws=0; $this->_out('0 Tw'); } $this->MCell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); } else { if($align=='J') { $this->ws=($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0; $this->_out(sprintf('%.3F Tw',$this->ws*$this->k)); } $this->MCell($w,$h,substr($s,$j,$sep-$j),$b,2,$align,$fill); $i=$sep+1; } $sep=-1; $j=$i; $l=0; $ns=0; $nl++; if($border && $nl==2) $b=$b2; } else $i++; } //Last chunk if($this->ws>0) { $this->ws=0; $this->_out('0 Tw'); } if($border && strpos($border,'B')!==false) $b.='B'; $this->MCell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); $this->x=$this->lMargin; } /**************************************************************************************** * »ÃÐàÀ· : Function ¢Í§ Class FPDF_TH * ÍéÒ§ÍÔ§ : Function Cell ¢Í§ Class FPDF * ¡Ò÷ӧҹ : ãªé㹡ÒþÔÁ¾ì¢éͤÇÒÁ·ÕÅкÃ÷Ѵ¢Í§àÍ¡ÊÒà PDF * ÃٺẺ : Cell ( $w = ¤ÇÒÁ¡ÇéÒ§¢Í§Cell, * $h = ¤ÇÒÁÊÙ§¢Í§Cell, * $txt = ¢éͤÇÒÁ·Õè¨Ð¾ÔÁ¾ì, * $border = ¡Ó˹´¡ÒÃáÊ´§àÊ鹡Ãͺ(0 = äÁèáÊ´§, 1= áÊ´§), * $ln = µÓá˹觷ÕèÍÂÙè¶Ñ´ä»¨Ò¡à«ÅÅì(0 = ¢ÇÒ, 1 = ºÃ÷Ѵ¶Ñ´ä», 2 = ´éÒ¹ÅèÒ§), * $align = µÓá˹觢éͤÇÒÁ(L = «éÒÂ, R = ¢ÇÒ, C = ¡Öè§¡ÅÒ§, T = º¹, B = ÅèÒ§), * $fill = ¡Ó˹´¡ÒÃáÊ´§ÊբͧCell(false = äÁèáÊ´§, true = áÊ´§), * $link = URL ·Õèµéͧ¡ÒÃãËé¢éͤÇÒÁàª×èÍÁâ§件֧ * ) *****************************************************************************************/ function utf8_to_tis620($string) { $str = $string; $res = ""; for ($i = 0; $i < strlen($str); $i++) { if (ord($str[$i]) == 224) { $unicode = ord($str[$i+2]) & 0x3F; $unicode |= (ord($str[$i+1]) & 0x3F) << 6; $unicode |= (ord($str[$i]) & 0x0F) << 12; $res .= chr($unicode-0x0E00+0xA0); $i += 2; } else { $res .= $str[$i]; } } return $res; } function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='') { $this->checkFill=""; $k=$this->k; if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) { //¢Öé¹Ë¹éÒãËÁèÍѵâ¹Áѵ $x=$this->x; $ws=$this->ws; if($ws>0) { $this->ws=0; $this->_out('0 Tw'); } $this->AddPage($this->CurOrientation); $this->x=$x; if($ws>0) { $this->ws=$ws; $this->_out(sprintf('%.3F Tw',$ws*$k)); } } //¡Ó˹´¤ÇÒÁ¡ÇéÒ§à«ÅÅìà·èҡѺ˹éÒ¡ÃдÒÉ if($w==0) $w=$this->w-$this->rMargin-$this->x; $this->s_th=''; //¡Ó˹´¡ÒÃáÊ´§àÊ鹡Ãͺ 4 ´éÒ¹ áÅÐÊÕ¡Ãͺ if($fill || $border==1) { if($fill) $op=($border==1) ? 'B' : 'f'; else $op='S'; $this->s_th=sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op); if($op=='f') $this->checkFill=$op; } //¡Ó˹´¡ÒÃáÊ´§àÊ鹡Ãͺ·ÕÅÐàÊé¹ if(is_string($border)) { $x=$this->x; $y=$this->y; if(strpos($border,'L')!==false) $this->s_th.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); if(strpos($border,'T')!==false) $this->s_th.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); if(strpos($border,'R')!==false) $this->s_th.=sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); if(strpos($border,'B')!==false) $this->s_th.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); } if($txt!=='') { $x=$this->x; $y=$this->y; //¡Ó˹´¡ÒèѴ¢éͤÇÒÁã¹à«ÅÅìµÒÁá¹ÇÃдѺ if(strpos($align,'R')!==false) $dx=$w-$this->cMargin-$this->GetStringWidth($txt); elseif(strpos($align,'C')!==false) $dx=($w-$this->GetStringWidth($txt))/2; else $dx=$this->cMargin; //¡Ó˹´¡ÒèѴ¢éͤÇÒÁã¹à«ÅÅìµÒÁá¹Ç´Ôè§ if(strpos($align,'T')!==false) $dy=$h-(.7*$this->k*$this->FontSize); elseif(strpos($align,'B')!==false) $dy=$h-(.3*$this->k*$this->FontSize); else $dy=.5*$h; //¡Ó˹´¡ÒâմàÊé¹ãµé¢éͤÇÒÁ if($this->underline) { //¡Ó˹´ºÑ¹·Ö¡¡ÃÒ¿Ô¡ if($this->ColorFlag) $this->s_th.=' q '.$this->TextColor.' '; //¢Õ´àÊé¹ãµé¢éͤÇÒÁ0 $this->s_th.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); //¡Ó˹´¤×¹¤èÒ¡ÃÒ¿Ô¡ if($this->ColorFlag) $this->s_th.=' Q '; } //¡Ó˹´¢éͤÇÒÁàª×èÍÁâ§件֧ if($link) $this->Link($this->x,$this->y,$this->GetStringWidth($txt),$this->FontSize,$link); /*if($s) $this->_out($s); $s='';*/ //µÑ´ÍÑ¡ÉÃÍÍ¡¨Ò¡¢éͤÇÒÁ ·ÕÅеÑÇà¡çºÅ§ÍÐàÃÂì $this->array_th=substr($txt,0); $i=0; $this->pointY=($this->h-($y+$dy+.3*$this->FontSize))*$k; $this->curPointX=($x+$dx)*$k; $this->string_th=''; $this->txt_error=0; while($i<strlen($txt)) { //¡Ó˹´µÓá˹觷Õè¨Ð¾ÔÁ¾ìÍÑ¡ÉÃã¹à«ÅÅì if(strpos('èéêëìÔÕÖ×çÑÓØÙ',$this->array_th[$i])!==false) { $pX=$x+$dx; if($i>0) $pX+=.02*$this->GetStringWidth($this->array_th[$i-1]); $this->pointX=$pX*$k; //µÃǨÊͺÍÑ¡Éà »ÃѺµÓá˹è§áÅзӡÒþÔÁ¾ì $this->_checkT($i); if($this->txt_error==0) $this->string_th.=$this->array_th[$i]; else { $this->txt_error=0; } } else $this->string_th.=$this->array_th[$i]; //àÅ×è͹µÓáË¹è§ x ä»·ÕèµÑÇ·Õè¨Ð¾ÔÁ¾ì¶Ñ´ä» $x=$x+$this->GetStringWidth($this->array_th[$i]); $i++; } $this->TText($this->curPointX,$this->pointY,$this->string_th); /*$this->s_th.=$this->s_hidden.$this->s_error;*/ //$this->s_th.=$this->s_error; if($this->s_th) $this->_out($this->s_th); } else //¹Ó¤èÒä»áÊ´§àÁ×èÍäÁèÁÕ¢éͤÇÒÁ $this->_out($this->s_th); $this->lasth=$h; //µÃǨÊͺ¡ÒÃÇÒ§µÓá˹觢ͧà«ÅÅì¶Ñ´ä» if($ln>0) { //¢Ö鹺Ã÷ѴãËÁè $this->y+=$h; if($ln==1) $this->x=$this->lMargin; } else $this->x+=$w; } /******************************************************************************** * ãªé§Ò¹: Function Cell ¢Í§ Class FPDF_TH * ¡Ò÷ӧҹ: ãªé㹡ÒõÃǨÊͺÍÑ¡Éà áÅлÃѺµÓá˹觡è͹·Õè¨Ð·Ó¡ÒþÔÁ¾ì * ¤ÇÒÁµéͧ¡ÒÃ: $this->array_th = ÍÐàÃÂì¢Í§ÍÑ¡É÷ÕèµÑ´ÍÍ¡¨Ò¡¢éͤÇÒÁ * $i = ÅӴѺ»Ñ¨¨ØºÑ¹ã¹ÍÐàÃÂì·Õè¨Ð·Ó¡ÒõÃǨÊͺ * $s = ÊÒÂÍÑ¡¢ÃТͧ⤴ PDF *********************************************************************************/ function _checkT($i) { $pointY=$this->pointY; $pointX=$this->pointX; $nb=strlen($this->array_th); //µÇ¨Êͺ¡ÒÃáÊ´§¼Å¢Í§µÑÇÍÑ¡ÉÃà˹×ÍÊÃк¹ if($this->_errorTh($this->array_th[$i])==1) { //µÃǨÊͺµÑÇÍÑ¡Éáè͹˹éÒ¹Ñé¹äÁèãªèÊÃк¹ »ÃѺµÓá˹è§Å§ if(($this->_errorTh($this->array_th[$i-1])!=2)&&($this->array_th[$i+1]!="Ó")) { //¶éÒµÑǹÑé¹à»ç¹äÁéàÍ¡ËÃ×ÍäÁé¨ÑµÇÒ if($this->array_th[$i]=="è"||$this->array_th[$i]=="ë") { $pointY=$this->pointY-.2*$this->FontSize*$this->k; $this->txt_error=1; } //¶éÒµÑǹÑé¹à»ç¹äÁéâ·ËÃ×ÍäÁéµÃÕ elseif($this->array_th[$i]=='é'||$this->array_th[$i]=='ê') { $pointY=$this->pointY-.23*$this->FontSize*$this->k; $this->txt_error=1; } //¶éÒµÑǹÑé¹à»ç¹¡ÒÃѹµì else { $pointY=$this->pointY-.17*$this->FontSize*$this->k; $this->txt_error=1; } } //µÃǨÊͺµÑÇÍÑ¡ÉõÑÇ¡è͹˹éÒ¹Ñé¹à»ç¹µÑÇÍÑ¡ÉÃËÒ§ÂÒǺ¹ if($this->_errorTh($this->array_th[$i-1])==3) { //¶éÒµÑǹÑé¹à»ç¹äÁéàÍ¡ËÃ×ÍäÁé¨ÑµÇÒ if($this->array_th[$i]=="è"||$this->array_th[$i]=="ë") { $pointX=$this->pointX-.17*$this->GetStringWidth($this->array_th[$i-1])*$this->k; $this->txt_error=1; } //¶éÒµÑǹÑé¹à»ç¹äÁéâ·ËÃ×ÍäÁéµÃÕ elseif($this->array_th[$i]=='é'||$this->array_th[$i]=='ê') { $pointX=$this->pointX-.25*$this->GetStringWidth($this->array_th[$i-1])*$this->k; $this->txt_error=1; } //¶éÒµÑǹÑé¹à»ç¹¡ÒÃѹµì else { $pointX=$this->pointX-.4*$this->GetStringWidth($this->array_th[$i-1])*$this->k; $this->txt_error=1; } } //µÃǨÊͺµÑÇÍÑ¡ÉõÑÇ¡è͹˹éÒ¹Ñé¹ä»ÍÕ¡à»ç¹µÑÇÍÑ¡ÉÃËÒ§ÂÒǺ¹ if($i>=2 && $this->_errorTh($this->array_th[$i-2])==3) { //¶éÒµÑǹÑé¹à»ç¹äÁéàÍ¡ËÃ×ÍäÁé¨ÑµÇÒ if($this->array_th[$i]=="è"||$this->array_th[$i]=="ë") { $pointX=$this->pointX-.17*$this->GetStringWidth($this->array_th[$i-2])*$this->k; $this->txt_error=1; } //¶éÒµÑǹÑé¹à»ç¹äÁéâ·ËÃ×ÍäÁéµÃÕ elseif($this->array_th[$i]=='é'||$this->array_th[$i]=='ê') { $pointX=$this->pointX-.25*$this->GetStringWidth($this->array_th[$i-2])*$this->k; $this->txt_error=1; } //¶éÒµÑǹÑé¹à»ç¹¡ÒÃѹµì else { $pointX=$this->pointX-.4*$this->GetStringWidth($this->array_th[$i-2])*$this->k; $this->txt_error=1; } } } //¨º¡ÒõÃǨÊͺµÑÇÍÑ¡ÉÃà˹×ÍÊÃк¹ //µÇ¨Êͺ¡ÒÃáÊ´§¼Å¢Í§µÑÇÍÑ¡ÉÃÊÃк¹ elseif($this->_errorTh($this->array_th[$i])==2) { //µÃǨÊͺµÑÇÍÑ¡ÉõÑÇ¡è͹˹éÒ¹Ñé¹à»ç¹µÑÇÍÑ¡ÉÃËÒ§ÂÒǺ¹ if($this->_errorTh($this->array_th[$i-1])==3) { $pointX=$this->pointX-.17*$this->GetStringWidth($this->array_th[$i-1])*$this->k; $this->txt_error=1; } //¶éÒµÑǹÑé¹à»ç¹ÊÃÐÍÓ if($this->array_th[$i]=="Ó") //µÃǨÊͺµÑÇÍÑ¡ÉõÑÇ¡è͹˹éÒ¹Ñé¹à»ç¹µÑÇÍÑ¡ÉÃËÒ§ÂÒǺ¹ if($this->_errorTh($this->array_th[$i-2])==3) { $pointX=$this->pointX-.17*$this->GetStringWidth($this->array_th[$i-2])*$this->k; $this->txt_error=1; } } //¨º¡ÒõÃǨÊͺµÑÇÍÑ¡ÉÃÊÃк¹ //µÇ¨Êͺ¡ÒÃáÊ´§¼Å¢Í§µÑÇÍÑ¡ÉÃÊÃÐÅèÒ§ elseif($this->_errorTh($this->array_th[$i])==6) { //µÃǨÊͺµÑÇÍÑ¡ÉõÑÇ¡è͹˹éÒ¹Ñé¹à»ç¹µÑÇÍÑ¡Éà . ¡Ñº °. if($this->_errorTh($this->array_th[$i-1])==5) { //$this->string_th $this->curPointX $this->TText($this->curPointX,$this->pointY,$this->string_th); $this->string_th=''; $this->curPointX=$this->pointX; if($this->checkFill=='f') $this->s_th.=' q '; else $this->s_th.=' q 1 g '; //ÊÃéÒ§ÊÕèàËÅÕèÂÁä»»Ô´·Õè°Ò¹ÅèÒ§¢Í§µÑÇÍÑ¡Éà . ¡Ñº °. $s. $this->s_th.=sprintf('%.2F %.2F %.2F %.2F re f ',$this->pointX-$this->GetStringWidth($this->array_th[$i-1])*$this->k,$this->pointY-.27*$this->FontSize*$this->k,.9*$this->GetStringWidth($this->array_th[$i-1])*$this->k,.25*$this->FontSize*$this->k); $this->s_th.=' Q '; $this->txt_error=1; } //µÃǨÊͺµÑÇÍÑ¡ÉõÑÇ¡è͹˹éÒ¹Ñé¹à»ç¹ÍÑ¡¢ÃÐ ¯. ¡Ñº ®. elseif($this->_errorTh($this->array_th[$i-1])==4) { $pointY=$this->pointY-.25*$this->FontSize*$this->k; $this->txt_error=1; } //¨º¡ÒõÃǨÊͺµÑÇÍÑ¡ÉÃÊÃÐÅèÒ§ } //¨º¡ÒõÃǨÊͺµÑÇÍÑ¡ÉÃÐÊÃÐÅèÒ§ if($this->txt_error==1) $this->TText($pointX,$pointY,$this->array_th[$i]); } /******************************************************************************** * ãªé§Ò¹: Function _checkT ¢Í§ Class FPDF_TH * ¡Ò÷ӧҹ: ãªé㹡ÒõÃǨÊͺÍÑ¡É÷ÕèÍÒ¨¨Ð·ÓãËéà¡Ô´¡ÒþÔÁ¾ì·Õè¼Ô´¾ÅÒ´ * ¤ÇÒÁµéͧ¡ÒÃ: $char_th = µÑÇÍÑ¡É÷Õè¨Ðãªé㹡ÒÃà»ÃÕºà·Õº *********************************************************************************/ function _errorTh($char_th) { $txt_error=0; //µÑÇÍÑ¡Éú¹-º¹ if(($char_th=='è')||($char_th=='é')||($char_th=='ê')||($char_th=='ë')||($char_th=='ì')) $txt_error=1; //µÑÇÍÑ¡Éú¹ elseif(($char_th=='Ô')||($char_th=='Õ')||($char_th=='Ö')||($char_th=='×')||($char_th=='ç')||($char_th=='Ñ')||($char_th=='Ó')) $txt_error=2; //µÑÇÍÑ¡ÉáÅÒ§-º¹ elseif(($char_th=='»')||($char_th=='¿')||($char_th=='½')) $txt_error=3; //µÑÇÍÑ¡ÉáÅÒ§-ÅèÒ§ elseif(($char_th=='®')||($char_th=='¯')) $txt_error=4; //µÑÇÍÑ¡ÉáÅÒ§-ÅèÒ§ elseif(($char_th=='')||($char_th=='°')) $txt_error=5; //µÑÇÍÑ¡ÉÃÊÃÐÅèÒ§ elseif(($char_th=='Ø')||($char_th=='Ù')) $txt_error=6; else $txt_error=0; return $txt_error; } /******************************************************************************** * ãªé§Ò¹: Function _checkT ¢Í§ Class FPDF_TH * * ¡Ò÷ӧҹ: ãªéã¹¾ÔÁ¾ìµÑÇÍÑ¡É÷ÕèµÃǨÊͺáÅéÇ * * ¤ÇÒÁµéͧ¡ÒÃ: $txt_th = µÑÇÍÑ¡Éà 1 µÑÇ ·ÕèµÃǨÊͺáÅéÇ * * $s = ÊÒÂÍÑ¡¢ÃТͧ⤴ PDF * *********************************************************************************/ function TText($pX, $pY, $txt_th) { //µÇ¨Êͺ¡ÒÃãÊèÊÕà«ÅÅì if($this->ColorFlag) $this->s_th.=' q '.$this->TextColor.' '; $txt_th2=str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt_th))); //ÃкصÓáË¹è§ áÅоÔÁ¾ìµÑÇÍÑ¡Éà $this->s_th.=sprintf(' BT %.2F %.2F Td (%s) Tj ET ',$pX,$pY,$txt_th2); if($this->ColorFlag) $this->s_th.=' Q '; } /**************************************************************************************** * ãªé§Ò¹: called by function MultiCell within this class * ÍéÒ§ÍÔ§: Function Cell ¢Í§ Class FPDF * ¡Ò÷ӧҹ: ãªé㹡ÒþÔÁ¾ì¢éͤÇÒÁ·ÕÅкÃ÷Ѵ¢Í§àÍ¡ÊÒà PDF * ÃٺẺ: MCell ( $w = ¤ÇÒÁ¡ÇéÒ§¢Í§Cell, * $h = ¤ÇÒÁÊÙ§¢Í§Cell, * $txt = ¢éͤÇÒÁ·Õè¨Ð¾ÔÁ¾ì, * $border = ¡Ó˹´¡ÒÃáÊ´§àÊ鹡Ãͺ(0 = äÁèáÊ´§, 1= áÊ´§), * $ln = µÓá˹觷ÕèÍÂÙè¶Ñ´ä»¨Ò¡à«ÅÅì(0 = ¢ÇÒ, 1 = ºÃ÷Ѵ¶Ñ´ä», 2 = ´éÒ¹ÅèÒ§), * $align = µÓá˹觢éͤÇÒÁ(L = «éÒÂ, R = ¢ÇÒ, C = ¡Öè§¡ÅÒ§, T = º¹, B = ÅèÒ§), * $fill = ¡Ó˹´¡ÒÃáÊ´§ÊբͧCell(false = äÁèáÊ´§, true = áÊ´§) * $link = URL ·Õèµéͧ¡ÒÃãËé¢éͤÇÒÁàª×èÍÁâ§件֧ * ) *****************************************************************************************/ function MCell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='') { $this->checkFill=""; $k=$this->k; if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak()) { //¢Öé¹Ë¹éÒãËÁèÍѵâ¹Áѵ $x=$this->x; $ws=$this->ws; if($ws>0) { $this->ws=0; $this->_out('0 Tw'); } $this->AddPage($this->CurOrientation); $this->x=$x; if($ws>0) { $this->ws=$ws; $this->_out(sprintf('%.3F Tw',$ws*$k)); } } //¡Ó˹´¤ÇÒÁ¡ÇéÒ§à«ÅÅìà·èҡѺ˹éÒ¡ÃдÒÉ if($w==0) $w=$this->w-$this->rMargin-$this->x; $this->s_th=''; //¡Ó˹´¡ÒÃáÊ´§àÊ鹡Ãͺ 4 ´éÒ¹ áÅÐÊÕ¡Ãͺ if($fill || $border==1) { if($fill) $op=($border==1) ? 'B' : 'f'; else $op='S'; $this->s_th=sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op); if($op=='f') $this->checkFill=$op; } //¡Ó˹´¡ÒÃáÊ´§àÊ鹡Ãͺ·ÕÅÐàÊé¹ if(is_string($border)) { $x=$this->x; $y=$this->y; if(strpos($border,'L')!==false) $this->s_th.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); if(strpos($border,'T')!==false) $this->s_th.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); if(strpos($border,'R')!==false) $this->s_th.=sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); if(strpos($border,'B')!==false) $this->s_th.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k); } if($txt!=='') { $x=$this->x; $y=$this->y; //¡Ó˹´¡ÒèѴ¢éͤÇÒÁã¹à«ÅÅìµÒÁá¹ÇÃдѺ if(strpos($align,'R')!==false) $dx=$w-$this->cMargin-$this->GetStringWidth($txt); elseif(strpos($align,'C')!==false) $dx=($w-$this->GetStringWidth($txt))/2; else $dx=$this->cMargin; //¡Ó˹´¡ÒèѴ¢éͤÇÒÁã¹à«ÅÅìµÒÁá¹Ç´Ôè§ if(strpos($align,'T')!==false) $dy=$h-(.7*$this->k*$this->FontSize); elseif(strpos($align,'B')!==false) $dy=$h-(.3*$this->k*$this->FontSize); else $dy=.5*$h; //¡Ó˹´¡ÒâմàÊé¹ãµé¢éͤÇÒÁ if($this->underline) { //¡Ó˹´ºÑ¹·Ö¡¡ÃÒ¿Ô¡ if($this->ColorFlag) $this->s_th.='q '.$this->TextColor.' '; //¢Õ´àÊé¹ãµé¢éͤÇÒÁ0 $this->s_th.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); //¡Ó˹´¤×¹¤èÒ¡ÃÒ¿Ô¡ if($this->ColorFlag) $this->s_th.=' Q'; } //¡Ó˹´¢éͤÇÒÁàª×èÍÁâ§件֧ if($link) $this->Link($this->x,$this->y,$this->GetStringWidth($txt),$this->FontSize,$link); if($this->s_th) $this->_out($this->s_th); $this->s_th=''; //µÑ´ÍÑ¡ÉÃÍÍ¡¨Ò¡¢éͤÇÒÁ ·ÕÅеÑÇà¡çºÅ§ÍÐàÃÂì $this->array_th=substr($txt,0); $i=0; while($i<strlen($txt)) { //¡Ó˹´µÓá˹觷Õè¨Ð¾ÔÁ¾ìÍÑ¡ÉÃã¹à«ÅÅì $this->pointX=($x+$dx+.02*$this->GetStringWidth($this->array_th[$i-1]))*$k; $this->pointY=($this->h-($y+$dy+.3*$this->FontSize))*$k; //µÃǨÊͺÍÑ¡Éà »ÃѺµÓá˹è§áÅзӡÒþÔÁ¾ì $this->_checkT($i); if($this->txt_error==0) $this->TText($this->pointX,$this->pointY,$this->array_th[$i]); else { $this->txt_error=0; } //µÃǨÊͺ¡ÒÃãÊèàŢ˹éÒ if($this->array_th[$i]=='{'&&$this->array_th[$i+1]=='n'&&$this->array_th[$i+2]=='b'&&$this->array_th[$i+3]=='}') $i=$i+3; //àÅ×è͹µÓáË¹è§ x ä»·ÕèµÑÇ·Õè¨Ð¾ÔÁ¾ì¶Ñ´ä» $x=$x+$this->GetStringWidth($this->array_th[$i]); $i++; } $this->_out($this->s_th); } else //¹Ó¤èÒä»áÊ´§àÁ×èÍäÁèÁÕ¢éͤÇÒÁ $this->_out($this->s_th); $this->lasth=$h; //µÃǨÊͺ¡ÒÃÇÒ§µÓá˹觢ͧà«ÅÅì¶Ñ´ä» if($ln>0) { //¢Ö鹺Ã÷ѴãËÁè $this->y+=$h; if($ln==1) $this->x=$this->lMargin; } else $this->x+=$w; } //End of class } ?>