/* Create the first page */ $ypos = newpage(false); /* Create a text object which will contain the weekday name */ $day = new jh_pdf_text_jhpci(&$pdf); $day->setalignment("center"); /* Create a barcode object which will contain some number */ $barcode = new jh_pdf_barcode_jhpci(&$pdf); $barcode->settype('25i'); $barcode->setheight(20); /* Create a text object which will contain the same number as the barcode, but this time as plain text */ $bctext = new jh_pdf_text_jhpci(&$pdf); $bctext->setalignment("center"); /* Create a container object and put in the three objects created above and some empty space between them */ $content = new jh_pdf_container_jhpci(&$pdf); $content->addobject($day); $content->addemptyspace(3); $content->addobject($barcode); $content->addemptyspace(3); $content->addobject($bctext); /* Make an instance of the table class */ $table = new jh_pdf_table(&$pdf, &$ypos, 30, 565, 30); /* Set a function that will be called if a new page is necessary */ $table->setnewpagefunction(newpage); /* Define the columns; note that all the columns have "*" as their width which means that the whole table width will be divided up and assigned equally to the columns */ $col1 =& $table->addcolumn("", "*", false, $content); $col2 =& $table->addcolumn("", "*", false, $content); $col3 =& $table->addcolumn("", "*", false, $content);
function renderHeaderBand($bandparams) { if (array_key_exists('grid', $bandparams)) { $grid = $bandparams['grid']; } else { $grid = $this->phpgrid; } $headerstyle = 'reportheader'; if ($this->issubreport) { $headerstyle = 'subreportheader'; } $grid->getlookupquery(); $what = $grid->statustext; if ($this->outputformat == HTML) { if ($what != '') { $cs = count($grid->printable); echo "<tr><td colspan=\"{$cs}\"><b>{$what}</b></td></tr>\n"; } echo "<tr class=\"{$headerstyle}\">"; } reset($grid->printable); while (list($k, $v) = each($grid->printable)) { $column = $grid->getLabel($k); if ($this->outputformat == HTML) { echo "<td>{$column}</td>"; } if ($this->outputformat == PDF) { $column = strip_tags($column); $colh = new jh_pdf_text_jhpci(&$this->pdf); if (array_key_exists($k, $this->coltypes)) { $colr = new jh_pdf_container_jhpci(&$this->pdf); $barcode = new jh_pdf_barcode_jhpci(&$this->pdf); $barcode->settype('128a'); /* Adjust the height of the barcode */ $barcode->setheight(20); $bctext = new jh_pdf_text_jhpci(&$this->pdf); $bctext->setalignment("center"); $colr->addobject($barcode); $colr->addemptyspace(3); $bctext->setfontsize($this->pdffontsize); $colr->addobject($bctext); } else { $colr = new jh_pdf_text_jhpci(&$this->pdf); $colr->setfontsize($this->pdffontsize); } $colh->setfontsize($this->pdffontsize); $colh->setfontcolor(1); if (array_key_exists($k, $this->pdfwidths)) { $w = $this->pdfwidths[$k]; } else { $w = '*'; } $col =& $this->table->addcolumn($column, $w, $colh, $colr); } } if ($this->outputformat == HTML) { echo "</tr>"; } }
$ypos = newpage(false); /* Create instances of JHPCI conformant classes for the header and the rows of every column */ $col1h = new jh_pdf_text_jhpci(&$pdf); $col1r = new jh_pdf_text_jhpci(&$pdf); $col2h = new jh_pdf_text_jhpci(&$pdf); $col2r = new jh_pdf_text_jhpci(&$pdf); $col3h = new jh_pdf_text_jhpci(&$pdf); $col3r = new jh_pdf_text_jhpci(&$pdf); /* Note that the 4th column is a barcode column; the header should have the text "Barcode" in it, so it's a instance of jh_pdf_text_jhpci just like the other columns; however, the rows should show a barcode; this is done by just using another class, the rest is the same as with the other columns! */ $col4h = new jh_pdf_text_jhpci(&$pdf); $col4r = new jh_pdf_container_jhpci(&$pdf); $col4r->addobject($barcode); $col4r->addemptyspace(3); $col4r->addobject($bctext); /* Use Courier for the rows in the 2nd and 3rd column and make the content right-aligned */ $col2r->setfontface("Courier"); $col2r->setalignment("right"); $col2h->setalignment("right"); $col3r->setfontface("Courier"); $col3r->setalignment("right"); $col3h->setalignment("right"); /* Make an instance of the table class */ $table = new jh_pdf_table(&$pdf, &$ypos, 30, 812, 30); /* Set a function that will be called if a new page is necessary */ $table->setnewpagefunction(newpage);