Jump to content

printing pdf documment from mysql table


lional

Recommended Posts

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

 

?>

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.