2

I am using FPDF to generate a report, and i need to align the number on right taking the number on top(Year) by reference. But I am having a problem on this align.

If i use a function Cell like this:

$pdf->Cell(0,5,$alue,'B',1,'D');

All values stay on right Overlapping.

I tried to use a function SetX but did not changed anything.

how it is now

2 Answers2

1

Take a look at the documentation. It states that:

Cell width. If 0, the cell extends up to the right margin.

Since you're right-aligning your text and your Cell sits on the right margin of the page, it makes sense that it does not align properly.

Try specifying a width for your cell. For example, replace your example line of code with:

$pdf->Cell(50,5,$alue,'B',1,'D'); 
aphid
  • 1,135
  • 7
  • 20
0
<?php

//right align
$pdf->Cell(50, 5, $alue, 0, 0, 'R' ); 

//Left Align
$pdf->Cell(50, 5, $alue, 0, 0, 'L' ); 

//Center Align
$pdf->Cell(50, 5, $alue, 0, 0, 'C' ); 

?>
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
  • 1
    Please read [answer] and [edit] your answer to contain an explanation as to why this code would actually solve the problem at hand. Always remember that you're not only solving the problem, but are also educating the OP and any future readers of this post. – Adriaan Jan 30 '23 at 12:42