I want to generate a bar code using Zend library and I have this error:
Class 'Namespace\Module\Model\Order\Pdf\Zend_Barcode' not found in 'Namespace\Module\Model\Order\Pdf\Shipment.php'.
This is my code with error:
$imageResource = Zend_Barcode::draw(
'code39', 'image', $barcodeOptions, $rendererOptions
);
In Magento 1.9 works but when I change it on Magento 2 doesn't work. I don't know how to include Zend_Barcode
class of Zend Library in my Shippment class.
You can also import
Zend_Barcode
class at the top of your class file:Then, your code will work as normal:
OR, you can directly instantiate the object of the class. For this, you don't need to import the class but have to use "backslash" infront of the
Zend_Barcode
class name.Reference: PHP Documentation on Using namespaces: Aliasing/Importing