Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Minor
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.10.0
-
Component/s: Zend_Barcode
-
Labels:None
Description
I Need a custom position for draw a barcode in pdf page. There are another way to positioning? I make this changes an work ![]()
abstract class Zend_Barcode_Renderer_RendererAbstract
{
...
public function setTopOffset($value)
{
if (!is_numeric($value) || intval($value) < 0) {
require_once 'Zend/Barcode/Renderer/Exception.php';
throw new Zend_Barcode_Renderer_Exception(
'Vertical position must be greater than or equals 0'
);
}
$this->_verticalPosition = 'custom';//added rolly
$this->_topOffset = intval($value);
return $this;
}
...
public function setLeftOffset($value)
{
if (!is_numeric($value) || intval($value) < 0) {
require_once 'Zend/Barcode/Renderer/Exception.php';
throw new Zend_Barcode_Renderer_Exception(
'Horizontal position must be greater than or equals 0'
);
}
$this->_horizontalPosition = 'custom'; //added rolly
$this->_leftOffset = intval($value);
return $this;
}
...
public function setHorizontalPosition($value)
{
if (!in_array($value, array('left' , 'center' , 'right', 'custom'))) { //added 'custom' rolly
...
}
...
public function setVerticalPosition($value)
{
if (!in_array($value, array('top' , 'middle' , 'bottom', 'custom'))) {//added 'custom' rolly
...
}
protected function _adjustPosition($supportHeight, $supportWidth)
{
$barcodeHeight = $this->_barcode->getHeight(true) * $this->_moduleSize;
if ($barcodeHeight != $supportHeight) {
switch ($this->_verticalPosition) {
case 'custom':
break;
case 'middle':
$this->_topOffset = floor(
($supportHeight - $barcodeHeight) / 2);
break;
case 'bottom':
$this->_topOffset = $supportHeight - $barcodeHeight;
break;
case 'top':
default:
$this->_topOffset = 0;
break;
}
}
$barcodeWidth = $this->_barcode->getWidth(true) * $this->_moduleSize;
if ($barcodeWidth != $supportWidth) {
switch ($this->_horizontalPosition) {
case 'custom':
break;
case 'center':
$this->_leftOffset = floor(
($supportWidth - $barcodeWidth) / 2);
break;
case 'right':
$this->_leftOffset = $supportWidth - $barcodeWidth;
break;
case 'left':
default:
$this->_leftOffset = 0;
break;
}
}
}
Tanks. Sorry for my bad english.
Fixed in r20314