Help with class ezpdf

I’m trying to output mysql data to a pdf using ezpdf. http://www.ros.co.nz/pdf/ I have successfully generated the first part of my report but the second part a lot of columns and of course won’t across the page. The diagram below will probably explain what I’m trying to do.

Example of the current layout:

|—HEADER—|—HEADER2—|—HEADER3—|—HEADER4—|—HEADER5—|
| USERNAME1 | DATAFIELD1 | DATAFIELD2 | DATAFIELD3 | DATAFIELD3 |
| USERNAME2 | DATAFIELD1 | DATAFIELD2 | DATAFIELD3 |DATAFIELD3|
| USERNAME3 | DATAFIELD1 | DATAFIELD2 | DATAFIELD3 |DATAFIELD3|

Example of what I’m trying to accomplish:

|----HEADER1—|—HEADER2—|
| USERNAME1 | DATAFIELD1 |
|—HEADER3—|—HEADER4—|—HEADER5—|
| DATAFIELD2 | DATAFIELD3 | DATAFIELD4 |

|----HEADER1—|—HEADER2—|
| USERNAME2 | DATAFIELD1 |
|—HEADER3—|—HEADER4—|—HEADER5—|
| DATAFIELD2 | DATAFIELD3 | DATAFIELD4 |

|----HEADER1—|—HEADER2—|
| USERNAME3 | DATAFIELD1 |
|—HEADER3—|—HEADER4—|—HEADER5—|
| DATAFIELD2 | DATAFIELD3 | DATAFIELD4 |

If any one can help it would be very much appreciated.

Below is my test code

[code]<?php
//http://sourceforge.net/projects/pdf-php/forums/forum/147987/topic/666093
$con = mysql_connect(“localhost”,“root”,“password”);
if (!$con)
{
die('Could not connect: ’ . mysql_error());
}

mysql_select_db(“dbname”, $con);
error_reporting(E_ALL);

include (’…/pdf-php/class.ezpdf.php’);

$pdf =& new Cezpdf(‘LETTER’,‘landscape’);
$pdf->selectFont(’…/pdf-php/fonts/Helvetica.afm’);

//Margins (TOP,BOTTOM,LEFT,RIGHT)
$pdf->ezSetCmMargins(2,1,1,1);
$pdf->addText(105,595,8,“TEXT”);

$data = array();
// do the SQL query
$query = “SELECT username, lastname, firstname, Overall, Lodging_Ease AS Lod_Ease, Lodging_Quality AS Lod_Qty, Web_Info, Registration AS Reg, Facilities AS Fac, Non_Academic AS Non_Aca, IT_Support AS IT, Instructors AS Instr, Course_Content AS Cont, Sequence AS Seq, Book_Handouts AS Books, PE FROM student_evaluation_results WHERE course = ‘course-A’”;
$result = mysql_query($query);
$total = mysql_num_rows($result);
$pdf->addText(105,585,8,"Evaluation ratings for course ". $test. “”);
$pdf->addText(580,585,8,“Processed on: “. “”.date(“m/d/Y”));
// step through the result set, populating the array, note that this could also have been written:
// while($data[] = mysql_fetch_assoc($result)) {}
while($data[] = mysql_fetch_array($result, MYSQL_ASSOC)) {}
// make the table
$pdf->addText(580,595,8,“Total records: “. $total. “”);
$options = array(‘fontSize’=>8 );
$title = ‘YOUR TITLE HERE’;
$pdf->ezTable(&$data, $title, ‘’, $options);
// do the output, this is my standard testing output code, adding ?d=1
// to the url puts the pdf code to the screen in raw form, good for checking
// for parse errors before you actually try to generate the pdf file.
if (isset($d) && $d){
$pdfcode = $pdf->output(1);
$pdfcode = str_replace(”\n”,”\n
”,htmlspecialchars($pdfcode));
echo ‘’;
echo trim($pdfcode);
echo ‘’;
} else {
$pdf->stream();
}
?>[/code]

Sponsor our Newsletter | Privacy Policy | Terms of Service