FPDF Layout problems

Hi all,

I have the following code which creates a pdf with the fpdf class found at fpdf.org. All works well but i am having a few problems with the layout.

Here is my code:


include 'db.php';


$sql = mysql_query("Select * From users Where userid = '$userid'") or die ("Sql error : " . mysql_error());

if( mysql_num_rows($sql) > 0 ) {

$sql1= mysql_query("SELECT * FROM tblOrder WHERE orderid='$orderid'") or die ("Sql error : " . mysql_error());
$row1= mysql_fetch_array($sql1);
$row = mysql_fetch_array($sql);

$Start = $row1["order_date"];
$Finish = $row1["renew_date"];
$Price = $row1["price"];
$P_method = $row1["p_method"];
$C_Fname = $row["C_Fname"];
$C_Fname = $row["C_Domain"];
$C_Surname = $row["C_Surname"];
$C_Street1 = $row["C_Street1"];
$C_Street2 = $row["C_Street2"];
$C_Town = $row["C_Town"];
$C_City = $row["C_City"];
$C_Country = $row["C_Country"];
$p_id = $row["p_id"];

$pdf=new FPDF();

$pdf->Cell(500,80,'Your Invoice');

$pdf->Cell(70,10,'Bill to:');
$pdf->Cell(70,10, $C_Fname . " " . $C_Surname);
$pdf->Cell(70,10,'Billing Address:');
$pdf->Cell(70,10, $C_Street);
$pdf->Cell(70,10, $C_Street1);
$pdf->Cell(70,10, $C_Town);
$pdf->Cell(70,10, $C_City);
$pdf->Cell(70,10, $C_Country);
$pdf->Cell(70,10,'Hosting Ordered:');
$pdf->Cell(70,10,'Plan Ordered:' . $p_id);
$pdf->Cell(70,10,'Subdomain:' . $C_Domain);
$pdf->Cell(70,10,'Start Date:' . $Start);
$pdf->Cell(70,10,'Rewenal Date:' . $Finish);
$pdf->Cell(70,10,'Payment Method:' . $P_method);
$pdf->Cell(70,10,'Total Price:' . $Price);

$pdf->SetTextColor(255, 165, 0);

else {
  echo "No result for the query, PDF not generated";

function redirect($url) {
    echo '<script language="JavaScript">
    document.location.href="' . $url . '"
    echo "If you do not get redirected <a href=\"" . $url . "\">click here</a>.";

For some reason the Invoice wording appears in the same cell block as my logo? Also i would like to include colours similar to the tutorial found at http://www.fpdf.org/en/tutorial/tuto3.htm

I particulary like the Chapter 1: A Runaway Reef layout part.

However i'm unable to understand the way they are using their code to implement it at all.

Does anyone know how i could fix up my pdf so i have:


Your Invoice -> like the the Chapter 1 example at fpdf.org

The rest of my output seems to be ok, just the above im having trouble with.

Any help is much appreciated

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

It's been a while ago when I last used this class, but as far as I remember, pictures were not actually being put into a cell. If you want to position the text underneath the picture, you need first to position to that point. So try putting a $pdf->Ln(20); after you insert the picture.

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
act1veAuthor Commented:
thanks that worked, got my text onto the next line, think im getting the hang of this, cheers!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.