>백엔드 개발 >PHP 튜토리얼 >PHP生成条形码有关问题

PHP生成条形码有关问题

WBOY
WBOY원래의
2016-06-13 10:13:271234검색

PHP生成条形码问题
官网地址http://www.barcodephp.com/en/userguide

我现在想将这个方法打包成函数,然后传数值进去,返回的是html代码,例如PHP生成条形码有关问题这种字符串

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->function barcode($listing)    {    // Including all required classes        require_once('class/BCGFontFile.php');        require_once('class/BCGColor.php');        require_once('class/BCGDrawing.php');                // Including the barcode technology        require_once('class/BCGcode39.barcode.php');                // Loading Font        $font = new BCGFontFile('./class/font/Arial.ttf', 18);                // The arguments are R, G, B for color.        $color_black = new BCGColor(0, 0, 0);        $color_white = new BCGColor(255, 255, 255);                $drawException = null;        try {            $code = new BCGcode39();            $code->setScale(2); // Resolution            $code->setThickness(30); // Thickness            $code->setForegroundColor($color_black); // Color of bars            $code->setBackgroundColor($color_white); // Color of spaces            $code->setFont($font); // Font (or 0)            $code->parse($listing); // Text        } catch(Exception $exception) {            $drawException = $exception;        }                /* Here is the list of the arguments        1 - Filename (empty : display on screen)        2 - Background color */        $drawing = new BCGDrawing('', $color_white);        if($drawException) {            $drawing->drawException($drawException);        } else {            $drawing->setBarcode($code);            $drawing->draw();        }                // Header that says it is an image (remove it if you save the barcode to a file)        header('Content-Type: image/png');                // Draw (or save) the image into PNG format.        $drawing->finish(BCGDrawing::IMG_FORMAT_PNG);     }


------解决方案--------------------
1、糟糕!此链接好像已损坏
2既然有
header('Content-Type: image/png');

// Draw (or save) the image into PNG format.
$drawing->finish(BCGDrawing::IMG_FORMAT_PNG);
那么差生的是图片数据流

所以产生 PHP生成条形码有关问题 的工作是你自己的事情
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.