영원한사랑

ZINT PHP extension win32 0.4 (GPL) 바코드 생성기

zint를 기초로 64종류의 바코드 이미지를 GD 처럼 바로 출력 가능한 PHP 확장입니다.
php 5.2.6으로 컴파일 되어 있어서 5.2.6에서만 사용 가능합니다. (다른 php 버젼을 원하시면 아래 컴파일 방법 참조)
aztec code는 버그가 많아서 제외 했습니다. console용도 포함되어 있습니다.
아래는 datamatrix만 encode, decode 가능하고, 이건 여러가지 바코드를 encode만 가능합니다.
역시 윈도우 의존적인 함수는 사용하지 않아서 php돌아가는 운영체제에서 가능하겠지만, phpize용 m4를 만들줄 몰라서...

사용자 삽입 이미지

사용 라이브러리

- zint-1.6.2(GPL) http://www.zint.org.uk/
- libqrencode(LGPL) http://megaui.net/fukuchi/works/qrencode/index.en.html
- zlib
- libpng(Open Source)
- 본 압축에 포함되어 있는 소스는 일부분이(zint,qrencode) 수정 되어 있습니다. zint는 메모리 할당 후 해제 작업이 거의 없더군요.

설치 방법
1. php_zint.dll을 php/ext로 복사한 후.
2. php.ini에 " extension=php_zint.dll " 추가
사용 법

콘솔용과 옵션이 같습니다. 자세한 내용은 zint/zint/docs/index.html을 참조하세요.

$params = array(
  ['outputfile'        => string (default NULL, 설정되지 않으면 breturn이 적용됨)]
  ['barcode'        => int (default 1, Number of barcode type)]
  ['breturn'        => bool (default false, outputfile이 설정되어 있으면 무시됨)]
  'data'        => string (Barcode content) (require)
  ['height'        => int (default 0(auto), 1~1000 pixels, Height of barcode)]
  ['Whitespace'        => int (default 0, 0~1000 pixels, Width of whitespace)]
  ['border'        => int (default 0, 1~1000 pixels, Width of border)]
  ['outputoption'    => int (ZINT_BARCODE_BIND, ZINT_BARCODE_BOX )
   (default NONE, BARCODE_BIND=border 만큼 위아래 선, BARCODE_BOX=border 만큼의 박스)]
  ['reverse'        => bool (default false, Reverse colours )]
  ['fg'            => string (default 000000, 6 length string, Specify a foreground color)]
  ['bg'            => string (default ffffff, 6 length string, Specify a background color)]
  ['rotate'        => int (default 0, 90 180 270)]
  ['cols'        => int (default 0, 1~30, PDF417 only)]
  ['vers'        => int (default 0, 1~9, QR Code only )]
  ['secure'        => int (default -1, 1~8, PDF417 and QR Code Error correction level)]
  ['primary'        => string (default NULL, Maxicode and Composite Structured primary message)]
  ['mode'        => int (1~6, Maxicode and Composite Set encoding mode)]
);

zint_imagepng( $params );

예제

<?
//화면으로 QR Code가 뿌려집니다.
$params = array (
'barcode'=>58 //qrcode
,'data'=> "1234"
);
zint_imagepng($params);
?>

<?
//화면으로 출력하지 않고 변수에 담습니다.
$params = array (
'barcode'=>57//maxicode
,'data'=> "1234"
,'breturn'=>true
);
$result = zint_imagepng($params);
//echo $result;
?>

<?
//파일로 출력합니다.
$params = array (
'outputfile'=> "test.png"
,'barcode'=>55 //PDF417
,'data'=> "1234"
);
zint_imagepng($params);
?>

php_zint로 직접 생성한 샘플
바코드 번호(barcode type)

1

Code 11

2

Standard Code 2 of 5

3

Interleaved 2 of 5

4

Code 2 of 5 IATA

6

Code 2 of 5 Data Logic

7

Code 2 of 5 Industrial

8

Code 3 of 9 (Code 39)

9

Extended Code 3 of 9 (Code 39+)

13

EAN

16

GS1-128 (UCC.EAN-128)

18

Codabar

20

Code 128 (automatic subset switching)

21

Deutshe Post Leitcode

22

Deutshe Post Identcode

23

Code 16K

25

Code 93

28

Flattermarken

29

GS1 DataBar-14

30

GS1 DataBar Limited

31

GS1 DataBar Extended

32

Telepen Alpha

34

UPC A

37

UPC E

40

PostNet

47

MSI Code

49

FIM

50

LOGMARS

