PHP code generation 2 Open Source

Source: Internet
Author: User

This software supports two versions: PhP4 and PhP5. The PhP5 version is used in this article. Before using the function, you must enable the GD module of PHP. In Windows, it is php_gd2.dll, and in Linux it is GD. So. Decompress the compressed file to Apache and executeHttp: // localhost/barcode/index. php. For the interface, see:

1. Type: select the barcode type

2. Output: output image format

3. Thickness: bar code height

4. Resolution: bar code size

5. Font: the text at the bottom of the bar code cannot be displayed.

6. Text: bar code printed content

Of course, thisProgramOnly generate text into a bar code, but cannot be flexibly embedded into other PHP programs. I will compress the test. php
Some adjustments have been made to make it flexible for other programs. You only need to pass the barcode type and text to test. php at runtime, for example:
Http: // localhost/barcode/test. php? Codebar = bcgcode39 & text = 20090729

Or run http: // localhost/barcode/mytest. php

Mytest. phpCode:

<IMG SRC="Test. php? Codebar = bcgcode39 & text = 20090729">
 
 

:

Test. PHP code:

 <? PHP // Including all required classes  Require (' Class/bcgfont. php '); Require (' Class/bcgcolor. php '); Require ('Class/bcgdrawing. php '); /* 'Bcgcodabar ', 'bcgcode11', 'bcgcode39extended', 'bcgcode93', 'bcgcode128', 'bcgean8', 'bcgean13', 'bcgisbn ', 'bcgi25', 'bcgs25', 'bcgmsi ', 'bcgupca', 'bcgupce', 'bcgupcext2', 'bcgupcext5 ', 'bcgpostnet', 'bcgothercode '*/ $ Codebar = $ _ request [' Codebar ']; // All codes supported by the Software. You only need to adjust the $ codebar parameter.  // Including the Barcode Technology  Include (' Class/ '. $ Codebar .' . Barcode. php '); // Loading font $ Font = new bcgfont ('./Class/font/Arial. TTF ', 10 ); // The arguments are R, G, B for color. $ Color_black = new bcgcolor (0, 0, 0); $ color_white = new bcgcolor (255,255,255); $ code = new $ codebar (); $ 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) $ Text = $ _ request [' Text '];// The content of the barcode $ Code-> parse ($ text ); /* Here is the list of the arguments1-filename (empty: display on screen) 2-background color */ $ Drawing = new bcgdrawing ('  ', $ Color_white); $ drawing-> setbarcode ($ Code); $ drawing-> draw (); // Header that says it is an image (remove it if you save the barcode to a file)  Header (' Content-Type: image/PNG '); // Draw (or save) the image into PNG format. $ Drawing-> finish (bcgdrawing: img_format_png ); ?> 

: Source code download ::

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.