?? fpdf.php
字號:
$this->_out($this->FillColor);}function SetTextColor($r,$g=-1,$b=-1){ //Set color for text if(($r==0 and $g==0 and $b==0) or $g==-1) $this->TextColor=sprintf('%.3f g',$r/255); else $this->TextColor=sprintf('%.3f %.3f %.3f rg',$r/255,$g/255,$b/255); $this->ColorFlag=($this->FillColor!=$this->TextColor);}function GetStringWidth($s){ //Get width of a string in the current font $s=(string)$s; $cw=&$this->CurrentFont['cw']; $w=0; $l=strlen($s); for($i=0;$i<$l;$i++) $w+=$cw[$s{$i}]; return $w*$this->FontSize/1000;}function SetLineWidth($width){ //Set line width $this->LineWidth=$width; if($this->page>0) $this->_out(sprintf('%.2f w',$width*$this->k));}function Line($x1,$y1,$x2,$y2){ //Draw a line $this->_out(sprintf('%.2f %.2f m %.2f %.2f l S',$x1*$this->k,($this->h-$y1)*$this->k,$x2*$this->k,($this->h-$y2)*$this->k));}function Rect($x,$y,$w,$h,$style=''){ //Draw a rectangle if($style=='F') $op='f'; elseif($style=='FD' or $style=='DF') $op='B'; else $op='S'; $this->_out(sprintf('%.2f %.2f %.2f %.2f re %s',$x*$this->k,($this->h-$y)*$this->k,$w*$this->k,-$h*$this->k,$op));}function AddFont($family,$style='',$file=''){ //Add a TrueType or Type1 font $family=strtolower($family); if($family=='arial') $family='helvetica'; $style=strtoupper($style); if($style=='IB') $style='BI'; if(isset($this->fonts[$family.$style])) $this->Error('Font already added: '.$family.' '.$style); if($file=='') $file=str_replace(' ','',$family).strtolower($style).'.php'; if(defined('FPDF_FONTPATH')) $file=FPDF_FONTPATH.$file; include($file); if(!isset($name)) $this->Error('Could not include font definition file'); $i=count($this->fonts)+1; $this->fonts[$family.$style]=array('i'=>$i,'type'=>$type,'name'=>$name,'desc'=>$desc,'up'=>$up,'ut'=>$ut,'cw'=>$cw,'enc'=>$enc,'file'=>$file); if($diff) { //Search existing encodings $d=0; $nb=count($this->diffs); for($i=1;$i<=$nb;$i++) if($this->diffs[$i]==$diff) { $d=$i; break; } if($d==0) { $d=$nb+1; $this->diffs[$d]=$diff; } $this->fonts[$family.$style]['diff']=$d; } if($file) { if($type=='TrueType') $this->FontFiles[$file]=array('length1'=>$originalsize); else $this->FontFiles[$file]=array('length1'=>$size1,'length2'=>$size2); }}function SetFont($family,$style='',$size=0){ //Select a font; size given in points global $fpdf_charwidths; $family=strtolower($family); if($family=='') $family=$this->FontFamily; if($family=='arial') $family='helvetica'; elseif($family=='symbol' or $family=='zapfdingbats') $style=''; $style=strtoupper($style); if(is_int(strpos($style,'U'))) { $this->underline=true; $style=str_replace('U','',$style); } else $this->underline=false; if($style=='IB') $style='BI'; if($size==0) $size=$this->FontSizePt; //Test if font is already selected if($this->FontFamily==$family and $this->FontStyle==$style and $this->FontSizePt==$size) return; //Test if used for the first time $fontkey=$family.$style; if(!isset($this->fonts[$fontkey])) { //Check if one of the standard fonts if(isset($this->CoreFonts[$fontkey])) { if(!isset($fpdf_charwidths[$fontkey])) { //Load metric file $file=$family; if($family=='times' or $family=='helvetica') $file.=strtolower($style); $file.='.php'; if(defined('FPDF_FONTPATH')) $file=FPDF_FONTPATH.$file; include($file); if(!isset($fpdf_charwidths[$fontkey])) $this->Error('Could not include font metric file'); } $i=count($this->fonts)+1; $this->fonts[$fontkey]=array('i'=>$i,'type'=>'core','name'=>$this->CoreFonts[$fontkey],'up'=>-100,'ut'=>50,'cw'=>$fpdf_charwidths[$fontkey]); } else $this->Error('Undefined font: '.$family.' '.$style); } //Select it $this->FontFamily=$family; $this->FontStyle=$style; $this->FontSizePt=$size; $this->FontSize=$size/$this->k; $this->CurrentFont=&$this->fonts[$fontkey]; if($this->page>0) $this->_out(sprintf('BT /F%d %.2f Tf ET',$this->CurrentFont['i'],$this->FontSizePt));}function SetFontSize($size){ //Set font size in points if($this->FontSizePt==$size) return; $this->FontSizePt=$size; $this->FontSize=$size/$this->k; if($this->page>0) $this->_out(sprintf('BT /F%d %.2f Tf ET',$this->CurrentFont['i'],$this->FontSizePt));}function AddLink(){ //Create a new internal link $n=count($this->links)+1; $this->links[$n]=array(0,0); return $n;}function SetLink($link,$y=0,$page=-1){ //Set destination of internal link if($y==-1) $y=$this->y; if($page==-1) $page=$this->page; $this->links[$link]=array($page,$y);}function Link($x,$y,$w,$h,$link){ //Put a link on the page $this->PageLinks[$this->page][]=array($x*$this->k,$this->hPt-$y*$this->k,$w*$this->k,$h*$this->k,$link);}function Text($x,$y,$txt){ //Output a string $s=sprintf('BT %.2f %.2f Td (%s) Tj ET',$x*$this->k,($this->h-$y)*$this->k,$this->_escape($txt)); if($this->underline and $txt!='') $s.=' '.$this->_dounderline($x,$y,$txt); if($this->ColorFlag) $s='q '.$this->TextColor.' '.$s.' Q'; $this->_out($s);}function AcceptPageBreak(){ //Accept automatic page break or not return $this->AutoPageBreak;}function Cell($w,$h=0,$txt='',$border=0,$ln=0,$align='',$fill=0,$link=''){ //Output a cell $k=$this->k; if($this->y+$h>$this->PageBreakTrigger and !$this->InFooter and $this->AcceptPageBreak()) { //Automatic page break $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; $s=''; if($fill==1 or $border==1) { if($fill==1) $op=($border==1) ? 'B' : 'f'; else $op='S'; $s=sprintf('%.2f %.2f %.2f %.2f re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op); } if(is_string($border)) { $x=$this->x; $y=$this->y; if(is_int(strpos($border,'L'))) $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k); if(is_int(strpos($border,'T'))) $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k); if(is_int(strpos($border,'R'))) $s.=sprintf('%.2f %.2f m %.2f %.2f l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k); if(is_int(strpos($border,'B'))) $s.=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!='') { if($align=='R') $dx=$w-$this->cMargin-$this->GetStringWidth($txt); elseif($align=='C') $dx=($w-$this->GetStringWidth($txt))/2; else $dx=$this->cMargin; if($this->ColorFlag) $s.='q '.$this->TextColor.' '; $txt2=str_replace(')','\\)',str_replace('(','\\(',str_replace('\\','\\\\',$txt))); $s.=sprintf('BT %.2f %.2f Td (%s) Tj ET',($this->x+$dx)*$k,($this->h-($this->y+.5*$h+.3*$this->FontSize))*$k,$txt2); if($this->underline) $s.=' '.$this->_dounderline($this->x+$dx,$this->y+.5*$h+.3*$this->FontSize,$txt); if($this->ColorFlag) $s.=' Q'; if($link) $this->Link($this->x+$dx,$this->y+.5*$h-.5*$this->FontSize,$this->GetStringWidth($txt),$this->FontSize,$link); } if($s) $this->_out($s); $this->lasth=$h; if($ln>0) { //Go to next line $this->y+=$h; if($ln==1) $this->x=$this->lMargin; } else $this->x+=$w;}function MultiCell($w,$h,$txt,$border=0,$align='J',$fill=0){ //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 and $s[$nb-1]=="\n") $nb--; $b=0; if($border) { if($border==1) { $border='LTRB'; $b='LRT'; $b2='LR'; } else { $b2=''; if(is_int(strpos($border,'L'))) $b2.='L'; if(is_int(strpos($border,'R'))) $b2.='R'; $b=is_int(strpos($border,'T')) ? $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->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); $i++; $sep=-1; $j=$i; $l=0; $ns=0; $nl++; if($border and $nl==2) $b=$b2; continue; } if($c==' ') { $sep=$i; $ls=$l; $ns++; } $l+=isset($cw[ord($c)])?$cw[ord($c)]:0; 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->Cell($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->Cell($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 and $nl==2) $b=$b2; } else $i++; } //Last chunk if($this->ws>0) { $this->ws=0; $this->_out('0 Tw'); } if($border and is_int(strpos($border,'B'))) $b.='B'; $this->Cell($w,$h,substr($s,$j,$i-$j),$b,2,$align,$fill); $this->x=$this->lMargin;}function Write($h,$txt,$link=''){ //Output text in flowing mode
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -