コード例 #1
0
 /**
  * @param $strContent
  * @param int $intHeight
  * @return string
  * @throws \Exception
  */
 public static function generate($strContent, $intHeight = 35)
 {
     // Handle height
     if (!is_numeric($intHeight)) {
         $intHeight = 35;
     }
     $strPath = 'barcode/cache';
     $strAbsolutePath = \System::getContainer()->get('kernel')->getRootDir() . '/../web/' . $strPath . '/';
     $objBarcode = new Base1DBarcode();
     $objBarcode->savePath = $strAbsolutePath;
     $strAbsoluteFilePath = $objBarcode->getBarcodePNGPath($strContent, 'C128', 1.5, $intHeight);
     $strFile = substr($strAbsoluteFilePath, strlen($strAbsolutePath));
     return $strPath . '/' . $strFile;
 }
コード例 #2
0
 /**
  * PHARMA2T Barcode HTML table rendering test
  *
  * @covers BG\BarcodeBundle\Util\Base1DBarcode::getBarcodeHTML();
  */
 public function testPHARMA2TGetBarcodeHTMLRaw()
 {
     $d1 = new barCode();
     $d1->savePath = '/tmp/';
     $bcHTMLRaw = $d1->getBarcodeHTML(self::C_BC_DEFAULT, 'PHARMA2T', self::C_BC_1D_WIDTH, self::C_BC_1D_HEIGHT);
     $bcCheckArray = explode('background-color:black', $bcHTMLRaw);
     // print_r(count($bcCheckArray));
     $this->assertTrue(count($bcCheckArray) === 14);
 }