lional Posted November 14, 2007 Share Posted November 14, 2007 Hi All I am trying to print a catalogue from a mysql table. I want it to print 6 products per page and then automaticcaly do the next page, until it is completed is this possible The first bit of code is the code to print the catelog, and the second is the include file that it uses Thanks Lional <?php ob_start(); $catid_out = $_GET['catid']; include 'includes/conn_db.php'; require 'PDF.php'; $filename = 'foo.pdf'; $fullpath = "scotland_documents/".$filename; $pdf = &PDF::factory('l', 'a4'); // Set up the pdf object. $pdf->open(); // Start the document. $pdf->setCompression(true); // Activate compression. $now_out = date('d/m/Y'); $query_ex = "SELECT * from categories WHERE cat_id = '$catid_out'"; $result_ex = mysql_query($query_ex, $conn); while ($row_ex = mysql_fetch_assoc($result_ex)){ $category_out = $row_ex["category"]; } $pdf->addPage(); // Start a page. $pdf->setFont('Arial', '', 16); // Set font to courier 8 pt. $pdf->text(100, 25, "Catalogue for $category_out as at $now_out"); // Text at x=100 and y=100. $y_no = 35; $dim1_out = 45; $dim2_out = 55; $dim3_out = 65; $dim4_out = 75; $spec1_out = 45; $spec2_out = 55; $spec3_out = 65; $count=1; $query4 = "SELECT * from products WHERE cat_id = '$catid_out'"; // display the products in each subcat $result4 = mysql_query($query4, $conn); while ($row4 = mysql_fetch_assoc($result4)){ $prodid_out = $row4["prod_id"]; $prodcode_out = $row4["prod_code"]; $prodname_out = $row4["prod_name"]; $thumb_out = $row4["thumb"]; $width_out = $row4["width"]; $height_out = $row4["height"]; $cp_out = $row4["cp"]; $diameter_out = $row4["diameter"]; $price_out = $row4["price"]; $pdf->image("images/products/thumbs/$thumb_out", 100, "$y_no", 100, 100); // Text at x=100 and y=100. $pdf->setFont('Arial', '', 12); $pdf->text(220, "$y_spec", "Dimensions"); // Text at x=100 and y=100. $pdf->text(220, "$dim1_out", "Width - $width_out"); // Text at x=100 and y=100. $pdf->text(220, "$dim2_out", "Height - $height_out"); // Text at x=100 and y=100. $pdf->text(220, "$dim3_out", "Centre Point - $cp_out"); // Text at x=100 and y=100. $pdf->text(220, "$dim4_out", "Diameter - $diameter_out"); // Text at x=100 and y=100. $pdf->text(340, "$y_spec", "Finishes"); // Text at x=100 and y=100. $pdf->text(340, "$spec1_out", "Antique Black"); // Text at x=100 and y=100. $pdf->text(340, "$spec2_out", "Antique Bronze"); // Text at x=100 and y=100. $pdf->text(340, "$spec3_out", "Antique Silver"); // Text at x=100 and y=100. $pdf->text(460, "$y_spec", "R $price_out"); // Text at x=100 and y=100. $y_no = $y_no + 120; $y_spec = $y_no + 10; $dim1_out =$y_spec + 10; $dim2_out =$dim1_out + 10; $dim3_out =$dim2_out + 10; $dim4_out =$dim3_out + 10; $spec1_out =$y_spec + 10; $spec2_out =$spec1_out + 10; $spec3_out =$spec2_out + 10; } $pdf->output($fullpath); // Output the file named foo.pdf ?> Quote Link to comment Share on other sites More sharing options...
aschk Posted November 14, 2007 Share Posted November 14, 2007 So what's the problem? Quote Link to comment Share on other sites More sharing options...
lional Posted November 14, 2007 Author Share Posted November 14, 2007 It does not write to the next page. I have about 60 products in the category, put it stops at page 1, and only outputs 6 products. I need to tell it that it must print 6 products per page, and then start a new page Quote Link to comment Share on other sites More sharing options...
jpratt Posted November 14, 2007 Share Posted November 14, 2007 all pdf classes ive worked with make you call the newpage method for each new page to be created. This only has it called once outside of your loop so it should only create one page. Quote Link to comment Share on other sites More sharing options...
lional Posted November 14, 2007 Author Share Posted November 14, 2007 When I put the new page in my loop it says the font has not been set in acrobat reader Quote Link to comment Share on other sites More sharing options...
lional Posted November 15, 2007 Author Share Posted November 15, 2007 I have a product list with about 800 products. I want to pull the info from the database in categories which would end up at about 60 products. I want to put 6 products per page. I want this in pdf. I get to pull the products but I do not know how to create miltiple pages Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.