1、如何生成條形碼?
在barcode
barcodegen.1d-php5.v5.0.1.zip版本,然後解壓檔案放到你的apache伺服器的根目錄下。
1.1檔案結構:
1.2具體解析
(1)class資料夾是已封裝好生成條形碼的類,只需要呼叫即可。
(2)index.php是乙個可選擇條件生成條形碼的功能,是主程式的入口,而html資料夾是提供的被引用的**,code39.php指的是指向預設的編碼格式。
<?php
header('location: html/code39.php');
?>
當直接訪問http://localhost/barcodegen/index.php
時,使用者體驗可以體驗該功能,任意選擇項,生成對應的條形碼。需要的話可以將它改版成module來使用。
(3)test.php是另外乙個例子,通過**直接生成hello條形碼。
當訪問http://localhost/barcodegen/test.php時,hello.png生成
//引用class資料夾對應的類
require_once('class/bcgfontfile.php');
require_once('class/bcgcolor.php');
require_once('class/bcgdrawing.php');
//條形碼的編碼格式
require_once('class/bcgcode39.barcode.php');
//載入字型大小
$font = new bcgfontfile('./class/font/arial.ttf', 18);
//顏色條形碼
$color_black = new bcgcolor(0, 0, 0);
$color_white = new bcgcolor(255, 255, 255);
$drawexception = null
;try
catch(exception
$exception
) //
根據以上條件繪製條形碼
$drawing = new bcgdrawing('', $color_white
);if($drawexception
) else
//生成png格式的
header('content-type: image/png');
$drawing->finish(bcgdrawing::img_format_png);
?>
然後新建test.html檔案,向buildcode.php請求資料
doctype html最後訪問>
<
html
>
<
head
>
<
title
>test with embedded image
title
>
head
>
<
body
>
<
img
src="buildcode.php?codebar=bcgcode39&text=abc123"
/>
body
>
html
>
http://localhost/barcodegen/test.html或訪問
http://localhost/barcodegen/buildcode.php?codebar=bcgcode39&text=abc123,瀏覽器直接生成png格式的條形碼
其中codebar支援的編碼格式可以由使用者請求所得:
/*'bcgcodabar','bcgcode11','bcgcode39','bcgcode39extended','bcgcode93',
'bcgcode128','bcgean8','bcgean13','bcgisbn','bcgi25','bcgs25','bcgmsi',
'bcgupca','bcgupce','bcgupcext2','bcgupcext5','bcgpostnet','bcgothercode'
*/
條形碼(Bar Code)概述
社會的發展產生新的需求,於是新的技術應運而生。條形碼也不例外。想像一下,在超市結賬的時候,你推著一車子的東西,櫃檯服務員乙個商品接乙個商品的手動計算你的購買總金額,這會是乙個多麼恐怖的場景。最害怕這個場景的還不是,而是排在你後面的那個人,以及後面的後面的。的所有人。收款環節成為了超市發展的最大瓶頸。...
PHP生成條形碼
1.什麼是條形碼?列印出來的優惠券,商家需要用驗證器讀取條形碼,來獲得其有效性。2.如何生成條形碼?2.1檔案結構 2.2具體解析 1 class資料夾是已封裝好生成條形碼的類,只需要呼叫即可。2 index.php是乙個可選擇條件生成條形碼的功能,是主程式的入口,而html資料夾是提供的被引用的 ...
PHP生成條形碼
前陣子在做乙個商家優惠券的功能,需要用到條形碼,於是將資料重新整理下。1.什麼是條形碼?列印出來的優惠券,商家需要用驗證器讀取條形碼,來獲得其有效性。2.如何生成條形碼?首先找到強大的開源資料,在barcode barcodegen.1d php5.v5.0.1.zip版本,然後解壓檔案放到你的ap...