Ejemplo n.º 1
0
 /**
  * Returns the maximal size of a barcode
  *
  * @return int[]
  */
 public function getMaxSize()
 {
     $p = parent::getMaxSize();
     $array = str_split($this->text, 1);
     $textlength = (array_sum($array) + count($array)) * $this->scale;
     return array($p[0] + $textlength, $p[1]);
 }
Ejemplo n.º 2
0
 /**
  * Returns the maximal size of a barcode.
  *
  * @return int[]
  */
 public function getMaxSize()
 {
     $p = parent::getMaxSize();
     $textlength = 12 * strlen($this->text) * $this->scale;
     $startlength = 3 * $this->scale;
     $checksumlength = $this->checksum * 12 * $this->scale;
     $endlength = 4 * $this->scale;
     return array($p[0] + $startlength + $textlength + $checksumlength + $endlength, $p[1]);
 }
Ejemplo n.º 3
0
 /**
  * Returns the maximal size of a barcode.
  *
  * @return int[]
  */
 public function getMaxSize()
 {
     $p = parent::getMaxSize();
     $startlength = 3 * $this->scale;
     $centerlength = 5 * $this->scale;
     $textlength = 8 * 7 * $this->scale;
     $endlength = 3 * $this->scale;
     return array($p[0] + $startlength + $centerlength + $textlength + $endlength, $p[1]);
 }
 /**
  * Returns the maximal size of a barcode
  *
  * @return int
  */
 public function getMaxSize()
 {
     $p = parent::getMaxSize();
     $c = strlen($this->text);
     $startlength = 6 * $this->scale;
     $textlength = $c * 5 * 6 * $this->scale;
     $checksumlength = 5 * 6 * $this->scale;
     $endlength = 6 * $this->scale;
     // We remove the white on the right
     $removelength = -3 * $this->scale;
     return array($p[0] + $startlength + $textlength + $checksumlength + $endlength + $removelength, $p[1]);
 }
Ejemplo n.º 5
0
 /**
  * Returns the maximal size of a barcode.
  *
  * @return int[]
  */
 public function getMaxSize()
 {
     $p = parent::getMaxSize();
     $textlength = 7 * strlen($this->text) * $this->scale;
     $startlength = 4 * $this->scale;
     $checksumlength = 0;
     if ($this->checksum === true) {
         $checksumlength = 7 * $this->scale;
     }
     $endlength = 4 * $this->scale;
     return array($p[0] + $startlength + $textlength + $checksumlength + $endlength, $p[1]);
 }
Ejemplo n.º 6
0
 /**
  * Returns the maximal size of a barcode.
  *
  * @return int[]
  */
 public function getMaxSize()
 {
     $p = parent::getMaxSize();
     $c = strlen($this->text);
     $startlength = 8 * $this->scale;
     $textlength = $c * 14 * $this->scale;
     $checksumlength = 0;
     if ($c % 2 !== 0) {
         $checksumlength = 14 * $this->scale;
     }
     $endlength = 7 * $this->scale;
     return array($p[0] + $startlength + $textlength + $checksumlength + $endlength, $p[1]);
 }
Ejemplo n.º 7
0
 /**
  * Returns the maximal size of a barcode
  *
  * @return int[]
  */
 public function getMaxSize()
 {
     $p = parent::getMaxSize();
     $w = 0;
     $c = strlen($this->text);
     for ($i = 0; $i < $c; $i++) {
         $index = $this->findIndex($this->text[$i]);
         if ($index !== false) {
             $w += 8;
             $w += substr_count($this->code[$index], '1');
         }
     }
     return array($p[0] + $w * $this->scale, $p[1]);
 }
 /**
  * Overloaded method for drawing special label
  *
  * @param resource $im
  */
 protected function drawText($im)
 {
     if ($this->label !== BCGBarcode1D::AUTO_LABEL && $this->label !== '') {
         $pA = $this->getMaxSize();
         $pB = BCGBarcode1D::getMaxSize();
         $w = $pA[0] - $pB[0];
         if ($this->textfont instanceof BCGFont) {
             $textfont = clone $this->textfont;
             $textfont->setText($this->label);
             $xPosition = $w / 2 - $textfont->getWidth() / 2 + $this->offsetX * $this->scale;
             $yPosition = $this->thickness * $this->scale + $textfont->getHeight() - $textfont->getUnderBaseline() + BCGBarcode1D::SIZE_SPACING_FONT + $this->offsetY * $this->scale;
             $text_color = $this->colorFg->allocate($im);
             $textfont->draw($im, $text_color, $xPosition, $yPosition);
         } elseif ($this->textfont !== 0) {
             $xPosition = $w / 2 - strlen($this->label) * imagefontwidth($this->textfont) / 2 + $this->offsetX * $this->scale;
             $yPosition = $this->thickness * $this->scale + $this->offsetY * $this->scale + BCGBarcode1D::SIZE_SPACING_FONT;
             $text_color = $this->colorFg->allocate($im);
             imagestring($im, $this->textfont, $xPosition, $yPosition, $this->label, $text_color);
         }
     }
 }
