PHP Barcode Generation Package Class

Source: Internet
Author: User
  1. Referencing classes for class folders
  2. Require_once (' class/bcgfontfile.php ');
  3. Require_once (' class/bcgcolor.php ');
  4. Require_once (' class/bcgdrawing.php ');
  5. Barcode encoding Format
  6. Require_once (' class/bcgcode39.barcode.php ');
  7. Load Font Size
  8. $font = new Bcgfontfile ('./class/font/arial.ttf ', 18);
  9. Color barcode
  10. $color _black = new Bcgcolor (0, 0, 0);
  11. $color _white = new Bcgcolor (255, 255, 255);
  12. $drawException = null;
  13. try {
  14. $code = new BCGcode39 ();
  15. $code->setscale (2);
  16. $code->setthickness (30); The thickness of the barcode
  17. $code->setforegroundcolor ($color _black); Barcode Color
  18. $code->setbackgroundcolor ($color _white); White space gap Color
  19. $code->setfont ($font); //
  20. $code->parse (' HELLO '); The data content required by the barcode
  21. } catch (Exception $exception) {
  22. $drawException = $exception;
  23. }
  24. Draw barcodes based on the above conditions
  25. $drawing = new Bcgdrawing (", $color _white);
  26. if ($drawException) {
  27. $drawing->drawexception ($drawException);
  28. } else {
  29. $drawing->setbarcode ($code);
  30. $drawing->draw ();
  31. }
  32. Generate a picture in PNG format
  33. Header (' content-type:image/png ');
  34. $drawing->finish (bcgdrawing::img_format_png);
  35. ?>
Copy Code
Php
  • Related Article

    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.