在PHP中使用FPDF将两个MultiCell并排放置


Placing two MultiCells next to each other using FPDF in PHP

我试图使用FPDF Cell/MultiCell创建自定义表。

我的第一个单元格是一个有两行文本的MultiCell。然后,下一个单元格应该放在它旁边。

问题:无论我对下一个单元格做什么,它总是在页面的下一行,而不是放在第一个单元格旁边 - 这让我发疯。

这是我的代码:

require_once 'config.php';
require 'fpdf.php';
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','',10);
$pdf->MultiCell(150,10,'Certificate of foreign Currency usage in respect of materials and components in terms of the notes to rebate item ',1);
$pdf->SetFont('Arial','',10);
$pdf->MultiCell(40,10,'DA190',1);
$pdf->Output();

包含文本"DA190"的单元格应放置在上一个单元格旁边,但位于前一个单元格的下方。

在打印第一个多单元格之前,请记录光标位置:

$x=$this->GetX();
$y=$this->GetY();

使用$this->Multicell($w,5,'Content');添加多单元格

将光标位置重置为起始高度 (y) 和起始水平 + 第一个多单元格的宽度:

$this->SetXY($x+$w,$y);

添加下一个多单元格,并根据需要重复此操作。

这对

我有用

$pdf->multicell(120, 5, '   ' . $actividad, 0, 'l', true);
$x = $pdf->GetX();
$y = $pdf->GetY();
$pdf->SetXY($x + 120, $y);
$pdf->Cell(70, -5, '   ' . $claseActividad, '', 0, 'l', true);

结果

我找到了解决方案 - fpdf 有一个扩展 专注于使用多单元格。