Example #1
0
 public function generate(Page $page, Template $template, $records, $label = 0)
 {
     $pdf = new TagliatelleFpdf('P', 'mm', 'A4');
     $pdf->AddPage();
     $pdf->SetFont('Arial', 'B', 16);
     $pdf->SetMargins(0, 0, 0, 0);
     $pdf->SetAutoPageBreak(false);
     foreach ($records as $record) {
         //echo $page->getLabelColumn($label) . '-' . $page->getLabelRow($label) . ' ';
         //echo $page->getLabelX($label) . '-' . $page->getLabelY($label) . "\n";
         $pdf->Rect($page->getLabelX($label), $page->getLabelY($label), $page->getLabelWidth(), $page->getLabelHeight());
         foreach ($template->getBlocks() as $block) {
             $reflect = new \ReflectionClass($block);
             $methodName = 'render' . $reflect->getShortName();
             $this->{$methodName}($block, $page, $pdf, $label, $record);
         }
         $label++;
         if ($label >= $page->getLabels()) {
             $pdf->AddPage();
             $label = 0;
         }
     }
     return $pdf->Output(null, 'S');
 }