|
PHP开发实例:创建PDF中文文档的程序代码(5) if($nl==1) { $this->x=$this->lMargin; $w=$this->w-$this->rMargin-$this->x; $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; } $nl++; continue; } if(!$ascii or $c==' ') $sep=$i; $l+=$ascii ? $cw[$c] : 1000; if($l>$wmax) { //Automatic line break if($sep==-1 or $i==$j) { if($this->x>$this->lMargin) { //Move to next line $this->x=$this->lMargin; $this->y+=$h; $w=$this->w-$this->rMargin-$this->x; $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; $i++; $nl++; continue; } if($i==$j) $i+=$ascii ? 1 : 2; $this->Cell($w,$h,substr($s,$j,$i-$j),0,2,'',0,$link); } else { $this->Cell($w,$h,substr($s,$j,$sep-$j),0,2,'',0,$link); $i=($s[$sep]==' ') ? $sep+1 : $sep; } $sep=-1; $j=$i; $l=0; if($nl==1) { $this->x=$this->lMargin; $w=$this->w-$this->rMargin-$this->x; $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; } $nl++; } else $i+=$ascii ? 1 : 2; } //Last chunk if($i!=$j) $this->Cell($l/1000*$this->FontSize,$h,substr($s,$j,$i-$j),0,0,'',0,$link); } function _putfonts() { $nf=$this->n; foreach($this->diffs as $diff) { //Encodings $this->_newobj(); $this->_out('<</Type /Encoding /BaseEncoding /WinAnsiEncoding /Differences ['.$diff.']>>'); $this->_out('endobj'); } $mqr=get_magic_quotes_runtime(); set_magic_quotes_runtime(0); foreach($this->FontFiles as $file=>$info) { //Font file embedding $this->_newobj(); $this->FontFiles[$file]['n']=$this->n; if(defined('FPDF_FONTPATH')) $file=FPDF_FONTPATH.$file; $size=filesize($file); if(!$size) $this->Error('Font file not found'); $this->_out('<</Length '.$size); if(substr($file,-2)=='.z') $this->_out('/Filter /FlateDecode'); $this->_out('/Length1 '.$info['length1']);
|