Ejemplo n.º 9
0
 /**
  * Returns the maximal size of a barcode.
  *
  * @return int[]
  */
 public function getMaxSize()
 {
     $p = parent::getMaxSize();
     $w = 0;
     $c = strlen($this->text);
     for ($i = 0; $i < $c; $i++) {
         $index = $this->findIndex($this->text[$i]);
         if ($index !== false) {
             $w += 6;
             $w += substr_count($this->code[$index], '1');
         }
     }
     $startlength = 8 * $this->scale;
     $textlength = $w * $this->scale;
     // We take the max length possible for checksums (it is 7 or 8...)
     $checksumlength = 8 * $this->scale;
     if ($c >= 10) {
         $checksumlength += 8 * $this->scale;
     }
     $endlength = 7 * $this->scale;
     return array($p[0] + $startlength + $textlength + $checksumlength + $endlength, $p[1]);
 }
Ejemplo n.º 10
0
 /**
  * Returns the maximal size of a barcode.
  *
  * @return int[]
  */
 public function getMaxSize()
 {
     $p = parent::getMaxSize();
     $startlength = 3 * $this->scale;
     $centerlength = 5 * $this->scale;
     $textlength = 6 * 7 * $this->scale;
     $endlength = $this->scale;
     $lastcharlength = $this->getEndPosition() + 2;
     return array($p[0] + $startlength + $centerlength + $textlength + $endlength + $lastcharlength, $p[1]);
 }
Ejemplo n.º 11
0
 /**
  * Returns the maximal size of a barcode.
  *
  * @return int[]
  */
 public function getMaxSize()
 {
     $p = parent::getMaxSize();
     $startlength = 9 * $this->scale;
     $textlength = 9 * count($this->data) * $this->scale;
     $checksumlength = 2 * 9 * $this->scale;
     $endlength = 9 * $this->scale + $this->scale;
     // + final bar
     return array($p[0] + $startlength + $textlength + $checksumlength + $endlength, $p[1]);
 }
Ejemplo n.º 12
0
 /**
  * Returns the maximal size of a barcode
  *
  * @return int[]
  */
 function getMaxSize()
 {
     $p = BCGBarcode1D::getMaxSize();
     $startlength = 3 * $this->scale;
     $centerlength = 5 * $this->scale;
     $textlength = 12 * 7 * $this->scale;
     $endlength = 3 * $this->scale;
     return array($p[0] + $startlength + $centerlength + $textlength + $endlength, $p[1]);
 }
 /**
  * Returns the maximal size of a barcode
  *
  * @return int[]
  */
 public function getMaxSize()
 {
     $p = parent::getMaxSize();
     // Contains start + text + checksum + stop
     $textlength = count($this->data) * 11 * $this->scale;
     $endlength = 2 * $this->scale;
     // + final bar
     return array($p[0] + $textlength + $endlength, $p[1]);
 }
Ejemplo n.º 14
0
 public function getMaxSize()
 {
     $p = parent::getMaxSize();
     $textlength = count($this->data) * 11 * $this->scale;
     $endlength = 2 * $this->scale;
     // + final bar
     return array($p[0] + $textlength + $endlength, $p[1]);
 }
Ejemplo n.º 15
0
 /**
  * Overloaded method for drawing special label.
  *
  * @param resource $im
  */
 protected function drawText($im)
 {
     $label = $this->getLabel();
     if (!empty($label)) {
         $pA = $this->getMaxSize();
         $pB = BCGBarcode1D::getMaxSize();
         $w = $pA[0] - $pB[0];
         if ($this->textfont instanceof BCGFont) {
             $textfont = clone $this->textfont;
             $textfont->setText($label);
             $xPosition = $w / 2 - $textfont->getWidth() / 2 + $this->offsetX * $this->scale;
             $yPosition = $this->offsetY * $this->scale - BCGBarcode1D::SIZE_SPACING_FONT + 1;
             // +1 for anti-aliasing
             $textfont->draw($im, $this->colorFg->allocate($im), $xPosition, $yPosition);
         } elseif ($this->textfont !== 0) {
             $xPosition = $w / 2 - strlen($label) / 2 * imagefontwidth($this->textfont) + $this->offsetX * $this->scale;
             $yPosition = $this->offsetY * $this->scale - BCGBarcode1D::SIZE_SPACING_FONT - imagefontheight($this->textfont);
             imagestring($im, $this->textfont, $xPosition, $yPosition, $label, $this->colorFg->allocate($im));
         }
     }
 }
