PHP barcode generation problems

Source: Internet
Author: User
PHP generates a barcode. barcodephp. comenuserguide I want to package this method into a function and then pass the value in. the returned html code is: & lt; imgsrc & quot ;#& quot; & gt; this type of string PHPcodefunctionbarcode ($ listing) {Inclu PHP generates a barcode
Official website address http://www.barcodephp.com/en/userguide

Now I want to package this method into a function, and then pass the value in. the returned result is html code, such as a string.

PHP code
  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);     }


------ Solution --------------------
1. bad! The link seems to be damaged.
2.
Header ('content-Type: image/png ');

// Draw (or save) the image into PNG format.
$ Drawing-> finish (BCGDrawing: IMG_FORMAT_PNG );
The difference is that image data streams

So the work is your own business.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.