clonmelog
asked on
fpdf layout
Hi,
Im struggling with the layout formate used for the fpdf class that im using wth php to generate receipts on the fly. basically the pdf content is going all over the place when i call the variables to the printed out and i cant figure out how exactly the layout manager works no matter how much i study the examples on fpdf.org.
an example of my current output is:
http://www.substanceabuseawareness.com/invoice.pdf
the code im using to generate this so far is:
<?php
include ('db.php');
require('fpdf.php');
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
if(isset($_POST["Submit"]) ) {
$sql = mysql_query("Select * From tracking Where C_Pass = '" . $_POST["trackingnum"] . "'") or die ("Sql error : " . mysql_error());
if( mysql_num_rows($sql) > 0 ) {
$row = mysql_fetch_array($sql);
$C_Pass = $row["C_Pass"];
$C_Fname = $row["C_Fname"];
$C_Surname = $row["C_Surname"];
$C_Street = $row["C_Street"];
$C_Street1 = $row["C_Street1"];
$C_Town = $row["C_Town"];
$C_City = $row["C_City"];
$C_Country = $row["C_Country"];
$p_id = $row["p_id"];
$invoicedate = date("l dS of F Y ");
$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Helvetica', 'U',16);
$pdf->Image('logo.jpg',80, 10,50);
$pdf->Ln(3);
$pdf->SetDrawColor(0,80,18 0);
$pdf->SetFillColor(230,230 ,0);
$pdf->Cell(80,10,'test');
$pdf->Ln(40);
$pdf->SetFont('Helvetica', '',12);
$pdf->Cell(70,10,'Bill to:');
$pdf->Ln(10);
$pdf->Cell(100,10, $C_Fname . " " . $C_Surname);
$pdf->Cell(10,10,'Referenc e No:');
$pdf->Cell(160,10,$C_Pass) ;
$pdf->Ln(10);
$pdf->Cell(70,10, $C_Street);
$pdf->Cell(80,10,'Invoice Date: ' . $invoicedate);
$pdf->Ln(6);
$pdf->Cell(70,10, $C_Street1);
$pdf->Ln(6);
$pdf->Cell(70,10, $C_Town);
$pdf->Ln(6);
$pdf->Cell(70,10, $C_City);
$pdf->Ln(6);
$pdf->Cell(70,10, $C_Country);
$pdf->Ln(20);
$pdf->Cell(70,10,'Goods Ordered:');
$pdf->Ln(6);
$pdf->Cell(70,10,'Invoice Total:');
$pdf->Ln(120);
$pdf->SetTextColor(254, 0, 0);
//$pdf->Cell(70,10,'www.substanceabuseawareness.com');
$pdf->Cell(500,10,'shoppin g@substanc ebuseaware ness.com', 'c');
$pdf->Output("invoice.pdf" ,true);
}
else {
echo "You Must Enter a tracking code to view details. Please go back and enter a valid code.";
}
}
?>
is there anyone that has used the class before that could help with fixing this layout problem?
thanks
Im struggling with the layout formate used for the fpdf class that im using wth php to generate receipts on the fly. basically the pdf content is going all over the place when i call the variables to the printed out and i cant figure out how exactly the layout manager works no matter how much i study the examples on fpdf.org.
an example of my current output is:
http://www.substanceabuseawareness.com/invoice.pdf
the code im using to generate this so far is:
<?php
include ('db.php');
require('fpdf.php');
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
if(isset($_POST["Submit"])
$sql = mysql_query("Select * From tracking Where C_Pass = '" . $_POST["trackingnum"] . "'") or die ("Sql error : " . mysql_error());
if( mysql_num_rows($sql) > 0 ) {
$row = mysql_fetch_array($sql);
$C_Pass = $row["C_Pass"];
$C_Fname = $row["C_Fname"];
$C_Surname = $row["C_Surname"];
$C_Street = $row["C_Street"];
$C_Street1 = $row["C_Street1"];
$C_Town = $row["C_Town"];
$C_City = $row["C_City"];
$C_Country = $row["C_Country"];
$p_id = $row["p_id"];
$invoicedate = date("l dS of F Y ");
$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Helvetica',
$pdf->Image('logo.jpg',80,
$pdf->Ln(3);
$pdf->SetDrawColor(0,80,18
$pdf->SetFillColor(230,230
$pdf->Cell(80,10,'test');
$pdf->Ln(40);
$pdf->SetFont('Helvetica',
$pdf->Cell(70,10,'Bill to:');
$pdf->Ln(10);
$pdf->Cell(100,10, $C_Fname . " " . $C_Surname);
$pdf->Cell(10,10,'Referenc
$pdf->Cell(160,10,$C_Pass)
$pdf->Ln(10);
$pdf->Cell(70,10, $C_Street);
$pdf->Cell(80,10,'Invoice Date: ' . $invoicedate);
$pdf->Ln(6);
$pdf->Cell(70,10, $C_Street1);
$pdf->Ln(6);
$pdf->Cell(70,10, $C_Town);
$pdf->Ln(6);
$pdf->Cell(70,10, $C_City);
$pdf->Ln(6);
$pdf->Cell(70,10, $C_Country);
$pdf->Ln(20);
$pdf->Cell(70,10,'Goods Ordered:');
$pdf->Ln(6);
$pdf->Cell(70,10,'Invoice Total:');
$pdf->Ln(120);
$pdf->SetTextColor(254, 0, 0);
//$pdf->Cell(70,10,'www.substanceabuseawareness.com');
$pdf->Cell(500,10,'shoppin
$pdf->Output("invoice.pdf"
}
else {
echo "You Must Enter a tracking code to view details. Please go back and enter a valid code.";
}
}
?>
is there anyone that has used the class before that could help with fixing this layout problem?
thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Alignment as in Left-aligned, centered/justified, right aligned? I have never tried that actually. But I suppose it should be possible.
-r-
-r-
ASKER
yeah just like in say HTML layout.
The points are yours but if you come up with anything please let me know ;)
The points are yours but if you come up with anything please let me know ;)
ASKER