Need help positioning fpdf
P粉619896145
P粉619896145 2023-09-09 17:54:44
0
1
656

I am new to fpdf cell and multicell and need help with my code. Below is the code I wrote:

$pdf->Cell(60, 6, 'MAILING ADDRESS', 'L,R', 0);
$pdf->Multicell(65, 5, $puchaser1[0]["address"], 1);
$pdf->Cell(60, 11, $puchaser2[0]["address"], 1);

$pdf->Cell(60, 8, 'PHONE NUMBER', 1, 0);
$pdf->Cell(65, 8, $puchaser1[0]["contact_no"], 1, 0);
$pdf->Cell(65, 8, $puchaser2[0]["contact_no"], 1, 1);

I want it to look like this:

P粉619896145
P粉619896145

reply all(1)
P粉752826008

I strongly recommend using more variables. Your code might look like this:

// Height is different in multicell, this stands for lineheight and should be the same as other cells :)
// I would advise you to go for, SMALL_CELL and BIG_CELL if you want to differentiate
$WIDTH_CELL = 60;
$HEIGHT_CELL = 5;

// Most of the time, you want to border all so let's put this in a variable as well 
// Not in your case though, but more on that below this :)
$BORDER = 1;

$pdf->Cell($WIDTH_CELL, $HEIGHT_CELL, 'MAILING ADDRESS', $border, 0);
$pdf->Multicell($WIDTH_CELL, $HEIGHT_CELL, $puchaser1[0]["address"], $border);
$pdf->Cell($WIDTH_CELL, $HEIGHT_CELL, $puchaser2[0]["address"], $border);

$pdf->Cell($WIDTH_CELL, $HEIGHT_CELL, 'PHONE NUMBER', 1, 0);
$pdf->Cell($WIDTH_CELL, $HEIGHT_CELL, $puchaser1[0]["contact_no"], $border, 0);
$pdf->Cell($WIDTH_CELL, $HEIGHT_CELL, $puchaser2[0]["contact_no"], $border, 1);

However, this cannot solve your problem. You're going to have a bad time because you need:

  1. Track your starting Y
  2. Save Y value after adding multiple cells
  3. Use these two values ​​to draw a rectangle for the entire row

All other borders should be specifically "L", "R", or "LR". You have to draw the top border, bottom (sometimes L or R) border with a rectangle.

There is a lot of code, so if you have such code, I will help you further :)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template