PHP Generated Barcode problem
Official Address Http://www.barcodephp.com/en/userguide
I now want to package this method into a function and then pass the value in, returning the HTML code, such as this string
PHP Code
function Barcode ($listing) {//Including all required classes require_once (' class/bcgfontfile.php '); Require_once (' class/bcgcolor.php '); Require_once (' class/bcgdrawing.php '); Including the barcode technology require_once (' class/bcgcode39.barcode.php '); Loading Font $font = new Bcgfontfile ('./class/font/arial.ttf ', 18); The arguments is R, G, B for color. $color _black = new Bcgcolor (0, 0, 0); $color _white = new Bcgcolor (255, 255, 255); $drawException = null; try {$code = new BCGcode39 (); $code->setscale (2); Resolution $code->setthickness (30); Thickness $code->setforegroundcolor ($color _black); Color of Bars $code->setbackgroundcolor ($color _white); Color of Spaces $code->setfont ($font); Font (or 0) $code->parse ($listing); Text} catch (ExcePtion $exception) {$drawException = $exception; }/* Here are the list of the arguments 1-filename (empty:display on screen) 2-backgroun D Color */$drawing = new bcgdrawing (' ', $color _white); if ($drawException) {$drawing->drawexception ($drawException); } else {$drawing->setbarcode ($code); $drawing->draw (); }//header that says it's an image (remove it if you save the barcode to a file) Header (' Content-t Ype:image/png '); Draw (or save) the image into PNG format. $drawing->finish (bcgdrawing::img_format_png); }
------Solution--------------------
1, Bad! This link appears to be corrupted
2 since there is
Header (' content-type:image/png ');
Draw (or save) the image into PNG format.
$drawing->finish (bcgdrawing::img_format_png);
So the poor is the picture data stream
So the work that's generated is your own business.