<?php // Example 6 : QR Barcode with image in JPG format // Include the library require_once 'jpgraph/QR/qrencoder.inc.php'; $data = 'ABCDEFGH01234567'; // Data to be encoded $version = -1; // -1 = Let the library decide version (same as default) $corrlevel = -1; // -1 = Let the library decide error correction level (same as default) // Create a new instance of the encoder using the specified // QR version and error correction $encoder = new QREncoder($version, $corrlevel); // Use the image backend $backend = QRCodeBackendFactory::Create($encoder, BACKEND_IMAGE); // Use JPEG format with 80% quality level $backend->SetImgFormat('jpeg', 80); // Set the module size $backend->SetModuleWidth(4); // Store the barcode in the specifed file $backend->Stroke($data);
<?php require_once 'jpgraph/QR/qrencoder.inc.php'; // Data to be encoded $data = '01234567'; // Create a new instance of the encoder and let the library // decide a suitable QR version and error level $encoder = new QREncoder(1); // Use the image backend (this is also the default) $backend = QRCodeBackendFactory::Create($encoder); try { // . send the QR Code back to the browser $backend->Stroke($data); } catch (Exception $e) { $errstr = $e->GetMessage(); echo 'QR Code error: ' . $e->GetMessage() . "\n"; exit(1); }
<?php // Include the library require_once 'jpgraph/QR/qrencoder.inc.php'; // Example 11 : Generate postscript output $data = 'ABCDEFGH01234567'; // Data to be encoded $version = -1; // -1 = Let the library decide version (same as default) $corrlevel = QRCapacity::ErrH; // Error correction level H (Highest possible) $modulewidth = 1; // Create a new instance of the encoder using the specified // QR version and error correction $encoder = new QREncoder($version, $corrlevel); // Use the image backend $backend = QRCodeBackendFactory::Create($encoder, BACKEND_ASCII); // Set the module size $backend->SetModuleWidth($modulewidth); // Store the barcode in the specifed file $ps_str = $backend->Stroke($data); echo '<pre>' . $ps_str . '</pre>';
<?php require_once 'jpgraph/QR/qrencoder.inc.php'; // Data to be encoded $data = '01234567'; // Create a new instance of the encoder and let the library // decide a suitable QR version and error level $e = new QREncoder(); // Use the image backend (this is also the default) $b = QRCodeBackendFactory::Create($e); // .. send the barcode back to the browser for the data $b->Stroke($data);