Hey there. Ive been trying to generate a pdf file to create stickers (6180 - sticker pattern)
I managed to have 3 stickers per line with 10 lines per page giving a total of 30 stickers per page.
ex.
| 1 | 2 | 3 |
| 4 | 5 | 6 |
| 7 | 8 | 9 |
etc
Here comes the HUGE problem:
$a="valor1";
$b="Valor2";
$pdf->Cell(70.3, 26.5, $a , 1, 0, 'C');
I´d like to have in this cell 5 itens, one bellow the other (at the moment there are only one - $a)
I´ve tryied to use <br> ($a."<br>".$b) but $b did not go under $a, instead the pdf generated something
like this: "valor1<br>valor2"
It doesnt work with $pdf->Ln(); because it will just jump a line AFTER the whole cell´s been generated.
I´d like to improve itens 1 and 2 commented in the code:
// ITEN 1 - WHAT I´D LIKE TO DO
// ITEN 2 - IMPROVE: There must be a better way to have a break after 3 cell´s been generated
How can I do that ???
I´ve been using fpdf: URL: fdpf
Bellow is my code.
<?
//DB MYSQL
$server = "localhost";
$user = "root";
$pass = "";
$bd = "pdf";
//TITLE
$tit = "STICKERS";
//FPDF LIBRARY
$end_fpdf = "../fpdf";
//NUMBER OF RESULTS PER PAGE
$per_page = 30;
//WHERE PDF WILL BE SAVED
$end_final = "gera.pdf";
//F-> TO SAVE THE PDF
$tipo_pdf = "F";
//CONECTION
$conn = mysql_connect($server, $user, $pass);
$db = mysql_select_db($bd, $conn);
$sql = mysql_query("SELECT A.ID, A.NOME, A.ASSUNTO FROM colunistas A", $conn);
$row = mysql_num_rows($sql);
//SEE IF THERE IS ANY RECORD
if(!$row) { echo "There are no records"; die; }
//CALCULATES HOW MANY PAGES WILL BE NECESSARY
$pages = ceil($row/$per_page);
//PDF
define("FPDF_FONTPATH", "$end_fpdf/font/");
require_once("$end_fpdf/fpdf.php");
$pdf = new FPDF('P','mm','Letter');
$pdf->SetTopMargin(7.1);
$pdf->SetLeftMargin(0);
$pdf->SetRightMargin(0);
//START VARS
$actual_line = 0;
$beginning = 0;
//PAGES
for($x=1; $x<=$pages; $x++) {
//VERIFY
$beginning = $actual_line;
$end = $actual_line + $per_page;
if($end > $row) $end = $row;
$pdf->Open();
$pdf->AddPage();
$pdf->SetFont("Arial", "B", 10);
//SHOW RECORDS
for($i=$beginning; $i<$end; $i++) {
//* ITEN 1 - WHAT I´D LIKE TO DO
//$a =mysql_result($sql, $i, "ID") ;
$a="Valor1"; $b="Valor2";
$pdf->Cell(70.3, 26.5, ($i+1)." ".$a."<br>".$b , 1, 0, 'C');
//* ITEN 2 - IMPROVE: There must be a better way to have a break after 3 cell´s been generated
$ia=$i;
$id=$ia+3;
if( $ia==2 || $ia==5 || $ia==8 || $ia==11 || $ia==14 || $ia==17 || $ia==20 || $ia==23 || $ia==26 || $ia==29 ||
$ia==35 || $ia==38 || $ia==41 || $ia==44 || $ia==47 || $ia==50 || $ia==53 || $ia==56 || $ia==59 ||
$ia==65 || $ia==68 || $ia==71 || $ia==74 || $ia==77 || $ia==80 || $ia==83 || $ia==86 || $ia==89 ||
$ia==95 || $ia==98 || $ia==101 || $ia==104 || $ia==107 || $ia==110 || $ia==113 || $ia==116 || $ia==119 ||
$ia==125 || $ia==128 || $ia==131 || $ia==134 || $ia==137 || $ia==140 || $ia==143 || $ia==146 || $ia==149 ||
$ia==155 || $ia==158 || $ia==161 || $ia==164 || $ia==167 || $ia==170 || $ia==173 || $ia==176 || $ia==179
){
$pdf->ln();
}
//ITEN 2 ENDS
$actual_line++;
$pdf->SetAutoPageBreak('on','0.2');
}//END FOR(RECORDS - i)
}//END FOR(pages - x)
//PDF OUTPUT
$pdf->Output("$end_final", "$tipo_pdf");
?>
See the generated pdf attached to understand it better.
GERA.PDF
Help me pleaseeeee. I´ve been looking for that for days but it seems that it doenst exist !
Thanks so much.
Roger.