Rev | Line | |
---|
[42] | 1 | <?php |
---|
| 2 | // Example 3 : QR Barcode with specified version and stored to a file |
---|
| 3 | |
---|
| 4 | // Include the library |
---|
| 5 | require_once ('jpgraph/QR/qrencoder.inc.php'); |
---|
| 6 | |
---|
| 7 | // Data to be encoded |
---|
| 8 | $data = '01234567'; |
---|
| 9 | $version = 3; // Use QR version 3 |
---|
| 10 | $fileName = 'qrexample03.png'; |
---|
| 11 | |
---|
| 12 | // Create a new instance of the encoder and let the library |
---|
| 13 | // decide a suitable error level |
---|
| 14 | $encoder = new QREncoder($version); |
---|
| 15 | |
---|
| 16 | // Use the image backend |
---|
| 17 | $backend = QRCodeBackendFactory::Create($encoder, BACKEND_IMAGE); |
---|
| 18 | |
---|
| 19 | // Set the module size (quite big) |
---|
| 20 | $backend->SetModuleWidth(5); |
---|
| 21 | |
---|
| 22 | // Store the barcode in the specifed file |
---|
| 23 | $backend->Stroke($data,$fileName); |
---|
| 24 | list($version,$errorcorrection) = $backend->GetQRInfo(); |
---|
| 25 | |
---|
| 26 | echo "QR Barcode, (<b>Version: $version-$errorcorrection</b>), image stored in file $fileName"; |
---|
| 27 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.