Skip to content

Instantly share code, notes, and snippets.

Last active Aug 11, 2022
What would you like to do?
barcode save download
// ...
public function barcodeAction()
$barcodeOptions = array('text' => 'ZEND-FRAMEWORK');
$barcode = \Zend\Barcode\Barcode::factory('code39', 'Image', $barcodeOptions);
//temporary save file into data folder
imagegif($barcode->draw(), './data/barcode.gif');
$response = $this->getResponse();
//setting response header....
$response->getHeaders()->addHeaderLine('Content-Type', 'image/gif');
$response->getHeaders()->addHeaderLine('Content-Disposition', 'attachment; filename="barcode.gif"');
$response->getHeaders()->addHeaderLine('Content-Length', filesize('./data/barcode.gif'));
// set response with get content of pdf
//remove file after no need
return $response;
Copy link

Thank you, it works perfectly! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment