Line | |
---|
1 | <?php |
---|
2 | require_once('jpgraph/datamatrix/datamatrix.inc.php'); |
---|
3 | |
---|
4 | $data = 'This is a datamatrix symbol'; |
---|
5 | |
---|
6 | $outputfile = 'dm_ex6.png'; |
---|
7 | |
---|
8 | // Create and set parameters for the encoder |
---|
9 | $encoder = DatamatrixFactory::Create(); |
---|
10 | $encoder->SetEncoding(ENCODING_TEXT); |
---|
11 | |
---|
12 | // Create the image backend (default) |
---|
13 | $backend = DatamatrixBackendFactory::Create($encoder); |
---|
14 | $backend->SetModuleWidth(5); |
---|
15 | $backend->SetQuietZone(10); |
---|
16 | |
---|
17 | // Set other than default colors (one, zero, background) |
---|
18 | $backend->SetColor('navy','white'); |
---|
19 | |
---|
20 | // Create the barcode from the given data string and write to output file |
---|
21 | $dir = dirname(__FILE__); |
---|
22 | $file = '<span style="font-weight:bold;">"'.$dir.'/'.$outputfile.'"</span>'; |
---|
23 | try { |
---|
24 | $backend->Stroke($data,$outputfile); |
---|
25 | echo 'Barcode sucessfully written to file: '.$file; |
---|
26 | } catch (Exception $e) { |
---|
27 | $errstr = $e->GetMessage(); |
---|
28 | $errcode = $e->GetCode(); |
---|
29 | echo "Failed writing file: ".$file.'<br>'; |
---|
30 | echo "Datamatrix error ($errcode). Message: $errstr\n"; |
---|
31 | } |
---|
32 | |
---|
33 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.