This document uses the PHP5 version. 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. This document uses the PHP5 version. 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 execute http: // localhost/barcode/index. php. For more information about generating the PHP5 barcode, see:
1.Type:Select the barcode type
2.Output:Output Image format
3.Thickness:Bar code height
4.Resolution:Barcode size
5.Font:The text size below the bar code is not displayed
6. Text: bar code printed content
Of course, this PHP5 generated barcode program only generates text as a barcode, but it cannot be flexibly embedded into other PHP programs during use. I will compress the test in the package. php has made some adjustments so that it can be used flexibly in 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. php code:
PHP5 generates a barcode:
PHP5 generates the code test. 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 technologyInclude('Class/'. $ codebar.'. barcode. php ');
- // Loading Font $ font =NewBCGFont ('./class/font/Arial. ttf', 10 );
- // The arguments are R, G, B for color. $ color_black =NewBCGColor (0, 0, 0 );
- $ Color_white =NewBCGColor (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']; // PHP5 generates the content of the barcode to be data
- $ Code-> parse ($ text);/* Here is the list of the arguments
- 1-Filename (empty: display on screen) 2-Background color */
- $ Drawing =NewBCGDrawing ('', $ 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 );
- ?>
PHP source code download
|
Http://www.bitscn.com/upimg/soft/201003/1_16030353.zip |