Last active
August 11, 2022 02:43
-
-
Save samsonasik/2918538105eeedaf57a5 to your computer and use it in GitHub Desktop.
barcode save download
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ... | |
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 | |
$response->setContent(file_get_contents('./data/barcode.gif')); | |
//remove file after no need | |
@unlink('./data/barcode.gif'); | |
return $response; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you, it works perfectly! :)