Thinkphp Framework implementation of barcode generation method

Source: Internet
Author: User
This article mainly introduces the thinkphp framework implementation of the method of generating barcodes, combined with an example of the thinkphp combination of third-party barcode class files to generate barcode related operation skills, the need for friends can refer to the following

This paper describes the method of thinkphp framework to generate barcode. Share to everyone for your reference, as follows:

Before we do the download barcode class, want to download the class can click here to download the site .

We write a method code in the background as follows:

Generate the Barcode Public Function barcode () {import (' @.org. Util.barcode.BCGFontFile ');//Font Class import (' @.org. Util.barcode.BCGColor ');//Font Color class import (' @.org.  Util.barcode.BCGDrawing '); Import (' @.org.  Util.barcode.BCGcode39 ');  $text = $_get[' text '];  $texts = Isset ($text)? $text: ' 00000000000 ';  $color _black = new \bcgcolor (0,0,0);  $color _white = new \bcgcolor (255,255,255);  $drawException = null;    try {$code = new \bcgcode39 ();    $code->setscale (2);    $code->setthickness (30);    $code->setforegroundcolor ($color _black);    $code->setbackgroundcolor ($color _white);  $code->parse ($texts);  } catch (Exception $exception) {$drawException = $exception;  } $drawing = new \bcgdrawing (' ', $color _white);  if ($drawException) {$drawing->drawexception ($drawException);    } else {$drawing->setbarcode ($code);  $drawing->draw ();  } header (' Content-type:image/png ');  Header (' Content-disposition:inline; filename= ' barcode.png '); $drawing->finish (\bcgdrawing::img_formaT_png);} 

Call directly at the foreground:

Use the JS calling code as follows:

<script type= "Text/javascript" language= "JavaScript" >  document.writeln (" ");</script>

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.