Jump to content

tcpdf problem


lional

Recommended Posts

Hi All

 

I am using the tcpdf script from www.tecnick.com

 

I have one small problem. I am trying to create a online pdf catalog if the following format:

 

Image then a list of the finishes, then a list of the dimensions, then the price, but it formats it with the image, then below the image, the list of finishes, then below that the dimensions, and below that the price. I would like them to all be along side each other. I have attached my script, please let me know if there is anyone that can help me.

 

 

<?php
  ob_start();
$catid_out = $_GET['catid'];
include 'includes/conn_db.php';
$doc_title = "test title";
$doc_subject = "test description";
$doc_keywords = "test keywords";
require_once('config/lang/eng.php');
require_once('tcpdf.php');
// require_once('DBQueryClass.inc.php');
//create new PDF document (document units are set by default to millimeters)
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true); 
// set document information
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor(PDF_AUTHOR);
$pdf->SetTitle($doc_title);
$pdf->SetSubject($doc_subject);
$pdf->SetKeywords($doc_keywords);
//set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
//set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
//$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); //set image scale factor
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->setLanguageArray($l); //set language items
//initialize document
$pdf->AliasNbPages();
  $query4 = "SELECT * from Products WHERE cat_id = '$catid_out' AND active='1'";
$result4 = mysql_query($query4, $conn);
  $productCount = 0;
	while ($row4 = mysql_fetch_assoc($result4)){

	if(($productCount % 5) == 0)
	{
		$pdf->AddPage();

	}
	$productItem = "<table align=\"left\"><tr><td>";
    $thumbLocation = "images/products/thumbs/" . $row4['thumb'];
    $productItem .= "<img src=\"$thumbLocation\" align=\"left\">";
    $productItem .= "</td><td>";
    $productItem .= $row4['prod_code'];
    $productItem .= "<br>";
	$productItem .= "<b>Finishes</b><br>Antique Black<br>Antique Bronze<br>Antique Silver";
    $productItem .= "<br>";
    if ($row4['width'] != 0 || $row4['width'] != "" || $row4['height'] != 0 || $row4['height'] != "" || $row4['cp'] != 0 || $row4['cp'] != "" || $row4['diameter'] != 0 || $row4['diameter'] != "") {
    $productItem .= "<b>Dimensions</b>";
    $productItem .= "<br>";
    }
    if ($row4['width'] != 0 || $row4['width'] != "") {
    $productItem .= "Width - ";
    $productItem .= $row4['width'];
    $productItem .= "<br>";
    }
    if ($row4['height'] != 0 || $row4['height'] != "") {
    $productItem .= "Height - ";
    $productItem .= $row4['height'];
    $productItem .= "<br>";
    }
    if ($row4['cp'] != 0 || $row4['cp'] != "") {
    if ($row4['cp'] == 'cp') {
    $cp_out = 'Centre Pin';
    } else {
    $cp_out = $row4['cp'];
    }
    $productItem .= "Pin to Pin - ";
    $productItem .= $$cp_out;
    $productItem .= "<br>";
    }
    if ($row4['diameter'] != 0 || $row4['diameter'] != "") {
    $productItem .= "Diameter - ";
    $productItem .= $row4['diameter'];
    $productItem .= "<br>";
    }
	$productItem .= "</td>";
    $productItem .= "Price R " . $row4['price'];
    $productItem .= "<td>";
    $productItem .= "</tr></table>";
	ob_start();
	$pdf->writeHTML($productItem, true, 0);
	$productCount++;
}//Close and output PDF document
$pdf->Output();
?>

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.