By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,919 Members | 1,047 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,919 IT Pros & Developers. It's quick & easy.

please help with this fpdf label printing

P: 1
Hi

I'm trying to write a label printing routine, but I'm not being too sucsessful. I'm hoping maybe someone who's used FPDF b4 can help me out?

Basically, I want to print labels from a data taken from a MySQL DB, but it doesn't output the labels properly. As soon as it gets to the bottom of the page, it kinda spans the bottom two labels across the two pages. How do I tell it to print the whole last label on the second page? I had a look at the docs, but can't seem to get anything that'll help me.

[PHP]
include_once("classes/fpdf.php");
define('FPDF_FONTPATH','classes/font/');




$pdf=new FPDF('P','mm',$_GET['paper_size']);
$pdf->SetDisplayMode(fullpage);

$pdf->AddPage();

$pdf->SetFont('Arial','B',12);
$pdf->SetAutoPageBreak('on');
$pdf->SetTopMargin(0);
$pdf->SetLeftMargin(0);



$a = $row['name'];
$b = "Expires: ".$row['expire'];
$c = "Take ".$row['dosage'];
$d = "No ".$no." / Pages ".$pages;
$e = $_GET['l_gap']." / ".$_GET['t_gap']." / ".$_GET['width']." / ".$_GET['height'];

$width =$_GET['l_gap'];
$height =$_GET['t_gap'];


for($i=1; $i<$_GET['label_quantity']; $i++) {
//$width = $width+$width+$_GET['v_gap'];
$height = $Ypos+$_GET['h_gap'];

//First Column
$pdf->SetXY($width,$height);
$pdf->MultiCell($_GET['width'], $_GET['height']/10 ,$pdf->GetX()." / ".$pdf->GetY(). " ".$a."\n".$b."\n".$c."\n".$d."\n".$e." #".$i , 1,'L');
$Ypos = $pdf->GetY();
//Second Column
//$pdf->SetXY($_GET['l_gap']+$_GET['width']+$_GET['v_gap'],$height);
//$pdf->MultiCell($_GET['width'], $_GET['height']/10 ,$pdf->GetX()." / ".$pdf->GetY(). " ".$a."\n".$b."\n".$c."\n".$d."\n".$e." #".$i , 1,'L');

}


$pdf->Output();[/PHP]

My other problem, which I don't know howto address yet, is how would I be able to print a few labels next to each other?

tia :)
Attached Files
File Type: pdf output_labels.pdf (3.9 KB, 1091 views)
Dec 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: 3
I think you can simply adjust the space between the labels. i.e. use $pdf->Ln(5);

[link removed]
Sep 13 '07 #2

P: 36
I actually just wrote a major application using this. Its very useful but also has a lot of short comings.
Since your data is not dynamically changing in lines you probably can just use the addPage() function from fpdf after the 8th item is printed. This class is not an easy one to use.
Sep 13 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.