Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Isnīt That Possible To Do?!!!! Pdf
Old 03-09-2005, 09:15 AM Isnīt That Possible To Do?!!!! Pdf
Novice Talker

Posts: 8
Trades: 0
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:
Code:
$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.


PHP 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.326.5, ($i+1)."  ".$a."<br>".$b 10'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.
Attached Files
File Type: pdf gera.pdf (1.7 KB, 6 views)
rogernem is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-09-2005, 01:02 PM
0beron's Avatar
Defies a Status

Posts: 1,832
Location: Somewhere else entirely
Trades: 0
I'm not familiar with fpdf, but have a couple ideas:

You won't be able to use <br> - this is not HTML anymore but postscript.

You mention using $pdf->Ln() to add line breaks, but I'm guessing you are calling this outside of the Cell() method? You will need to find the Cell() method of that class somewhere in the code of fpdf and put your line breaks in there.

For the other part, you can replace the whole thing with

if( (($ia-2) % 3) == 0) {

and that will have the same effect presuming they are all 3 apart.
__________________
UPDATE 0beron SET talkupation = talkupation + lots WHERE post = 'helpful';

Please login or register to view this content. Registration is FREE
(aka MSN handwriting for forums)

Last edited by 0beron; 03-09-2005 at 01:04 PM..
0beron is offline
Reply With Quote
View Public Profile Visit 0beron's homepage!
 
Old 03-15-2005, 02:49 PM
Novice Talker

Posts: 8
Trades: 0
i will try that...thank you
rogernem is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Isnīt That Possible To Do?!!!! Pdf
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.62812 seconds with 13 queries