How to use Zend-Framework-PDF-Table-Helper
Here is the example of how to user ZendFramework PDF-Table-Helper.
You can get the code from GitHub here:
One of the prerequisites is that you mast have the zf_autoloader on and configured since I am relaying on it to auto load files.
first you have to in instantiate the class:
$pdf = new SirShurf_Pdf_TableSet ();
You can instantiate it with a Zend_PDF object and without it, in which case it will be created for you, but if you are instantating with Zend_PDF you have to tell the system on what page you are working (Default is page 0).
Now what you need it to initialise a Table you are going to work with:
$objTableRow = $table->addRow ();
Each table can have his own number of columns and settings.
Each table can have a different number of rows a row can be added using this method:
And as with HTML a row has a number of cells (or columns):
$objTableRow->addCol ( $strCourseId, array (
'bold' => false, 'colspan' => 1, 'align' => 'center'
) );
$objTableRow->addCol ( Labadmin_Models_Static::convertHebrew ( $this->view->translate ( 'LBL_GRADE_FORM_COURSE_ID' ) ), array (
'bold' => false, 'colspan' => 1, 'align' => 'center', 'font' => 'arial.ttf', 'fontBold' => 'arialbd.ttf'
) );
The Cell can have each own definitions as the example here shows, and you can iterate over the data to create it.
And finally you can call render(); in order to render the changes to PDF, or build(‘fileName’) to save the finale PDF to a file.
$pdf->build ( $strGradeFileLocation . $intTimeStamp . ".grade.pdf" );
Hi Alex,
Can you please give us complete example on how to use this pdf table helper ?
Thanks and Regards
Durgaprasad
Durgaprasad Budhwani
August 21, 2011 at 10:30 am
I will create a more complete example for it.
Alex (Shurf) Frenkel
August 22, 2011 at 7:22 pm
Hi, where can I find your example please? Thanks for your great work.
Johnny
October 20, 2011 at 12:03 pm
What type of the example are you looking for? I can create one, it’s just that I think that the one I did was self explanatory…
Can you tell me what do you need me to do an example of?
Alex (Shurf) Frenkel
October 20, 2011 at 8:25 pm
Maybe I can help someone
example:
$pdf = new SirShurf_Pdf_TableSet();
$table = $pdf->addTable();
$objTableRow = $table->addRow();
$objTableRow->addCol( ‘test1’ , array (‘font’ => ‘arial.ttf’,’size’=>10) );
$objTableRow->addCol( ‘text2’ , array (‘font’ => ‘arial.ttf’,’size’=>10) );
$filename = “export.pdf”;
header(‘Content-type: application/pdf’);
header(“Content-Disposition: attachment; filename=$filename”);
Daniel Meyer
January 17, 2012 at 1:46 pm
I forgot do add this at last:
echo $pdf->render()->render();
Daniel Meyer
January 17, 2012 at 1:48 pm
Thanks Daniel
I actually dont have the time to make a proper example for it.
Alex (Shurf) Frenkel
January 17, 2012 at 4:46 pm
What other file formats we can use rather than Pdf ?
Zend Framework
March 1, 2012 at 3:05 pm
Since this is a PDF table so only PDF 🙂
I dont know what other plugins there should be.
Alex (Shurf) Frenkel
March 2, 2012 at 8:21 am
hello,
how to add border to table?
Thank you
Jekin
December 25, 2012 at 8:29 am