FPDF print MultiCell() adjacently

前端 未结 4 1854
刺人心
刺人心 2020-12-05 19:07

I\'ve googled around and found this question very common but I can\'t seem to find a proper and direct answer. I\'m using FPDF and I want to generate tables using MultiCell(

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-05 19:21

    Just to add to Danny's answer. I like keeping the Width of each column stored and then use that when executing the SetXY method.

    Example:

    $x = $this->x;
    $y = $this->y;
    $push_right = 0;
    
    $this->MultiCell($w = 100,3,"Column\r\nNumber 1",1,'C',1);
    
    $push_right += $w;
    $this->SetXY($x + $push_right, $y);
    
    $this->MultiCell($w = 60,3,"Column\r\nNumber 2",1,'C',1);
    
    $push_right += $w;
    $this->SetXY($x + $push_right, $y);
    
    $this->MultiCell(0,3,"Column 3\r\nFilling in the Rest",1,'C',1);
    

提交回复
热议问题