PHP Generated Barcode Source Interpretation

Source: Internet
Author: User

<?PHP//including all required classesrequire_once(' class/bcgfontfile.php ');//Introducing font Generation filesrequire_once(' class/bcgcolor.php ');//Introducing background color filesrequire_once(' class/bcgdrawing.php ');//Introducing picture generation files//Including the barcode technologyrequire_once(' class/bcgcode39.barcode.php ');//Barcode Encoding Rule file introduced//Loading Font$font=NewBcgfontfile ('./font/arial.ttf ', 18);//introduce fonts and set the font size//Don ' t forget to sanitize user inputs$text=isset($_get[' Text ']) ?$_get[' Text ']: ' DSFDFASDA ';//sets the contents of the original text of the barcode//The arguments is R, G, B for color.$color _black=NewBcgcolor (0, 0, 0);//set the RGB color for black$color _white=NewBcgcolor (255, 255, 255);//set the RGB color for white$drawException=NULL;Try {    $code=NewBCGcode39 ();//to create a new object    $code->setscale (1.4);//Resolution//Set scale of scaling    $code->setthickness (60);//Thickness//Set height    $code->setforegroundcolor ($color _black);//Color of Bars    $code->setbackgroundcolor ($color _white);//Color of Spaces    $code->setfont ($font);//Font (or 0)//Set fonts    $code->parse ($text);//text//Convert font}Catch(Exception $exception) {    $drawException=$exception;}/*Here is the list of the arguments1-filename (empty:display in screen) 2-background color*/$drawing=NewBcgdrawing ("',$color _white);//Create a piece of canvasif($drawException) {    $drawing->drawexception ($drawException);//If the error is caught, the output}Else {    $drawing->setbarcode ($code);//Setting up Barcodes    $drawing->draw ();//Create a picture}//Header that says it's an image (remove it if you save the barcode to a file)Header(' Content-type:image/png ');//tell the browser this is a PNG-formatted pictureHeader(' Content-disposition:inline; filename= "Barcode.png");//configuration, in-line, set file name//Draw (or save) the image into PNG format.$drawing->finish (bcgdrawing::img_format_png);//output image is in PNG format?>

PHP Generated Barcode Source Interpretation

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.