Leonardo Nori
Leonardo Nori

Reputation: 21

FPDF align values on right

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

Upvotes: 2

Views: 2324

Answers (2)

PRAISE OKOROUDOH
PRAISE OKOROUDOH

Reputation: 11

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

?>

Upvotes: 0

aphid
aphid

Reputation: 1163

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

Upvotes: 1

Related Questions