Ejemplo n.º 16
0
 /**
  * Returns the maximal size of a barcode.
  *
  * @return int[]
  */
 public function getMaxSize()
 {
     $p = BCGBarcode1D::getMaxSize();
     $textlength = 13 * count($this->data) * $this->scale;
     $startlength = 13 * $this->scale;
     $checksumlength = 0;
     if ($this->checksum === true) {
         $checksumlength = 13 * $this->scale;
     }
     $endlength = 13 * $this->scale;
     return array($p[0] + $startlength + $textlength + $checksumlength + $endlength, $p[1]);
 }
Ejemplo n.º 17
0
 /**
  * Draws the label under the barcode
  *
  * @param resource $im
  */
 function drawText(&$im)
 {
     // protected
     $label = $this->getLabel();
     if (!empty($label)) {
         $pA = $this->getMaxSize();
         $pB = BCGBarcode1D::getMaxSize();
         $w = $pA[0] - $pB[0];
         if (is_a($this->textfont, 'BCGFont')) {
             $textfont = $this->textfont;
             // clone
             $textfont->setText($label);
             $xPosition = $w / 2 - $textfont->getWidth() / 2 + $this->offsetX * $this->scale;
             $yPosition = $this->thickness * $this->scale + $textfont->getHeight() - $textfont->getUnderBaseline() + $this->SIZE_SPACING_FONT + $this->offsetY * $this->scale;
             $textfont->draw($im, $this->colorFg->allocate($im), $xPosition, $yPosition);
         } elseif ($this->textfont !== 0) {
             $xPosition = $w / 2 - strlen($label) / 2 * imagefontwidth($this->textfont) + $this->offsetX * $this->scale;
             $yPosition = $this->thickness * $this->scale + $this->SIZE_SPACING_FONT + $this->offsetY * $this->scale;
             imagestring($im, $this->textfont, $xPosition, $yPosition, $label, $this->colorFg->allocate($im));
         }
     }
 }
Ejemplo n.º 18
0
 /**
  * Overloaded method for drawing special label
  *
  * @param resource $im
  */
 protected function drawText($im)
 {
     parent::drawText($im);
     if (strlen($this->isbn_created) > 0) {
         $pA = $this->getMaxSize();
         $pB = BCGBarcode1D::getMaxSize();
         $w = $pA[0] - $pB[0];
         if ($this->isbn_textfont instanceof BCGFont) {
             $textfont = clone $this->isbn_textfont;
             $textfont->setText($this->isbn_created);
             $xPosition = $w / 2 - $textfont->getWidth() / 2 + $this->offsetX * $this->scale;
             $yPosition = $this->offsetY * $this->scale - BCGBarcode1D::SIZE_SPACING_FONT;
             $textfont->draw($im, $this->colorFg->allocate($im), $xPosition, $yPosition);
         } elseif ($this->isbn_textfont !== 0) {
             $xPosition = $w / 2 - strlen($this->isbn_created) / 2 * imagefontwidth($this->isbn_textfont) + $this->offsetX * $this->scale;
             $yPosition = $this->offsetY * $this->scale - BCGBarcode1D::SIZE_SPACING_FONT - imagefontheight($this->isbn_textfont);
             imagestring($im, $this->isbn_textfont, $xPosition, $yPosition, $this->isbn_created, $this->colorFg->allocate($im));
         }
     }
 }
Ejemplo n.º 19
0
 /**
  * Overloaded method for drawing special label.
  *
  * @param resource $im
  */
 protected function drawText($im)
 {
     parent::drawText($im);
     if (strlen($this->isbn_created) > 0) {
         $pA = $this->getMaxSize();
         $pB = BCGBarcode1D::getMaxSize();
         $w = $pA[0] - $pB[0];
         if ($this->getISBNFont() instanceof BCGFont) {
             $textfont = clone $this->getISBNFont();
             $textfont->setText($this->isbn_created);
             $xPosition = max(0, $w / 2 - $textfont->getWidth() / 2 + ($this->offsetX - $this->ean13offsetX) * $this->scale);
             $yPosition = $this->offsetY * $this->scale - BCGBarcode1D::SIZE_SPACING_FONT + 1;
             // +1 for anti-aliasing
             $textfont->draw($im, $this->colorFg->allocate($im), $xPosition, $yPosition);
         } elseif ($this->getISBNFont() !== 0) {
             $xPosition = $w / 2 - strlen($this->isbn_created) / 2 * imagefontwidth($this->getISBNFont()) + ($this->offsetX - $this->ean13offsetX) * $this->scale;
             $yPosition = $this->offsetY * $this->scale - BCGBarcode1D::SIZE_SPACING_FONT - imagefontheight($this->getISBNFont());
             imagestring($im, $this->getISBNFont(), $xPosition, $yPosition, $this->isbn_created, $this->colorFg->allocate($im));
         }
     }
 }