在PHP中使用FPDF将两个MultiCell彼此相邻放置 [英] Placing two MultiCells next to each other using FPDF in PHP

查看:350
本文介绍了在PHP中使用FPDF将两个MultiCell彼此相邻放置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

问题:无论我对下一个单元格做什么,它始终位于页面的下一行,而不是紧挨着第一个单元格-这使我发疯. /p>

这是我的代码:

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);

添加下一个多单元格,并根据需要重复.

I trying to create a custom table using FPDF Cell/MultiCell.

My 1st cell is a MultiCell that has two lines of text. The next cell should then just be placed right next to it.

Problem : no matter what I do to the next cell, it is always on the next line of the page instead of being placed right next to the 1st cell - and it's driving me crazy.

Here is my code:

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();

The cell containing the text "DA190" should be placed next to the previous cell, but is being positioned underneath the previous cell.

解决方案

Before printing your first multicell, record the cursor position:

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

add your multicell using $this->Multicell($w,5,'Content');

Reset the cursor position to the start height (y) and the start horizontal + the width of the 1st multicell:

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

Add your next multicell and repeat as necessary.

这篇关于在PHP中使用FPDF将两个MultiCell彼此相邻放置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