Php 如何在FPDF的单元格函数中包装文本?

Php 如何在FPDF的单元格函数中包装文本?,php,fpdf,Php,Fpdf,这是我的密码: $pdf->SetFillColor(255,255,255); $pdf -> SetTextColor(0,0,0); $pdf -> SetFont ("Times","B","10"); $pdf -> Cell(60,7,"NAME AND ADDRESS OF SCHOOL",'L,T',0,'L','false'); $pdf -> Cell(32,7,"LEVEL",'L,T',0,'L','false'); $pdf -> C

这是我的密码:

$pdf->SetFillColor(255,255,255);
$pdf -> SetTextColor(0,0,0);
$pdf -> SetFont ("Times","B","10");
$pdf -> Cell(60,7,"NAME AND ADDRESS OF SCHOOL",'L,T',0,'L','false');
$pdf -> Cell(32,7,"LEVEL",'L,T',0,'L','false');
$pdf -> Cell(28,7,"DATE FROM",'L,T',0,'L','false');
$pdf -> Cell(28,7,"DATE TO",'L,T',0,'L','false');
$pdf -> Cell(28,7,"DEGREE",'L,T',0,'L','false');
$pdf -> Cell(20,7,"AWARDS",'L,T,R',1,'L','false');


    if (isset($_GET['id'])) {
        $sql = "SELECT * FROM education_info WHERE applicant_code = " . $_GET['id'];
        $result = mysqli_query($coonn, $sql);
        $resultCheck = mysqli_num_rows($result);

        if ($resultCheck > 0) {
        while ($row = mysqli_fetch_assoc($result)) # end of first php code  
            {

            $pdf -> SetFont ("Times","","11");
            $pdf -> Cell(60,5, $row['educ_name'],'T,L',0,'L','false'); 
            $pdf -> Cell(32,5, "",'T,L',0,'L','false'); 
            $pdf -> Cell(28,5, "",'T,L',0,'L','false');
            $pdf -> Cell(28,5, "",'T,L',0,'L','false'); 
            $pdf -> Cell(28,5, "",'T,L',0,'L','false'); 
            $pdf -> Cell(20,5, "",'T,L,R',1,'L','false');    

            $pdf -> Cell(60,5, $row['educ_address'],'L,B',0,'L','false'); 
            $pdf -> Cell(32,5, $row['educ_level'],'L,B',0,'L','false');
            $pdf -> Cell(28,5, $row['educ_from'],'L,B',0,'L','false'); 
            $pdf -> Cell(28,5, $row['educ_to'],'L,B',0,'L','false'); 
            $pdf -> Cell(28,5, $row['educ_degree'],'L,B',0,'L','false'); 
            $pdf -> Cell(20,5, $row['educ_award'],'L,R,B',1,'L','false'); 
            }
        }
    }
如果文本已经到达单元格的末尾,我想让它自动转到下一行。我在FPDF中使用默认格式的Cell函数

function Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='')
    {
        // Output a cell
        $k = $this->k;
        if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $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->CurPageSize,$this->CurRotation);
            $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 || $border==1)
        {
            if($fill)
                $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(strpos($border,'L')!==false)
                $s .= 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)
                $s .= 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)
                $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(strpos($border,'B')!==false)
                $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(!isset($this->CurrentFont))
                $this->Error('No font has been set');
            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.' ';
            $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));
            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;
    }

是否有可能实现与细胞功能相同的功能?请帮帮我。我被困在这里,为了完成我的项目,这是我唯一需要做的事情。提前谢谢

您的问题主要涉及的不是有限的单元格方法,而是表的创建

如果您想绘制一个表,其中每个行实体具有与内容大小无关的高度,则应该考虑按照“FKY”提出或实现一个已经可用的解决方案。例如,这个:


使用multiCell,例如:
$pdf->multiCell(200,40,$row['educ\u address'],1)或扩展FPDF类:他的问题与单元格或行高度无关。这是关于当数据超过单元格宽度时在单元格内包装数据的问题。@Dave,相信我,确实如此,这是fpdf工具中的一个已知限制。仅仅将数据包装在一个单独的单元格中对他没有任何帮助,你还必须记住所有其他单元格的高度,并确定最高的单元格高度。获得后,可以根据最大值绘制下一行。如果没有这个高度,你的桌子(显然是一张桌子)看起来就像是一堵倒塌的墙。