51

Pharmacode One-Track

52

PZN

53

Pharmacode Two-Track

55

PDF417

56

PDF417 Truncated

57

Maxicode

58

QR Code

60

Code 128 (Subset B)

63

Australia Post Standard Customer

66

Australia Post Reply Paid

67

Australia Post Routing

68

Australia Post Redirection

69

ISBN (EAN-13 with verification stage)

70

Royal Mail 4 State (RM4SCC)

71

Data Matrix

72

ITF-14

75

NVE-18

79

GS1 DataBar-14 Stacked

80

GS1 DataBar-14 Stacked Omnidirectional

81

GS1 DataBar Expanded Stacked

82

PLANET

84

MicroPDF417

85

USPS OneCode

86

Plessey Code

100

Telepen Numeric

101

MSI Plessey + mod 10

102

MSI Plessey + mod 10 + mod 10

103

MSI Plessey + mod 11

104

MSI Plessey + mod 10 + mod 11

105

Code 39 + mod 43

106

Extended Code 39 + mod 43

110

Composite Symbol with EAN linear component

111

Composite Symbol with GS1-128 linear component

112

Composite Symbol with GS1 DataBar-14 linear component

113

Composite Symbol with GS1 DataBar Limited component

114

Composite Symbol with GS1 DataBar Extended component

115

Composite Symbol with UPC A linear component

116

Composite Symbol with UPC E linear component

117

Composite Symbol with GS1 DataBar-14 Stacked component

118

Composite Symbol with GS1 DataBar-14 Stacked Omnidirectional component

119

Composite Symbol with GS1 DataBar Expanded Stacked component

120

Dutch Post KIX Code

다른 버젼용으로 컴파일 하는 방법
1. php.net에서 원하는 버젼의 php binary와 source를 다운 받습니다.
2. php binary의 dev 디렉토리에 있는 php5ts.lib을 zint/lib디록토리로 복사합니다.
3. php source는 zint/php로 복사합니다.
4. VC2003으로 zint/php_zint.sln를 여신 후 프로젝트 구성을 PHP EXT Release로 변경.
5. zlib>libpng>qrencode_win32>php_zint,zint-win32(console용) 순서대로 컴파일.
6. zint/release 디렉토리에 원하는 binary가 생성됩니다.
 
- 테스트용 코드가 남아있던 문제를 수정했습니다.
버그 테스트 많이 해주세요.
Code 93와 QR Code에서 특정 데이터를 넣으면 에러뜨는 조금 불안한 버그가 있습니다. zint 자체 버그같습니다.
zint 2.0 stable 나오면 변경 해야겠습니다.



64가지 바코드 생성 zint php 확장 :
http://phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=63846&page=1

Datamatrix 바코드 생성/읽기 php 확장 :
http://phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=63794&page=1

레이어로 바코드 그리기 입니다.

소스는... 첨부파일 참조......

사용법........만 설명...


사용방법 :
바코드를 그릴 페이지에 아래의 스타일 시트를 선언해주셔야 합니다.
  <style type="text/css">
  .space { background:#FFFFFF;float:left;margin:0;padding:0;cursor:default; }
  .bar { background:#000000;float:left;margin:0;padding:0;cursor:default; }
  .bartext { clear:both;font-family:Fixedsys,Arial;font-size:12px;cursor:default; }
  </style>

barcode.js 파일을 불러들입니다.


<script type="text/javascript" src="barcode.js"></script>

바코드를 그릴 라인에서 아래와 같이 써줍니다.
<script type="text/javascript">barcode("1234567890", 40);</script>
<script type="text/javascript">barcode("i-swear.com", 40);</script>


사용예시
기본 : 바의 넓이 1px, 굵은바의 넓이 2px, 색상 검정
barcode(문자열, 바코드의 세로길이); // 필수 예시1
barcode(문자열, 바코드의 세로길이, 바의 넓이, 굵은바의 넓이); // 예시 2
barcode(문자열, 바코드의 세로길이, 바의 넓이, 굵은바의 넓이, 스페이스의 넓이, 굵은 스페이스의 넓이) // 예시 3
barcode(문자열, 바코드의 세로길이, 바의 넓이, 굵은바의 넓이, 스페이스의 넓이, 굵은 스페이스의 넓이, 바코드의 색상, 바코드 문자열의 색상) // 예시 4

ps. 문자열은 소문자로 넣어도 대문자로 변환됩니다..
    레이어는 absolute 이기 때문에 바코드를 연달아 출력하려면 br 태그로 띄워주세연