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?

    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?