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>