QRCodeGenLib4Pascal is a Delphi/FreePascal port of Fast-QR-Code-generator by Nayuki, providing an easy-to-use interface for generating QR Codes, released under the permissive MIT License.
- All QR versions and error correction levels -- supports encoding all 40 versions (sizes) and all 4 error correction levels, as per the QR Code Model 2 standard
- Multiple output formats -- raw modules/pixels, SVG XML string/file,
ImageObject(bmp,jpg,png) for VCL and LCL - Efficient encoding -- numeric and special-alphanumeric text encoded in less space than general text
- Customizable colors -- configurable background and foreground colors for generated QR codes
- Fine-grained control -- specify version range, mask pattern, error correction level, or let the library choose optimal values automatically
- ECI segments -- manually create data segment lists and add ECI segments
- Cross-framework -- FCL, VCL (Delphi), LCL (Lazarus), and experimental FMX support
| Compiler | Minimum Version |
|---|---|
| Delphi | XE3 or later |
| FreePascal | 3.0.0 or later |
| Framework | Notes |
|---|---|
| FCL | FreePascal |
| VCL | Delphi |
| LCL | Lazarus |
| FMX | Experimental -- enable {.$DEFINE Framework_FMX} in QRCodeGenLib.inc |
Method 1: Using Packages
Use the provided packages in the Packages folder.
Method 2: Search Path
Add the library path and its subdirectories to your project's search path.
uses
SysUtils, QlpQRCodeGenLibTypes, QlpQRCode, QlpIQRCode;
var
LQR: IQRCode;
LSVG: String;
begin
LQR := TQRCode.EncodeText('Hello QRCodeGenLib4Pascal',
TQrCode.TEcc.eccLow, TEncoding.UTF8);
LSVG := LQR.ToSVGString(4);
WriteLn(LSVG);
end;uses
SysUtils, Graphics, QlpQRCodeGenLibTypes, QlpQRCode, QlpIQrCode;
var
LQR: IQRCode;
LBmp: TQRCodeGenLibBitmap;
begin
LQR := TQRCode.EncodeText('Custom colors!',
TQRCode.TEcc.eccMedium, TEncoding.UTF8);
LBmp := LQR.ToBitmapImage(10, 4);
try
LBmp.SaveToFile('qrcode.bmp');
finally
LBmp.Free;
end;
end;uses
SysUtils, QlpQRCodeGenLibTypes, QlpQRCode, QlpIQRCode, QlpQRSegment, QlpIQRSegment;
var
LSegments: TArray<IQrSegment>;
LQR: IQRCode;
begin
LSegments := TQRSegment.MakeSegments('0123456789', TEncoding.UTF8);
LQR := TQRCode.EncodeSegments(LSegments,
TQRCode.TEcc.eccHigh,
5, // minimum version
10, // maximum version
-1, // auto mask
True // boost ECC
);
WriteLn(LQR.ToSVGString(4));
end;Check out the QRCodeGenLib.Demo folder for complete working examples.
Contributions are welcome. Please open an issue for bug reports or feature requests, and submit pull requests.
If you find this library useful and would like to support its continued development, tips are greatly appreciated! 🙏
QRCodeGenLib4Pascal is released under the MIT License.