PHP產生條碼有關問題

來源:互聯網
上載者:User
PHP產生條碼問題
官網地址http://www.barcodephp.com/en/userguide

我現在想將這個方法打包成函數,然後傳數值進去,返回的是html代碼,例如這種字串

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


------解決方案--------------------
1、糟糕!此連結好像已損壞
2既然有
header('Content-Type: image/png');

// Draw (or save) the image into PNG format.
$drawing->finish(BCGDrawing::IMG_FORMAT_PNG);
那麼差生的是圖片資料流

所以產生 的工作是你自己的事情
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.