dongxing1853 2014-10-22 12:38
浏览 558

将条形码保存在数据库中

I was wondering if I could save bar code in database. I am using "Code 39" type of barcode. Barcode will be generated from variable. I wanted to save it to database if possible. I have downloaded library from "http://www.barcodebakery.com". Can anyone give me suggestion how to do so?

Code works fine it displays the image, later on I will use bar code scanner to look for products, each of them will contain bar code.

<?php
    require_once('class/BCGFontFile.php');
    require_once('class/BCGColor.php');
    require_once('class/BCGDrawing.php');
    require('class/BCGcode39.barcode.php');

    $font = new BCGFontFile('font/Arial.ttf', 18);
    $color_black = new BCGColor(0, 0, 0);
    $color_white = new BCGColor(255, 255, 255);

    $barcode="3RC402A00";

    // Barcode Part
    $code = new BCGcode39();
    $code->setScale(2);
    $code->setThickness(30);
    $code->setForegroundColor($color_black);
    $code->setBackgroundColor($color_white);
    $code->setFont($font);
    $code->parse($barcode);

    // Drawing Part
    $drawing = new BCGDrawing('', $color_white);
    $drawing->setBarcode($code);
    $drawing->draw();
    header('Content-Type: image/png');
    $drawing->finish(BCGDrawing::IMG_FORMAT_PNG);
?>

Any suggestion is appreciated. Thanks

  • 写回答

2条回答 默认 最新

  • duanseci1039 2014-10-22 12:45
    关注
    $drawing = new BCGDrawing('yourfilename.png', $color_white);
    

    That would save the image to a file.

    To save a file into database, refer to this stackoverflow post.

    How can I store and retrieve images from a MySQL database using PHP?

    评论

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站