/**
  * Just render a single object to the output.
  * 
  * @param $object
  */
 private function renderSingleObject($object)
 {
     $dataReplacement = new Placeholder($object, "<<", ">>");
     $this->out .= $dataReplacement->apply($this->configuration['template']) . "\n";
 }
Ejemplo n.º 2
0
 /**
  * This method just renders the next single cell with a part
  * as content.
  */
 private function renderCell($object)
 {
     // Move the pointer to the next cell and initialize PDF class
     // correctly. Also draws the grid if necessary.
     $this->initNextCell();
     $padding = 3;
     $dataReplacement = new Placeholder($object, "!!", "!!");
     $text = $dataReplacement->apply($this->configuration['text']);
     $barcodeId = $dataReplacement->apply($this->configuration['textBarcode']);
     $this->pdf->SetCellPadding($padding);
     $this->pdf->SetFont($this->configuration['fontFamily'], $this->configuration['fontStyle'], $this->configuration['fontSize']);
     $this->pdf->SetXY($this->xCellPos, $this->yCellPos);
     if ($this->configuration['barcodeEnable']) {
         $widthParameter = new PercentOrNumericHelper($this->configuration['barcodeWidth']);
         $heightParameter = new PercentOrNumericHelper($this->configuration['barcodeHeight']);
         $xPosParameter = new PercentOrNumericHelper($this->configuration['barcodeXPos']);
         $yPosParameter = new PercentOrNumericHelper($this->configuration['barcodeYPos']);
         $xPos = $xPosParameter->getValueWrap(0, $this->layout->getCellWidthInMM());
         $yPos = $yPosParameter->getValueWrap(0, $this->layout->getCellHeightInMM());
         $width = $widthParameter->getValue(0, $this->layout->getCellWidthInMM());
         $height = $heightParameter->getValue(0, $this->layout->getCellHeightInMM());
         $regions = array();
         // Shitty workaround for a Bug in TCPDF the ower is not interested in fixing it!
         $this->pdf->resetInternalMargins();
         if ($this->configuration['barcode2D']) {
             $this->pdf->write2DBarcode($barcodeId, $this->configuration['barcodeType'], $this->xCellPos + $xPos - $width / 2, $this->yCellPos + $yPos - $height / 2, $width, $height);
         } else {
             $style = array('text' => $this->configuration['barcodeWithText']);
             $this->pdf->write1DBarcode($barcodeId, $this->configuration['barcodeType'], $this->xCellPos + $xPos - $width / 2, $this->yCellPos + $yPos - $height / 2, $width, $height, "", $style);
         }
         // This region will add a "do not write text here" over our barcode This is a kind
         // of hack to make text fluently moving around :)
         $textMarginX = 7;
         $textMarginY = 7;
         $left = $xPos < $this->layout->getCellWidthInMM() / 2;
         $top = $yPos < $this->layout->getCellHeightInMM() / 2;
         // $this->pdf->writeHTML("LEFT: $left TOP: $top XPOS: $xPos YPOS: $yPos WIDTH: ".$this->layout->getCellWidthInMM()." HEIGHT: ".$this->layout->getCellHeightInMM(), true, false, true, false, '');
         if ($left) {
             if ($top) {
                 $regions[] = array('page' => '', 'xt' => $xPos + $this->xCellPos + $textMarginX, 'yt' => 0, 'xb' => $xPos + $this->xCellPos + $textMarginX, 'yb' => $yPos + $this->yCellPos + $textMarginY, 'side' => 'L');
             } else {
                 $regions[] = array('page' => '', 'xt' => $xPos + $this->xCellPos + $textMarginX, 'yt' => $yPos + $this->yCellPos - $textMarginY, 'xb' => $xPos + $this->xCellPos + $textMarginX, 'yb' => $this->yCellPos + $this->layout->getCellHeightInMM(), 'side' => 'L');
             }
         } else {
             if ($top) {
                 $regions[] = array('page' => '', 'xt' => $xPos + $this->xCellPos - $textMarginX, 'yt' => 0, 'xb' => $xPos + $this->xCellPos - $textMarginX, 'yb' => $yPos + $this->yCellPos + $textMarginY, 'side' => 'R');
             } else {
                 $regions[] = array('page' => '', 'xt' => $xPos + $this->xCellPos - $width / 2 - $textMarginX, 'yt' => $yPos + $this->yCellPos - $height / 2 - $textMarginY, 'xb' => $xPos + $this->xCellPos - $width / 2 - $textMarginX, 'yb' => $this->yCellPos + $this->layout->getCellHeightInMM(), 'side' => 'R');
             }
         }
         $this->pdf->setPageRegions($regions);
     }
     // Start clipping. Every thing with StartTransform and StopTransform
     // will be clipped to the Rect. This is a cool feature if one field is
     // too long, it will not destroy the rest of your page and it is partial
     // usable.
     $this->pdf->StartTransform();
     // Draw clipping rectangle to match html cell.
     $this->pdf->Rect($this->xCellPos, $this->yCellPos, $this->layout->getCellWidthInMM(), $this->layout->getCellHeightInMM(), 'CNZ');
     $xPosTextOffsetParameter = new PercentOrNumericHelper($this->configuration['textXOffset']);
     $yPosTextOffsetParameter = new PercentOrNumericHelper($this->configuration['textYOffset']);
     $this->pdf->WriteHTMLCell($this->layout->getCellWidthInMM(), $this->layout->getCellHeightInMM(), $this->xCellPos + $xPosTextOffsetParameter->getValueUnbound($this->layout->getCellWidthInMM()), $this->yCellPos + $yPosTextOffsetParameter->getValueUnbound($this->layout->getCellWidthInMM()), $text);
     $this->pdf->StopTransform();
     $this->pdf->setPageRegions();
 }