@qr-platform/qr-code.js 0.8.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +18 -0
- package/CHANGELOG.md +233 -0
- package/LICENSE.md +77 -0
- package/README.md +188 -0
- package/docs/advanced-examples.md +523 -0
- package/docs/api-reference-guide.md +254 -0
- package/docs/documentation.md +1592 -0
- package/docs/examples.md +322 -0
- package/docs/license-management.md +501 -0
- package/docs/typescript-types-definitions.md +372 -0
- package/docs/usage-guide.md +622 -0
- package/lib/core/qr-code-js.d.ts +48 -0
- package/lib/core/qr-constant.d.ts +9 -0
- package/lib/core/qr-options-validation.d.ts +13 -0
- package/lib/core/qr-svg.d.ts +76 -0
- package/lib/core/qr-templates.d.ts +6 -0
- package/lib/figures/corner-dot.d.ts +24 -0
- package/lib/figures/corner-square.d.ts +24 -0
- package/lib/figures/dot.d.ts +31 -0
- package/lib/index.d.ts +52 -0
- package/lib/lib/image/GIFImage.d.ts +19 -0
- package/lib/lib/io/Base64.d.ts +10 -0
- package/lib/lib/io/Base64DecodeInputStream.d.ts +15 -0
- package/lib/lib/io/Base64EncodeOutputStream.d.ts +17 -0
- package/lib/lib/io/ByteArrayInputStream.d.ts +12 -0
- package/lib/lib/io/ByteArrayOutputStream.d.ts +12 -0
- package/lib/lib/io/InputStream.d.ts +10 -0
- package/lib/lib/io/OutputStream.d.ts +12 -0
- package/lib/lib/qr-code.d.ts +5 -0
- package/lib/lib/qrcode/BitBuffer.d.ts +11 -0
- package/lib/lib/qrcode/ErrorCorrectLevel.d.ts +23 -0
- package/lib/lib/qrcode/MaskPattern.d.ts +39 -0
- package/lib/lib/qrcode/Mode.d.ts +23 -0
- package/lib/lib/qrcode/Polynomial.d.ts +15 -0
- package/lib/lib/qrcode/QR8BitByte.d.ts +13 -0
- package/lib/lib/qrcode/QRAlphaNum.d.ts +13 -0
- package/lib/lib/qrcode/QRCode.d.ts +22 -0
- package/lib/lib/qrcode/QRCodeMinimal.d.ts +58 -0
- package/lib/lib/qrcode/QRData.d.ts +17 -0
- package/lib/lib/qrcode/QRKanji.d.ts +13 -0
- package/lib/lib/qrcode/QRMath.d.ts +13 -0
- package/lib/lib/qrcode/QRNumber.d.ts +14 -0
- package/lib/lib/qrcode/QRUtil.d.ts +25 -0
- package/lib/lib/qrcode/RSBlock.d.ts +16 -0
- package/lib/lib/text/createStringToBytes.d.ts +9 -0
- package/lib/lib/text/stringToBytes_SJIS.d.ts +8 -0
- package/lib/lib/text/stringToBytes_UTF8.d.ts +7 -0
- package/lib/lib/zbar-wasm/index.d.ts +1 -0
- package/lib/lib/zxing-js/src/browser/BrowserCodeReader.d.ts +410 -0
- package/lib/lib/zxing-js/src/browser/BrowserQRCodeReader.d.ts +29 -0
- package/lib/lib/zxing-js/src/browser/BrowserQRCodeSvgWriter.d.ts +46 -0
- package/lib/lib/zxing-js/src/browser/BrowserSvgCodeWriter.d.ts +49 -0
- package/lib/lib/zxing-js/src/browser/DecodeContinuouslyCallback.d.ts +6 -0
- package/lib/lib/zxing-js/src/browser/HTMLCanvasElementLuminanceSource.d.ts +27 -0
- package/lib/lib/zxing-js/src/browser/HTMLVisualMediaElement.d.ts +4 -0
- package/lib/lib/zxing-js/src/browser/VideoInputDevice.d.ts +22 -0
- package/lib/lib/zxing-js/src/browser.d.ts +3 -0
- package/lib/lib/zxing-js/src/core/ArgumentException.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/ArithmeticException.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/ArrayIndexOutOfBoundsException.d.ts +10 -0
- package/lib/lib/zxing-js/src/core/BarcodeFormat.d.ts +42 -0
- package/lib/lib/zxing-js/src/core/Binarizer.d.ts +53 -0
- package/lib/lib/zxing-js/src/core/BinaryBitmap.d.ts +78 -0
- package/lib/lib/zxing-js/src/core/ChecksumException.d.ts +8 -0
- package/lib/lib/zxing-js/src/core/DecodeHintType.d.ts +91 -0
- package/lib/lib/zxing-js/src/core/Dimension.d.ts +13 -0
- package/lib/lib/zxing-js/src/core/EncodeHintType.d.ts +99 -0
- package/lib/lib/zxing-js/src/core/Exception.d.ts +17 -0
- package/lib/lib/zxing-js/src/core/FormatException.d.ts +8 -0
- package/lib/lib/zxing-js/src/core/HighContrastLuminanceSource.d.ts +27 -0
- package/lib/lib/zxing-js/src/core/IllegalArgumentException.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/IllegalStateException.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/IndexOutOfBoundsException.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/InvertedLuminanceSource.d.ts +22 -0
- package/lib/lib/zxing-js/src/core/LuminanceSource.d.ts +84 -0
- package/lib/lib/zxing-js/src/core/NodeLuminanceSource.d.ts +36 -0
- package/lib/lib/zxing-js/src/core/NotFoundException.d.ts +8 -0
- package/lib/lib/zxing-js/src/core/NullPointerException.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/OutOfMemoryError.d.ts +6 -0
- package/lib/lib/zxing-js/src/core/PlanarYUVLuminanceSource.d.ts +35 -0
- package/lib/lib/zxing-js/src/core/RGBLuminanceSource.d.ts +21 -0
- package/lib/lib/zxing-js/src/core/Reader.d.ts +49 -0
- package/lib/lib/zxing-js/src/core/ReaderException.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/ReedSolomonException.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/Result.d.ts +52 -0
- package/lib/lib/zxing-js/src/core/ResultMetadataType.d.ts +68 -0
- package/lib/lib/zxing-js/src/core/ResultPoint.d.ts +34 -0
- package/lib/lib/zxing-js/src/core/ResultPointCallback.d.ts +11 -0
- package/lib/lib/zxing-js/src/core/UniversalLuminanceSource.d.ts +46 -0
- package/lib/lib/zxing-js/src/core/UnsupportedOperationException.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/Writer.d.ts +30 -0
- package/lib/lib/zxing-js/src/core/WriterException.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/common/BitArray.d.ts +111 -0
- package/lib/lib/zxing-js/src/core/common/BitMatrix.d.ts +98 -0
- package/lib/lib/zxing-js/src/core/common/BitSource.d.ts +38 -0
- package/lib/lib/zxing-js/src/core/common/CharacterSetECI.d.ts +89 -0
- package/lib/lib/zxing-js/src/core/common/DecoderResult.d.ts +64 -0
- package/lib/lib/zxing-js/src/core/common/DefaultGridSampler.d.ts +10 -0
- package/lib/lib/zxing-js/src/core/common/DetectorResult.d.ts +16 -0
- package/lib/lib/zxing-js/src/core/common/ECIEncoderSet.d.ts +37 -0
- package/lib/lib/zxing-js/src/core/common/ECIInput.d.ts +79 -0
- package/lib/lib/zxing-js/src/core/common/GlobalHistogramBinarizer.d.ts +29 -0
- package/lib/lib/zxing-js/src/core/common/GridSampler.d.ts +36 -0
- package/lib/lib/zxing-js/src/core/common/GridSamplerInstance.d.ts +18 -0
- package/lib/lib/zxing-js/src/core/common/HybridBinarizer.d.ts +54 -0
- package/lib/lib/zxing-js/src/core/common/MinimalECIInput.d.ts +123 -0
- package/lib/lib/zxing-js/src/core/common/PerspectiveTransform.d.ts +26 -0
- package/lib/lib/zxing-js/src/core/common/StringUtils.d.ts +48 -0
- package/lib/lib/zxing-js/src/core/common/detector/CornerDetector.d.ts +35 -0
- package/lib/lib/zxing-js/src/core/common/detector/MathUtils.d.ts +36 -0
- package/lib/lib/zxing-js/src/core/common/detector/WhiteRectangleDetector.d.ts +71 -0
- package/lib/lib/zxing-js/src/core/common/reedsolomon/AbstractGenericGF.d.ts +34 -0
- package/lib/lib/zxing-js/src/core/common/reedsolomon/AbstractGenericGFPoly.d.ts +36 -0
- package/lib/lib/zxing-js/src/core/common/reedsolomon/GenericGF.d.ts +58 -0
- package/lib/lib/zxing-js/src/core/common/reedsolomon/GenericGFPoly.d.ts +47 -0
- package/lib/lib/zxing-js/src/core/common/reedsolomon/ReedSolomonDecoder.d.ts +40 -0
- package/lib/lib/zxing-js/src/core/common/reedsolomon/ReedSolomonEncoder.d.ts +41 -0
- package/lib/lib/zxing-js/src/core/qrcode/QRCodeReader.d.ts +35 -0
- package/lib/lib/zxing-js/src/core/qrcode/QRCodeWriter.d.ts +13 -0
- package/lib/lib/zxing-js/src/core/qrcode/decoder/BitMatrixParser.d.ts +58 -0
- package/lib/lib/zxing-js/src/core/qrcode/decoder/DataBlock.d.ts +28 -0
- package/lib/lib/zxing-js/src/core/qrcode/decoder/DataMask.d.ts +36 -0
- package/lib/lib/zxing-js/src/core/qrcode/decoder/DecodedBitStreamParser.d.ts +30 -0
- package/lib/lib/zxing-js/src/core/qrcode/decoder/Decoder.d.ts +44 -0
- package/lib/lib/zxing-js/src/core/qrcode/decoder/ECB.d.ts +12 -0
- package/lib/lib/zxing-js/src/core/qrcode/decoder/ECBlocks.d.ts +16 -0
- package/lib/lib/zxing-js/src/core/qrcode/decoder/ErrorCorrectionLevel.d.ts +38 -0
- package/lib/lib/zxing-js/src/core/qrcode/decoder/FormatInformation.d.ts +33 -0
- package/lib/lib/zxing-js/src/core/qrcode/decoder/Mode.d.ts +56 -0
- package/lib/lib/zxing-js/src/core/qrcode/decoder/QRCodeDecoderMetaData.d.ts +21 -0
- package/lib/lib/zxing-js/src/core/qrcode/decoder/Version.d.ts +44 -0
- package/lib/lib/zxing-js/src/core/qrcode/detector/AlignmentPattern.d.ts +21 -0
- package/lib/lib/zxing-js/src/core/qrcode/detector/AlignmentPatternFinder.d.ts +82 -0
- package/lib/lib/zxing-js/src/core/qrcode/detector/Detector.d.ts +87 -0
- package/lib/lib/zxing-js/src/core/qrcode/detector/FinderPattern.d.ts +26 -0
- package/lib/lib/zxing-js/src/core/qrcode/detector/FinderPatternFinder.d.ts +114 -0
- package/lib/lib/zxing-js/src/core/qrcode/detector/FinderPatternInfo.d.ts +16 -0
- package/lib/lib/zxing-js/src/core/qrcode/encoder/BlockPair.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/qrcode/encoder/ByteMatrix.d.ts +24 -0
- package/lib/lib/zxing-js/src/core/qrcode/encoder/Encoder.d.ts +85 -0
- package/lib/lib/zxing-js/src/core/qrcode/encoder/MaskUtil.d.ts +47 -0
- package/lib/lib/zxing-js/src/core/qrcode/encoder/MatrixUtil.d.ts +37 -0
- package/lib/lib/zxing-js/src/core/qrcode/encoder/QRCode.d.ts +29 -0
- package/lib/lib/zxing-js/src/core/util/Arrays.d.ts +45 -0
- package/lib/lib/zxing-js/src/core/util/ByteArrayOutputStream.d.ts +174 -0
- package/lib/lib/zxing-js/src/core/util/Charset.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/util/Collections.d.ts +11 -0
- package/lib/lib/zxing-js/src/core/util/Float.d.ts +14 -0
- package/lib/lib/zxing-js/src/core/util/Formatter.d.ts +28 -0
- package/lib/lib/zxing-js/src/core/util/Integer.d.ts +19 -0
- package/lib/lib/zxing-js/src/core/util/Long.d.ts +12 -0
- package/lib/lib/zxing-js/src/core/util/OutputStream.d.ts +106 -0
- package/lib/lib/zxing-js/src/core/util/StandardCharsets.d.ts +7 -0
- package/lib/lib/zxing-js/src/core/util/StringBuilder.d.ts +21 -0
- package/lib/lib/zxing-js/src/core/util/StringEncoding.d.ts +51 -0
- package/lib/lib/zxing-js/src/core/util/System.d.ts +10 -0
- package/lib/lib/zxing-js/src/customTypings.d.ts +16 -0
- package/lib/lib/zxing-js/src/index.d.ts +5 -0
- package/lib/lib/zxing-js/src/node.d.ts +1 -0
- package/lib/license/LicenseManager.d.ts +69 -0
- package/lib/license/LicenseManagerNode.d.ts +64 -0
- package/lib/node.d.ts +37 -0
- package/lib/options-demo.d.ts +239 -0
- package/lib/plugins/QRBorderHelpers.d.ts +32 -0
- package/lib/plugins/QRBorderPlugin.d.ts +35 -0
- package/lib/plugins/QRValidatorZbar.d.ts +38 -0
- package/lib/plugins/QRValidatorZbarNode.d.ts +60 -0
- package/lib/plugins/QRValidatorZbarNodeSharp.d.ts +83 -0
- package/lib/qr-code-js-node.js +1 -0
- package/lib/qr-code-js.js +1 -0
- package/lib/templates/borders-inner-outter.d.ts +129 -0
- package/lib/templates/borders-inner-scale-offset.d.ts +497 -0
- package/lib/templates/borders-inner.d.ts +129 -0
- package/lib/templates/borders-no-license.d.ts +129 -0
- package/lib/templates/borders-outter.d.ts +129 -0
- package/lib/templates/borders-text-auto-curved.d.ts +129 -0
- package/lib/templates/borders-text-full-curved.d.ts +133 -0
- package/lib/templates/borders.d.ts +129 -0
- package/lib/templates/scales.d.ts +130 -0
- package/lib/templates/scan-validators/index.d.ts +1 -0
- package/lib/templates/scan-validators/tests/cases/basic-inverted.d.ts +9 -0
- package/lib/templates/scan-validators/tests/cases/basic-no-license.d.ts +3 -0
- package/lib/templates/scan-validators/tests/cases/basic.d.ts +3 -0
- package/lib/templates/scan-validators/tests/cases/colors-inverted.d.ts +2 -0
- package/lib/templates/scan-validators/tests/cases/colors.d.ts +58 -0
- package/lib/templates/scan-validators/tests/cases/out-of-borders-inverted.d.ts +9 -0
- package/lib/templates/scan-validators/tests/cases/out-of-borders.d.ts +9 -0
- package/lib/templates/scan-validators/tests/cases/position-inverted.d.ts +9 -0
- package/lib/templates/scan-validators/tests/cases/position.d.ts +3 -0
- package/lib/templates/scan-validators/tests/index.d.ts +27 -0
- package/lib/tools/browser-image-tools.d.ts +7 -0
- package/lib/tools/browser-utils.d.ts +18 -0
- package/lib/types/helper.d.ts +23 -0
- package/lib/utils/canvas-options.d.ts +7 -0
- package/lib/utils/color.d.ts +4 -0
- package/lib/utils/gradient.d.ts +26 -0
- package/lib/utils/image.d.ts +16 -0
- package/lib/utils/merge.d.ts +5 -0
- package/lib/utils/options.d.ts +220 -0
- package/lib/utils/qrcode.d.ts +8 -0
- package/lib/utils/scan-validator-node.d.ts +15 -0
- package/lib/utils/scan-validators/abstract-scan-validator.d.ts +43 -0
- package/lib/utils/scan-validators/zbar-scan-validator.d.ts +8 -0
- package/lib/utils/scan-validators/zxing-canvas-scan-validator.d.ts +10 -0
- package/lib/utils/scan-validators/zxing-scan-validator.d.ts +8 -0
- package/lib/utils/svg.d.ts +2 -0
- package/lib/utils/token-validator.d.ts +19 -0
- package/package.json +80 -0
@@ -0,0 +1,1592 @@
|
|
1
|
+
## QRCode.js Documentation
|
2
|
+
<a id="start"></a>
|
3
|
+
|
4
|
+
## Introduction
|
5
|
+
|
6
|
+
QRCode.js is a professional JavaScript/TypeScript library for creating customized QR codes, offering a blend of simplicity and sophistication. With versatile styling options—dot shapes, colors, gradients, embedded images, borders, and text—it enables you to design unique, visually appealing QR codes that work flawlessly with standard scanners. QRCode.js is part of QR-Platform: All-in-One QR Codes Management Solution.
|
7
|
+
|
8
|
+
|
9
|
+
This documentation provides a comprehensive overview of all available options to help you create the perfect QR code for your needs.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
```bash
|
14
|
+
# Using npm
|
15
|
+
npm install @qr-platform/qr-code.js
|
16
|
+
|
17
|
+
# Using yarn
|
18
|
+
yarn add @qr-platform/qr-code.js
|
19
|
+
|
20
|
+
# Using pnpm
|
21
|
+
pnpm add @qr-platform/qr-code.js
|
22
|
+
```
|
23
|
+
|
24
|
+
## Basic Usage
|
25
|
+
|
26
|
+
```typescript
|
27
|
+
import { QRCodeJs } from '@qr-platform/qr-code.js';
|
28
|
+
|
29
|
+
// Create a basic QR code
|
30
|
+
const qrCode = new QRCodeJs({
|
31
|
+
data: 'https://example.com',
|
32
|
+
});
|
33
|
+
|
34
|
+
// Render the QR code to a container
|
35
|
+
qrCode.append(document.getElementById('qr-container'));
|
36
|
+
```
|
37
|
+
|
38
|
+
## Core Options
|
39
|
+
|
40
|
+
### `data`
|
41
|
+
|
42
|
+
- **Purpose**: The content to be encoded in the QR code
|
43
|
+
- **Type**: `string`
|
44
|
+
- **Required**: Yes
|
45
|
+
- **Example**: `'https://example.com'`
|
46
|
+
|
47
|
+
### `shape`
|
48
|
+
|
49
|
+
- **Purpose**: Overall shape of the QR code
|
50
|
+
- **Type**: `ShapeType` enum
|
51
|
+
- **Default**: `'square'`
|
52
|
+
- **Possible values**: `'square'`, `'circle'`
|
53
|
+
- **Example**:
|
54
|
+
```typescript
|
55
|
+
shape: 'circle'
|
56
|
+
```
|
57
|
+
|
58
|
+
### `margin`
|
59
|
+
|
60
|
+
- **Purpose**: Empty space around the QR code (in pixels)
|
61
|
+
- **Type**: `number`
|
62
|
+
- **Default**: `0`
|
63
|
+
- **Example**:
|
64
|
+
```typescript
|
65
|
+
margin: 20
|
66
|
+
```
|
67
|
+
|
68
|
+
### `isResponsive`
|
69
|
+
|
70
|
+
- **Purpose**: Allows the QR code SVG to resize dynamically based on its container size. If `false`, fixed `width` and `height` attributes are set on the SVG.
|
71
|
+
- **Type**: `boolean`
|
72
|
+
- **Default**: `false`
|
73
|
+
- **Example**:
|
74
|
+
```typescript
|
75
|
+
isResponsive: true
|
76
|
+
```
|
77
|
+
|
78
|
+
### `qrOptions`
|
79
|
+
|
80
|
+
Options that affect the QR code generation algorithm.
|
81
|
+
|
82
|
+
#### `typeNumber`
|
83
|
+
|
84
|
+
- **Purpose**: Specifies the QR code version (size and capacity)
|
85
|
+
- **Type**: `TypeNumber` (0-40)
|
86
|
+
- **Default**: `0` (auto-determine based on content)
|
87
|
+
- **Example**:
|
88
|
+
```typescript
|
89
|
+
qrOptions: {
|
90
|
+
typeNumber: 4
|
91
|
+
}
|
92
|
+
```
|
93
|
+
|
94
|
+
#### `mode`
|
95
|
+
|
96
|
+
- **Purpose**: Encoding mode for the QR data
|
97
|
+
- **Type**: `Mode` enum
|
98
|
+
- **Default**: Auto-detected based on content
|
99
|
+
- **Possible values**: `'numeric'`, `'alphanumeric'`, `'byte'`, `'kanji'`, `'unicode'`
|
100
|
+
- **Example**:
|
101
|
+
```typescript
|
102
|
+
qrOptions: {
|
103
|
+
mode: 'alphanumeric'
|
104
|
+
}
|
105
|
+
```
|
106
|
+
|
107
|
+
#### `errorCorrectionLevel`
|
108
|
+
|
109
|
+
- **Purpose**: Determines error correction capability
|
110
|
+
- **Type**: `ErrorCorrectionLevel` enum
|
111
|
+
- **Default**: `'Q'`
|
112
|
+
- **Possible values**:
|
113
|
+
- `'L'`: 7% error recovery
|
114
|
+
- `'M'`: 15% error recovery
|
115
|
+
- `'Q'`: 25% error recovery
|
116
|
+
- `'H'`: 30% error recovery
|
117
|
+
- **Example**:
|
118
|
+
```typescript
|
119
|
+
qrOptions: {
|
120
|
+
errorCorrectionLevel: 'H'
|
121
|
+
}
|
122
|
+
```
|
123
|
+
|
124
|
+
## Layout Options
|
125
|
+
|
126
|
+
Options controlling the positioning and scaling of the QR code within its container.
|
127
|
+
|
128
|
+
### `scale`
|
129
|
+
|
130
|
+
- **Purpose**: Scales the QR code size relative to its container or border. Useful for adjusting size within borders.
|
131
|
+
- **Type**: `number` (0 to 1.5)
|
132
|
+
- **Default**: `1`
|
133
|
+
- **Example**:
|
134
|
+
```typescript
|
135
|
+
scale: 0.8 // Make QR code 80% of available space
|
136
|
+
```
|
137
|
+
|
138
|
+
### `offset`
|
139
|
+
|
140
|
+
- **Purpose**: Applies a vertical offset (positive moves down, negative moves up) to the QR code relative to the center. Useful for fine-tuning position, especially with borders.
|
141
|
+
- **Type**: `number`
|
142
|
+
- **Default**: `0`
|
143
|
+
- **Example**:
|
144
|
+
```typescript
|
145
|
+
offset: -10 // Move QR code 10px up
|
146
|
+
```
|
147
|
+
|
148
|
+
### `verticalOffset`
|
149
|
+
|
150
|
+
- **Purpose**: Applies a vertical offset (positive moves down, negative moves up) to the QR code, independent of other calculations.
|
151
|
+
- **Type**: `number`
|
152
|
+
- **Default**: `0`
|
153
|
+
- **Example**:
|
154
|
+
```typescript
|
155
|
+
verticalOffset: 5 // Move QR code 5px down
|
156
|
+
```
|
157
|
+
|
158
|
+
### `horizontalOffset`
|
159
|
+
|
160
|
+
- **Purpose**: Applies a horizontal offset (positive moves right, negative moves left) to the QR code, independent of other calculations.
|
161
|
+
- **Type**: `number`
|
162
|
+
- **Default**: `0`
|
163
|
+
- **Example**:
|
164
|
+
```typescript
|
165
|
+
horizontalOffset: -5 // Move QR code 5px left
|
166
|
+
```
|
167
|
+
|
168
|
+
## Styling Options
|
169
|
+
|
170
|
+
### Dots (`dotsOptions`)
|
171
|
+
|
172
|
+
Controls the appearance of individual QR code dots.
|
173
|
+
|
174
|
+
#### `type`
|
175
|
+
|
176
|
+
- **Purpose**: Shape of the dots in the QR code
|
177
|
+
- **Type**: `DotType` enum
|
178
|
+
- **Default**: `'square'`
|
179
|
+
- **Possible values**:
|
180
|
+
- `'dot'`: Round dots
|
181
|
+
- `'square'`: Square dots
|
182
|
+
- `'rounded'`: Slightly rounded squares
|
183
|
+
- `'extraRounded'`: More rounded squares
|
184
|
+
- `'classy'`: Dots with a distinctive classy pattern
|
185
|
+
- `'classyRounded'`: Classy dots with rounded corners
|
186
|
+
- `'verticalLine'`: Vertical line pattern
|
187
|
+
- `'horizontalLine'`: Horizontal line pattern
|
188
|
+
- `'randomDot'`: Randomized dot pattern
|
189
|
+
- `'smallSquare'`: Smaller square dots
|
190
|
+
- `'tinySquare'`: Very small square dots
|
191
|
+
- `'star'`: Star-shaped dots
|
192
|
+
- `'plus'`: Plus-shaped dots
|
193
|
+
- `'diamond'`: Diamond-shaped dots
|
194
|
+
- **Example**:
|
195
|
+
```typescript
|
196
|
+
dotsOptions: {
|
197
|
+
type: 'rounded'
|
198
|
+
}
|
199
|
+
```
|
200
|
+
|
201
|
+
#### `color`
|
202
|
+
|
203
|
+
- **Purpose**: Color of the dots
|
204
|
+
- **Type**: `string` (CSS color, hex, rgb, rgba)
|
205
|
+
- **Default**: `'#000000'`
|
206
|
+
- **Example**:
|
207
|
+
```typescript
|
208
|
+
dotsOptions: {
|
209
|
+
color: '#FF5733'
|
210
|
+
}
|
211
|
+
```
|
212
|
+
|
213
|
+
#### `size`
|
214
|
+
|
215
|
+
- **Purpose**: Size of the dots in pixels
|
216
|
+
- **Type**: `number`
|
217
|
+
- **Default**: `10`
|
218
|
+
- **Example**:
|
219
|
+
```typescript
|
220
|
+
dotsOptions: {
|
221
|
+
size: 12
|
222
|
+
}
|
223
|
+
```
|
224
|
+
|
225
|
+
#### `gradient`
|
226
|
+
|
227
|
+
- **Purpose**: Apply a gradient fill to the dots
|
228
|
+
- **Type**: `Gradient` object (see [Gradients](#gradients))
|
229
|
+
- **Default**: `undefined`
|
230
|
+
- **Example**:
|
231
|
+
```typescript
|
232
|
+
dotsOptions: {
|
233
|
+
gradient: {
|
234
|
+
type: 'linear',
|
235
|
+
rotation: Math.PI / 4,
|
236
|
+
colorStops: [{ offset: 0, color: 'blue' }, { offset: 1, color: 'red' }]
|
237
|
+
}
|
238
|
+
}
|
239
|
+
```
|
240
|
+
|
241
|
+
### Corner Squares (`cornersSquareOptions`)
|
242
|
+
|
243
|
+
These options override `dotsOptions` for the three large corner squares of the QR code.
|
244
|
+
|
245
|
+
#### `type`
|
246
|
+
|
247
|
+
- **Purpose**: Shape of the corner squares
|
248
|
+
- **Type**: `CornerSquareType` enum
|
249
|
+
- **Default**: Inherits from `dotsOptions.type` or uses `'dot'`
|
250
|
+
- **Possible values**:
|
251
|
+
- `'dot'`: Round corner squares
|
252
|
+
- `'square'`: Square corner squares
|
253
|
+
- `'rounded'`: Rounded corner squares
|
254
|
+
- `'classy'`: Classy corner squares
|
255
|
+
- `'outpoint'`: Corner squares with outward points
|
256
|
+
- `'inpoint'`: Corner squares with inward points
|
257
|
+
- **Example**:
|
258
|
+
```typescript
|
259
|
+
cornersSquareOptions: {
|
260
|
+
type: 'outpoint'
|
261
|
+
}
|
262
|
+
```
|
263
|
+
|
264
|
+
#### `color`
|
265
|
+
|
266
|
+
- **Purpose**: Color of the corner squares
|
267
|
+
- **Type**: `string` (CSS color, hex, rgb, rgba)
|
268
|
+
- **Default**: Inherits from `dotsOptions.color` or uses `'#000000'`
|
269
|
+
- **Example**:
|
270
|
+
```typescript
|
271
|
+
cornersSquareOptions: {
|
272
|
+
color: '#0000FF'
|
273
|
+
}
|
274
|
+
```
|
275
|
+
|
276
|
+
#### `gradient`
|
277
|
+
|
278
|
+
- **Purpose**: Apply a gradient fill to the corner squares (overrides `dotsOptions.gradient`)
|
279
|
+
- **Type**: `Gradient` object (see [Gradients](#gradients))
|
280
|
+
- **Default**: `undefined`
|
281
|
+
- **Example**:
|
282
|
+
```typescript
|
283
|
+
cornersSquareOptions: {
|
284
|
+
gradient: {
|
285
|
+
type: 'radial',
|
286
|
+
colorStops: [{ offset: 0, color: 'green' }, { offset: 1, color: 'yellow' }]
|
287
|
+
}
|
288
|
+
}
|
289
|
+
```
|
290
|
+
|
291
|
+
### Corner Dots (`cornersDotOptions`)
|
292
|
+
|
293
|
+
These options override `cornersSquareOptions` for the smaller dots within the corner squares.
|
294
|
+
|
295
|
+
#### `type`
|
296
|
+
|
297
|
+
- **Purpose**: Shape of the corner dots
|
298
|
+
- **Type**: `CornerDotType` enum
|
299
|
+
- **Default**: Inherits from `cornersSquareOptions.type` or uses `'dot'`
|
300
|
+
- **Possible values**:
|
301
|
+
- `'dot'`: Round corner dots
|
302
|
+
- `'square'`: Square corner dots
|
303
|
+
- `'heart'`: Heart-shaped corner dots
|
304
|
+
- `'rounded'`: Rounded corner dots
|
305
|
+
- `'classy'`: Classy corner dots
|
306
|
+
- `'outpoint'`: Corner dots with outward points
|
307
|
+
- `'inpoint'`: Corner dots with inward points
|
308
|
+
- **Example**:
|
309
|
+
```typescript
|
310
|
+
cornersDotOptions: {
|
311
|
+
type: 'heart'
|
312
|
+
}
|
313
|
+
```
|
314
|
+
|
315
|
+
#### `color`
|
316
|
+
|
317
|
+
- **Purpose**: Color of the corner dots
|
318
|
+
- **Type**: `string` (CSS color, hex, rgb, rgba)
|
319
|
+
- **Default**: Inherits from `cornersSquareOptions.color` or uses `'#000000'`
|
320
|
+
- **Example**:
|
321
|
+
```typescript
|
322
|
+
cornersDotOptions: {
|
323
|
+
color: '#FF0000'
|
324
|
+
}
|
325
|
+
```
|
326
|
+
|
327
|
+
#### `gradient`
|
328
|
+
|
329
|
+
- **Purpose**: Apply a gradient fill to the corner dots (overrides `cornersSquareOptions.gradient`)
|
330
|
+
- **Type**: `Gradient` object (see [Gradients](#gradients))
|
331
|
+
- **Default**: `undefined`
|
332
|
+
- **Example**:
|
333
|
+
```typescript
|
334
|
+
cornersDotOptions: {
|
335
|
+
gradient: {
|
336
|
+
type: 'linear',
|
337
|
+
rotation: 0,
|
338
|
+
colorStops: [{ offset: 0, color: 'orange' }, { offset: 1, color: 'purple' }]
|
339
|
+
}
|
340
|
+
}
|
341
|
+
```
|
342
|
+
|
343
|
+
### Background (`backgroundOptions`)
|
344
|
+
|
345
|
+
Controls the QR code background.
|
346
|
+
|
347
|
+
- **Purpose**: Configures the background of the QR code
|
348
|
+
- **Type**: `object` or `false` to disable the background
|
349
|
+
- **Default**: `{ color: '#FFFFFF' }`
|
350
|
+
|
351
|
+
#### `color`
|
352
|
+
|
353
|
+
- **Purpose**: Background color
|
354
|
+
- **Type**: `string` (CSS color, hex, rgb, rgba)
|
355
|
+
- **Default**: `'#FFFFFF'`
|
356
|
+
- **Example**:
|
357
|
+
```typescript
|
358
|
+
backgroundOptions: {
|
359
|
+
color: '#F5F5F5'
|
360
|
+
}
|
361
|
+
```
|
362
|
+
|
363
|
+
#### `round`
|
364
|
+
|
365
|
+
- **Purpose**: Rounds the corners of the background (0-1 value or percentage)
|
366
|
+
- **Type**: `number` or `string`
|
367
|
+
- **Default**: `0`
|
368
|
+
- **Example**:
|
369
|
+
```typescript
|
370
|
+
backgroundOptions: {
|
371
|
+
round: 0.5
|
372
|
+
}
|
373
|
+
```
|
374
|
+
|
375
|
+
#### `gradient`
|
376
|
+
|
377
|
+
- **Purpose**: Apply a gradient fill to the background
|
378
|
+
- **Type**: `Gradient` object (see [Gradients](#gradients))
|
379
|
+
- **Default**: `undefined`
|
380
|
+
- **Example**:
|
381
|
+
```typescript
|
382
|
+
backgroundOptions: {
|
383
|
+
gradient: {
|
384
|
+
type: 'linear',
|
385
|
+
rotation: Math.PI / 2,
|
386
|
+
colorStops: [{ offset: 0, color: '#eee' }, { offset: 1, color: '#ccc' }]
|
387
|
+
}
|
388
|
+
}
|
389
|
+
```
|
390
|
+
|
391
|
+
## Image Embedding
|
392
|
+
|
393
|
+
### `image`
|
394
|
+
|
395
|
+
- **Purpose**: URL, Buffer, or Blob of an image to embed in the QR code
|
396
|
+
- **Type**: `string | Buffer | Blob`
|
397
|
+
- **Example**:
|
398
|
+
```typescript
|
399
|
+
image: 'https://example.com/logo.png'
|
400
|
+
```
|
401
|
+
|
402
|
+
### `imageOptions`
|
403
|
+
|
404
|
+
Options for the embedded image.
|
405
|
+
|
406
|
+
#### `mode`
|
407
|
+
|
408
|
+
- **Purpose**: How the image is embedded in the QR code
|
409
|
+
- **Type**: `ImageMode` enum
|
410
|
+
- **Default**: `'center'`
|
411
|
+
- **Possible values**:
|
412
|
+
- `'center'`: Image placed in the center, QR code dots reflow around it
|
413
|
+
- `'overlay'`: Image placed on top of the QR code
|
414
|
+
- `'background'`: Image used as a background with dots drawn over it
|
415
|
+
- **Example**:
|
416
|
+
```typescript
|
417
|
+
imageOptions: {
|
418
|
+
mode: 'center'
|
419
|
+
}
|
420
|
+
```
|
421
|
+
|
422
|
+
#### `imageSize`
|
423
|
+
|
424
|
+
- **Purpose**: Relative size of the image (0-1)
|
425
|
+
- **Type**: `number`
|
426
|
+
- **Default**: `0.4`
|
427
|
+
- **Example**:
|
428
|
+
```typescript
|
429
|
+
imageOptions: {
|
430
|
+
imageSize: 0.5
|
431
|
+
}
|
432
|
+
```
|
433
|
+
|
434
|
+
#### `margin`
|
435
|
+
|
436
|
+
- **Purpose**: Margin around the image in dot units
|
437
|
+
- **Type**: `number`
|
438
|
+
- **Default**: `0`
|
439
|
+
- **Example**:
|
440
|
+
```typescript
|
441
|
+
imageOptions: {
|
442
|
+
margin: 2
|
443
|
+
}
|
444
|
+
```
|
445
|
+
|
446
|
+
#### `crossOrigin`
|
447
|
+
|
448
|
+
- **Purpose**: CORS setting for the image
|
449
|
+
- **Type**: `string`
|
450
|
+
- **Default**: `undefined`
|
451
|
+
- **Example**:
|
452
|
+
```typescript
|
453
|
+
imageOptions: {
|
454
|
+
crossOrigin: 'anonymous'
|
455
|
+
}
|
456
|
+
```
|
457
|
+
|
458
|
+
#### `fill`
|
459
|
+
|
460
|
+
- **Purpose**: Fill color for transparent areas in the image
|
461
|
+
- **Type**: `object`
|
462
|
+
- **Default**: `{ color: 'rgba(255,255,255,1)' }`
|
463
|
+
- **Properties**:
|
464
|
+
- `color`: A solid color fill (`string`)
|
465
|
+
- `gradient`: A gradient fill (`Gradient` object, see [Gradients](#gradients))
|
466
|
+
- **Example (Solid Color)**:
|
467
|
+
```typescript
|
468
|
+
imageOptions: {
|
469
|
+
fill: {
|
470
|
+
color: 'rgba(255,255,255,0.75)'
|
471
|
+
}
|
472
|
+
}
|
473
|
+
```
|
474
|
+
- **Example (Gradient Fill)**:
|
475
|
+
```typescript
|
476
|
+
imageOptions: {
|
477
|
+
fill: {
|
478
|
+
gradient: {
|
479
|
+
type: 'radial',
|
480
|
+
colorStops: [{ offset: 0, color: 'rgba(255,255,255,1)' }, { offset: 1, color: 'rgba(255,255,255,0)' }]
|
481
|
+
}
|
482
|
+
}
|
483
|
+
}
|
484
|
+
```
|
485
|
+
|
486
|
+
## Gradients
|
487
|
+
|
488
|
+
Gradients can be applied to multiple elements: `dotsOptions`, `cornersSquareOptions`, `cornersDotOptions`, `backgroundOptions`, and `imageOptions.fill`.
|
489
|
+
|
490
|
+
### Gradient Structure
|
491
|
+
|
492
|
+
- **Type**: `object`
|
493
|
+
- **Properties**:
|
494
|
+
- `type`: Type of gradient (`'linear'` or `'radial'`)
|
495
|
+
- `rotation`: Rotation of gradient in radians (for linear gradients)
|
496
|
+
- `colorStops`: Array of color stop objects with `offset` (0-1) and `color` properties
|
497
|
+
|
498
|
+
### Example
|
499
|
+
|
500
|
+
```typescript
|
501
|
+
{
|
502
|
+
dotsOptions: {
|
503
|
+
gradient: {
|
504
|
+
type: 'linear',
|
505
|
+
rotation: Math.PI / 4, // 45 degrees
|
506
|
+
colorStops: [
|
507
|
+
{ offset: 0, color: '#8F00FF' }, // Start color
|
508
|
+
{ offset: 1, color: '#0080FF' } // End color
|
509
|
+
]
|
510
|
+
}
|
511
|
+
}
|
512
|
+
}
|
513
|
+
```
|
514
|
+
|
515
|
+
## Borders
|
516
|
+
|
517
|
+
### Free vs. Premium Features
|
518
|
+
|
519
|
+
QRCode.js provides border features in both the free and premium versions, with some important differences:
|
520
|
+
|
521
|
+
- **Free Version Borders**:
|
522
|
+
- Basic border features are available but will automatically include "QR-Platform" branding text in the bottom border
|
523
|
+
- This branding cannot be removed or customized without a license
|
524
|
+
- Basic border styling like color and thickness is supported
|
525
|
+
|
526
|
+
- **Premium Version Borders** (requires license):
|
527
|
+
- No QR-Platform branding (can use custom text or no text)
|
528
|
+
- Full control over all sides of the border
|
529
|
+
- Advanced border features (inner borders, outer borders, custom text)
|
530
|
+
- Fine-grained control over border appearance
|
531
|
+
|
532
|
+
### `borderOptions`
|
533
|
+
|
534
|
+
Options for adding decorative borders around the QR code.
|
535
|
+
|
536
|
+
#### `hasBorder`
|
537
|
+
|
538
|
+
- **Purpose**: Master switch to enable/disable borders
|
539
|
+
- **Type**: `boolean`
|
540
|
+
- **Example**:
|
541
|
+
```typescript
|
542
|
+
borderOptions: {
|
543
|
+
hasBorder: true
|
544
|
+
}
|
545
|
+
```
|
546
|
+
|
547
|
+
#### `thickness`
|
548
|
+
|
549
|
+
- **Purpose**: Thickness of the main border in pixels
|
550
|
+
- **Type**: `number`
|
551
|
+
- **Example**:
|
552
|
+
```typescript
|
553
|
+
borderOptions: {
|
554
|
+
thickness: 50
|
555
|
+
}
|
556
|
+
```
|
557
|
+
|
558
|
+
#### `color`
|
559
|
+
|
560
|
+
- **Purpose**: Color of the main border
|
561
|
+
- **Type**: `string` (CSS color, hex, rgb, rgba)
|
562
|
+
- **Default**: `'#000000'`
|
563
|
+
- **Example**:
|
564
|
+
```typescript
|
565
|
+
borderOptions: {
|
566
|
+
color: 'blue'
|
567
|
+
}
|
568
|
+
```
|
569
|
+
|
570
|
+
#### `radius`
|
571
|
+
|
572
|
+
- **Purpose**: Corner rounding of the border
|
573
|
+
- **Type**: `string` (px or %)
|
574
|
+
- **Default**: `'0%'`
|
575
|
+
- **Example**:
|
576
|
+
```typescript
|
577
|
+
borderOptions: {
|
578
|
+
radius: '40%'
|
579
|
+
}
|
580
|
+
```
|
581
|
+
|
582
|
+
#### `noBorderThickness` (Premium)
|
583
|
+
|
584
|
+
- **Purpose**: Thickness to use for a border side if its decoration is disabled (e.g., text is not shown). Useful for maintaining alignment.
|
585
|
+
- **Type**: `number`
|
586
|
+
- **Default**: `borderOptions.thickness / 4`
|
587
|
+
- **Example**:
|
588
|
+
```typescript
|
589
|
+
borderOptions: {
|
590
|
+
noBorderThickness: 5
|
591
|
+
}
|
592
|
+
```
|
593
|
+
|
594
|
+
#### `background` (Premium)
|
595
|
+
|
596
|
+
- **Purpose**: Background color specifically for the border area itself.
|
597
|
+
- **Type**: `string` (CSS color, hex, rgb, rgba)
|
598
|
+
- **Default**: `undefined`
|
599
|
+
- **Example**:
|
600
|
+
```typescript
|
601
|
+
borderOptions: {
|
602
|
+
background: '#DDDDDD'
|
603
|
+
}
|
604
|
+
```
|
605
|
+
|
606
|
+
#### `inner` (Premium)
|
607
|
+
|
608
|
+
- **Purpose**: Options for scaling/offsetting the inner content area
|
609
|
+
- **Type**: `object`
|
610
|
+
- **Properties**:
|
611
|
+
- `radius`: Corner rounding of the inner border (string)
|
612
|
+
- `scale`: Scale factor for the inner content (number, 0-1.5)
|
613
|
+
- `horizontalOffset`: Horizontal offset of the inner content (number)
|
614
|
+
- `verticalOffset`: Vertical offset of the inner content (number)
|
615
|
+
- **Example**:
|
616
|
+
```typescript
|
617
|
+
borderOptions: {
|
618
|
+
inner: {
|
619
|
+
radius: '10%',
|
620
|
+
scale: 0.8,
|
621
|
+
horizontalOffset: -15,
|
622
|
+
verticalOffset: 10
|
623
|
+
}
|
624
|
+
}
|
625
|
+
```
|
626
|
+
|
627
|
+
#### `borderOuter` (Premium)
|
628
|
+
|
629
|
+
- **Purpose**: Options for an additional border outside the main one
|
630
|
+
- **Type**: `object`
|
631
|
+
- **Properties**:
|
632
|
+
- `color`: Color of the outer border (string)
|
633
|
+
- `thickness`: Thickness of the outer border (number)
|
634
|
+
- **Example**:
|
635
|
+
```typescript
|
636
|
+
borderOptions: {
|
637
|
+
borderOuter: {
|
638
|
+
color: '#002683',
|
639
|
+
thickness: 10
|
640
|
+
}
|
641
|
+
}
|
642
|
+
```
|
643
|
+
|
644
|
+
#### `borderInner` (Premium)
|
645
|
+
|
646
|
+
- **Purpose**: Options for an additional border inside the main one
|
647
|
+
- **Type**: `object`
|
648
|
+
- **Properties**:
|
649
|
+
- `color`: Color of the inner border (string)
|
650
|
+
- `thickness`: Thickness of the inner border (number)
|
651
|
+
- **Example**:
|
652
|
+
```typescript
|
653
|
+
borderOptions: {
|
654
|
+
borderInner: {
|
655
|
+
color: 'yellow',
|
656
|
+
thickness: 5
|
657
|
+
}
|
658
|
+
}
|
659
|
+
```
|
660
|
+
|
661
|
+
#### `decorations` (Premium)
|
662
|
+
|
663
|
+
- **Purpose**: Add text or images to specific sides of the border
|
664
|
+
- **Type**: `object`
|
665
|
+
- **Properties**: Configuration for each side (`top`, `right`, `bottom`, `left`)
|
666
|
+
- **Note**: In the free version, the bottom border will always display "QR-Platform" branding regardless of your settings
|
667
|
+
- **Example**:
|
668
|
+
```typescript
|
669
|
+
borderOptions: {
|
670
|
+
decorations: {
|
671
|
+
top: {
|
672
|
+
disabled: false,
|
673
|
+
enableText: true,
|
674
|
+
offset: 0,
|
675
|
+
curveAdjustment: 0,
|
676
|
+
curveDisabled: false,
|
677
|
+
curveRadius: '50%',
|
678
|
+
type: 'text',
|
679
|
+
value: 'SCAN ME',
|
680
|
+
style: {
|
681
|
+
fontFace: 'Helvetica',
|
682
|
+
fontSize: 28,
|
683
|
+
fontColor: '#ffffff',
|
684
|
+
letterSpacing: 2,
|
685
|
+
fontWeight: 'bold'
|
686
|
+
}
|
687
|
+
}
|
688
|
+
}
|
689
|
+
}
|
690
|
+
```
|
691
|
+
|
692
|
+
Each decoration object can have these properties:
|
693
|
+
- `disabled`: Whether this side's decoration is disabled
|
694
|
+
- `enableText`: Whether to enable text on this side
|
695
|
+
- `offset`: Positioning offset for the decoration
|
696
|
+
- `curveAdjustment`: Adjustment for text curve
|
697
|
+
- `curveDisabled`: Whether to disable curved text
|
698
|
+
- `curveRadius`: Radius of the text curve
|
699
|
+
- `type`: Type of decoration (`'text'` or `'image'`)
|
700
|
+
- `value`: Text content or image URL
|
701
|
+
- `style`: Style options for text (font, size, color, etc.)
|
702
|
+
|
703
|
+
### Free vs. Premium Border Examples
|
704
|
+
|
705
|
+
#### Free Version (with QR-Platform branding)
|
706
|
+
|
707
|
+
```typescript
|
708
|
+
// Free version border - will show "QR-Platform" in bottom border
|
709
|
+
const qrCode = new QRCodeJs({
|
710
|
+
data: 'https://example.com',
|
711
|
+
borderOptions: {
|
712
|
+
hasBorder: true,
|
713
|
+
thickness: 40,
|
714
|
+
color: '#0033CC',
|
715
|
+
radius: '10%'
|
716
|
+
}
|
717
|
+
});
|
718
|
+
```
|
719
|
+
|
720
|
+
#### Premium Version (license required)
|
721
|
+
|
722
|
+
```typescript
|
723
|
+
// First activate license
|
724
|
+
await QRCodeJs.license('YOUR-LICENSE-KEY');
|
725
|
+
|
726
|
+
// Then create QR code with custom border text
|
727
|
+
const qrCode = new QRCodeJs({
|
728
|
+
data: 'https://example.com',
|
729
|
+
borderOptions: {
|
730
|
+
hasBorder: true,
|
731
|
+
thickness: 40,
|
732
|
+
color: '#0033CC',
|
733
|
+
radius: '10%',
|
734
|
+
decorations: {
|
735
|
+
bottom: {
|
736
|
+
enableText: true,
|
737
|
+
type: 'text',
|
738
|
+
value: 'YOUR CUSTOM TEXT', // This only works with a license
|
739
|
+
style: {
|
740
|
+
fontFace: 'Arial',
|
741
|
+
fontSize: 24,
|
742
|
+
fontColor: '#FFFFFF'
|
743
|
+
}
|
744
|
+
}
|
745
|
+
}
|
746
|
+
}
|
747
|
+
});
|
748
|
+
```
|
749
|
+
|
750
|
+
### Error Handling for Borders
|
751
|
+
|
752
|
+
When attempting to use premium border features without a license, the library will:
|
753
|
+
|
754
|
+
1. Not throw errors, but gracefully fall back to the free version behavior
|
755
|
+
2. Display "QR-Platform" branding in the bottom border regardless of your `decorations` settings
|
756
|
+
3. Ignore certain premium-only properties like `inner`, `borderOuter`, and `borderInner`
|
757
|
+
|
758
|
+
To check if your license is active and premium features are available:
|
759
|
+
|
760
|
+
```typescript
|
761
|
+
// Check detailed license information
|
762
|
+
const licenseDetails = QRCodeJs.getLicenseDetails();
|
763
|
+
if (licenseDetails) {
|
764
|
+
console.log('License plan:', licenseDetails.plan);
|
765
|
+
console.log('License expires:', new Date(licenseDetails.exp * 1000));
|
766
|
+
}
|
767
|
+
```
|
768
|
+
|
769
|
+
## Scan Validation (Premium Feature)
|
770
|
+
|
771
|
+
> **Note**: This is a Premium Feature requiring a license.
|
772
|
+
|
773
|
+
The QRCode.js library offers functionality to validate that generated QR codes are scannable.
|
774
|
+
|
775
|
+
### `validateScanning()`
|
776
|
+
|
777
|
+
- **Purpose**: Verify the generated QR code is scannable
|
778
|
+
- **Returns**: `Promise<ScanValidatorResponse>` resolving to a validation result object (`{ isValid: boolean, decodedText?: string, message?: string }`)
|
779
|
+
- **Parameters**:
|
780
|
+
- `validatorId` (`string`, optional, default: `'zbar'`): The ID of the validator engine to use. Currently only `'zbar'` is supported in the public release.
|
781
|
+
- `debug` (`boolean`, optional, default: `false`): Enables debug logging for the validation process.
|
782
|
+
- **Example**:
|
783
|
+
```typescript
|
784
|
+
const qrCode = new QRCodeJs({
|
785
|
+
data: 'https://example.com'
|
786
|
+
});
|
787
|
+
|
788
|
+
qrCode.validateScanning()
|
789
|
+
.then(result => {
|
790
|
+
if (result.isValid) {
|
791
|
+
console.log('QR code is valid and scannable!');
|
792
|
+
console.log('Decoded text:', result.decodedText);
|
793
|
+
} else {
|
794
|
+
console.log('QR code validation failed:', result.message);
|
795
|
+
}
|
796
|
+
});
|
797
|
+
```
|
798
|
+
|
799
|
+
## Node.js Usage
|
800
|
+
|
801
|
+
QRCode.js can also be used in Node.js environments.
|
802
|
+
|
803
|
+
### Installation
|
804
|
+
|
805
|
+
Follow the standard installation steps using npm or yarn.
|
806
|
+
|
807
|
+
### Basic Usage
|
808
|
+
|
809
|
+
```typescript
|
810
|
+
import { QRCodeJs, Options } from '@qr-platform/qr-code.js/node'; // Import from '@qr-platform/qr-code.js/node'
|
811
|
+
import fs from 'fs';
|
812
|
+
|
813
|
+
const options: Options = {
|
814
|
+
data: 'https://example.com',
|
815
|
+
};
|
816
|
+
|
817
|
+
const qrCode = new QRCodeJs(options);
|
818
|
+
|
819
|
+
qrCode.serialize().then(svgString => {
|
820
|
+
if (svgString) {
|
821
|
+
fs.writeFileSync('qrcode.svg', svgString);
|
822
|
+
console.log('QR Code saved to qrcode.svg');
|
823
|
+
}
|
824
|
+
});
|
825
|
+
```
|
826
|
+
|
827
|
+
### Key Differences & Considerations
|
828
|
+
|
829
|
+
- **Import Path**: Use `import { QRCodeJs } from '@qr-platform/qr-code.js/node';`.
|
830
|
+
- **No Canvas/Download**: Methods relying on browser APIs like `append()`, `download()`, or internal canvas generation are not available or behave differently in the Node.js version.
|
831
|
+
- **License Management**: Use the static methods described in the [License Management](#license-management) section.
|
832
|
+
- **Border Branding**: Similar to the browser version, Node.js will add "QR-Platform" branding to borders in the free version. To remove this, you'll need to activate a license.
|
833
|
+
|
834
|
+
## License Management
|
835
|
+
|
836
|
+
QRCode.js provides a comprehensive licensing system for premium features like advanced border controls and scan validation.
|
837
|
+
|
838
|
+
### Free vs. Premium Features
|
839
|
+
|
840
|
+
- **Free Features**: Basic QR code generation, styling options (colors, shapes, dot types), image embedding, basic borders (with QR-Platform branding)
|
841
|
+
- **Premium Features**:
|
842
|
+
- Advanced border customization (without branding)
|
843
|
+
- Custom border text
|
844
|
+
- Inner and outer borders
|
845
|
+
- Scan validation tools
|
846
|
+
- Full control over border sides and styling
|
847
|
+
|
848
|
+
### Border Limitations in Free Version
|
849
|
+
|
850
|
+
When using the basic border features in the free version, the library will automatically add "QR-Platform" branding text in the bottom border. This branded text cannot be removed or modified without a valid license. With a premium license, you gain full control over border text and can use borders without any branding.
|
851
|
+
|
852
|
+
### Activation Timing
|
853
|
+
|
854
|
+
- **Purpose**: Determines when license activation should occur
|
855
|
+
- **Important**: License activation must be completed *before* you create any `QRCodeJs` instances
|
856
|
+
- **Reason**: The constructor checks the license status at the time of creation
|
857
|
+
- **Rule**: Activate first, then instantiate
|
858
|
+
|
859
|
+
### Initialization
|
860
|
+
|
861
|
+
- **Purpose**: Sets up the license manager
|
862
|
+
- **Behavior**: Initializes automatically when you first attempt activation or check the status
|
863
|
+
- **Manual Method**: `QRCodeJs.initializeIfNeeded()`
|
864
|
+
- **Example**:
|
865
|
+
```typescript
|
866
|
+
async function initializeOnLoad() {
|
867
|
+
const isActive = await QRCodeJs.initializeIfNeeded();
|
868
|
+
console.log('License active after init:', isActive);
|
869
|
+
}
|
870
|
+
```
|
871
|
+
|
872
|
+
### Persistence
|
873
|
+
|
874
|
+
#### Browser Environment
|
875
|
+
- **Storage**: `localStorage` under the key `QRCodeJsLicense`
|
876
|
+
- **Persistence**: License persists across page loads and sessions until token expiration
|
877
|
+
- **Content Stored**: Both JWT and license key (if used for activation)
|
878
|
+
|
879
|
+
#### Node.js Environment
|
880
|
+
- **Storage**: In-memory only (no persistent storage)
|
881
|
+
- **Persistence**: Requires reactivation when the application restarts
|
882
|
+
- **Alternative**: Manage token storage externally
|
883
|
+
|
884
|
+
### Activation Methods
|
885
|
+
|
886
|
+
#### Using a License Key (`QRCodeJs.license()`)
|
887
|
+
|
888
|
+
- **Purpose**: Activate license using a license key
|
889
|
+
- **Type**: `function(licenseKey: string): Promise<ValidationResult>`
|
890
|
+
- **Process**:
|
891
|
+
1. Calls `QRCodeJs.license('YOUR-LICENSE-KEY')`
|
892
|
+
2. Library sends key to backend endpoint (default: `POST /api/get-token`)
|
893
|
+
3. Backend validates key and returns signed JWT
|
894
|
+
4. Library validates JWT signature and expiration date
|
895
|
+
5. If valid, token and key are stored
|
896
|
+
- **Example** (async/await):
|
897
|
+
```typescript
|
898
|
+
await QRCodeJs.license('YOUR-LICENSE-KEY');
|
899
|
+
const qrInstance = new QRCodeJs({
|
900
|
+
data: 'https://example.com',
|
901
|
+
borderOptions: {
|
902
|
+
hasBorder: true,
|
903
|
+
decorations: {
|
904
|
+
bottom: {
|
905
|
+
enableText: true,
|
906
|
+
value: 'CUSTOM TEXT' // Works because license is active
|
907
|
+
}
|
908
|
+
}
|
909
|
+
}
|
910
|
+
});
|
911
|
+
```
|
912
|
+
|
913
|
+
#### Using a Pre-fetched Token (`QRCodeJs.token()`)
|
914
|
+
|
915
|
+
- **Purpose**: Activate license using a pre-fetched JWT token
|
916
|
+
- **Type**: `function(jwtToken: string | null): Promise<ValidationResult>`
|
917
|
+
- **Process**:
|
918
|
+
1. Calls `QRCodeJs.token('YOUR-JWT-STRING')`
|
919
|
+
2. Library validates JWT signature and expiration date
|
920
|
+
3. If valid, token is stored
|
921
|
+
- **Example** (async/await):
|
922
|
+
```typescript
|
923
|
+
await QRCodeJs.token(token);
|
924
|
+
const qrInstance = new QRCodeJs({
|
925
|
+
data: 'https://example.com',
|
926
|
+
borderOptions: {
|
927
|
+
hasBorder: true,
|
928
|
+
borderOuter: { // Premium feature works with license
|
929
|
+
color: '#002683',
|
930
|
+
thickness: 10
|
931
|
+
}
|
932
|
+
}
|
933
|
+
});
|
934
|
+
```
|
935
|
+
|
936
|
+
### Checking License Status
|
937
|
+
|
938
|
+
#### Getting License Details
|
939
|
+
|
940
|
+
- **Purpose**: Retrieve current license information
|
941
|
+
- **Type**: `function(): DecodedLicenseToken | null`
|
942
|
+
- **Returns**: Decoded token object if license is active, otherwise `null`
|
943
|
+
- **Example**:
|
944
|
+
```typescript
|
945
|
+
const licenseDetails = QRCodeJs.getLicenseDetails();
|
946
|
+
if (licenseDetails) {
|
947
|
+
console.log('License active. Plan:', licenseDetails.plan);
|
948
|
+
console.log('Domains:', licenseDetails.domains);
|
949
|
+
console.log('Expires:', new Date(licenseDetails.exp * 1000));
|
950
|
+
} else {
|
951
|
+
console.log('License not active or expired.');
|
952
|
+
}
|
953
|
+
```
|
954
|
+
|
955
|
+
### Configuration
|
956
|
+
|
957
|
+
#### Setting License URL
|
958
|
+
|
959
|
+
- **Purpose**: Configure the endpoint for license key validation
|
960
|
+
- **Type**: `function(url: string): typeof QRCodeJs`
|
961
|
+
- **Default**: `/api/get-token`
|
962
|
+
- **Important**: Must be called before `QRCodeJs.license()`
|
963
|
+
- **Example**:
|
964
|
+
```typescript
|
965
|
+
QRCodeJs.setLicenseUrl('https://my-api.com/licenses/get-token');
|
966
|
+
await QRCodeJs.license('YOUR-LICENSE-KEY');
|
967
|
+
```
|
968
|
+
|
969
|
+
#### Custom License Fetcher
|
970
|
+
|
971
|
+
- **Purpose**: Implement custom token fetching logic
|
972
|
+
- **Type**: `function(fetcherFn: (licenseKey: string) => Promise<string>): void`
|
973
|
+
- **Use Cases**: Custom headers, authentication, or request format
|
974
|
+
- **Example**:
|
975
|
+
```typescript
|
976
|
+
QRCodeJs.configureLicenseFetcher(async (key) => {
|
977
|
+
const response = await fetch('/my/custom/endpoint', {
|
978
|
+
method: 'POST',
|
979
|
+
headers: { 'Authorization': 'Bearer ' + getAuthToken() },
|
980
|
+
body: JSON.stringify({ licKey: key })
|
981
|
+
});
|
982
|
+
if (!response.ok) throw new Error('Fetch failed');
|
983
|
+
const data = await response.json();
|
984
|
+
return data.token;
|
985
|
+
});
|
986
|
+
```
|
987
|
+
|
988
|
+
## Complete Examples
|
989
|
+
|
990
|
+
### Basic QR Code with Custom Dots
|
991
|
+
|
992
|
+
```typescript
|
993
|
+
const qrCode = new QRCodeJs({
|
994
|
+
data: 'https://example.com',
|
995
|
+
dotsOptions: {
|
996
|
+
type: 'rounded',
|
997
|
+
color: '#0033CC',
|
998
|
+
size: 12
|
999
|
+
}
|
1000
|
+
});
|
1001
|
+
|
1002
|
+
qrCode.append(document.getElementById('qr-container'));
|
1003
|
+
```
|
1004
|
+
|
1005
|
+
### QR Code with Custom Corners and Background
|
1006
|
+
|
1007
|
+
```typescript
|
1008
|
+
const qrCode = new QRCodeJs({
|
1009
|
+
data: 'https://example.com',
|
1010
|
+
shape: 'square',
|
1011
|
+
qrOptions: {
|
1012
|
+
errorCorrectionLevel: 'H'
|
1013
|
+
},
|
1014
|
+
dotsOptions: {
|
1015
|
+
type: 'classy',
|
1016
|
+
color: '#000000'
|
1017
|
+
},
|
1018
|
+
cornersSquareOptions: {
|
1019
|
+
type: 'outpoint',
|
1020
|
+
color: '#FF0000'
|
1021
|
+
},
|
1022
|
+
cornersDotOptions: {
|
1023
|
+
type: 'dot',
|
1024
|
+
color: '#FF0000'
|
1025
|
+
},
|
1026
|
+
backgroundOptions: {
|
1027
|
+
color: '#FFECDB',
|
1028
|
+
round: 0.2
|
1029
|
+
}
|
1030
|
+
});
|
1031
|
+
```
|
1032
|
+
|
1033
|
+
### QR Code with Embedded Logo
|
1034
|
+
|
1035
|
+
```typescript
|
1036
|
+
const qrCode = new QRCodeJs({
|
1037
|
+
data: 'https://example.com',
|
1038
|
+
image: 'https://example.com/logo.png',
|
1039
|
+
imageOptions: {
|
1040
|
+
mode: 'center',
|
1041
|
+
imageSize: 0.3,
|
1042
|
+
margin: 1,
|
1043
|
+
crossOrigin: 'anonymous',
|
1044
|
+
fill: {
|
1045
|
+
color: 'rgba(255,255,255,1)'
|
1046
|
+
}
|
1047
|
+
},
|
1048
|
+
dotsOptions: {
|
1049
|
+
type: 'dot',
|
1050
|
+
color: '#4267B2'
|
1051
|
+
}
|
1052
|
+
});
|
1053
|
+
```
|
1054
|
+
|
1055
|
+
### QR Code with Free Border (includes QR-Platform branding)
|
1056
|
+
|
1057
|
+
```typescript
|
1058
|
+
const qrCode = new QRCodeJs({
|
1059
|
+
data: 'https://example.com',
|
1060
|
+
dotsOptions: {
|
1061
|
+
type: 'rounded',
|
1062
|
+
color: '#0033CC'
|
1063
|
+
},
|
1064
|
+
borderOptions: {
|
1065
|
+
hasBorder: true,
|
1066
|
+
thickness: 50,
|
1067
|
+
color: '#002683',
|
1068
|
+
radius: '5%'
|
1069
|
+
// Note: Bottom border will automatically show "QR-Platform" text
|
1070
|
+
// This cannot be changed in the free version
|
1071
|
+
}
|
1072
|
+
});
|
1073
|
+
```
|
1074
|
+
|
1075
|
+
### QR Code with Premium Border Features (requires license)
|
1076
|
+
|
1077
|
+
```typescript
|
1078
|
+
// Must activate license before creating QR code
|
1079
|
+
await QRCodeJs.license('YOUR-LICENSE-KEY');
|
1080
|
+
|
1081
|
+
const qrCode = new QRCodeJs({
|
1082
|
+
data: 'https://example.com',
|
1083
|
+
dotsOptions: {
|
1084
|
+
type: 'extraRounded',
|
1085
|
+
gradient: {
|
1086
|
+
type: 'radial',
|
1087
|
+
colorStops: [
|
1088
|
+
{ offset: 0, color: '#8F00FF' },
|
1089
|
+
{ offset: 1, color: '#0080FF' }
|
1090
|
+
]
|
1091
|
+
}
|
1092
|
+
},
|
1093
|
+
backgroundOptions: {
|
1094
|
+
color: '#FFFFFF',
|
1095
|
+
round: 0.1
|
1096
|
+
},
|
1097
|
+
borderOptions: {
|
1098
|
+
hasBorder: true,
|
1099
|
+
thickness: 50,
|
1100
|
+
color: '#002683',
|
1101
|
+
radius: '40%',
|
1102
|
+
// Premium feature: custom border text (no branding)
|
1103
|
+
decorations: {
|
1104
|
+
top: {
|
1105
|
+
enableText: true,
|
1106
|
+
type: 'text',
|
1107
|
+
value: 'SCAN ME',
|
1108
|
+
style: {
|
1109
|
+
fontFace: 'Helvetica',
|
1110
|
+
fontSize: 28,
|
1111
|
+
fontColor: '#ffffff',
|
1112
|
+
letterSpacing: 2,
|
1113
|
+
fontWeight: 'bold'
|
1114
|
+
}
|
1115
|
+
},
|
1116
|
+
bottom: {
|
1117
|
+
enableText: true,
|
1118
|
+
type: 'text',
|
1119
|
+
value: 'CUSTOM BOTTOM TEXT', // With license this replaces "QR-Platform"
|
1120
|
+
style: {
|
1121
|
+
fontFace: 'Arial',
|
1122
|
+
fontSize: 20,
|
1123
|
+
fontColor: '#ffffff'
|
1124
|
+
}
|
1125
|
+
}
|
1126
|
+
},
|
1127
|
+
// Premium feature: additional borders
|
1128
|
+
borderOuter: {
|
1129
|
+
color: '#001255',
|
1130
|
+
thickness: 10
|
1131
|
+
},
|
1132
|
+
borderInner: {
|
1133
|
+
color: '#334499',
|
1134
|
+
thickness: 5
|
1135
|
+
}
|
1136
|
+
}
|
1137
|
+
});
|
1138
|
+
```
|
1139
|
+
|
1140
|
+
### QR Code with Gradients
|
1141
|
+
|
1142
|
+
```typescript
|
1143
|
+
const qrCode = new QRCodeJs({
|
1144
|
+
data: 'Gradient Example',
|
1145
|
+
dotsOptions: {
|
1146
|
+
type: 'rounded',
|
1147
|
+
gradient: {
|
1148
|
+
type: 'linear',
|
1149
|
+
rotation: Math.PI / 4,
|
1150
|
+
colorStops: [
|
1151
|
+
{ offset: 0, color: '#ff5733' },
|
1152
|
+
{ offset: 1, color: '#c70039' }
|
1153
|
+
]
|
1154
|
+
}
|
1155
|
+
},
|
1156
|
+
backgroundOptions: {
|
1157
|
+
gradient: {
|
1158
|
+
type: 'radial',
|
1159
|
+
colorStops: [
|
1160
|
+
{ offset: 0, color: '#ffffff' },
|
1161
|
+
{ offset: 1, color: '#e0e0e0' }
|
1162
|
+
]
|
1163
|
+
}
|
1164
|
+
},
|
1165
|
+
cornersSquareOptions: {
|
1166
|
+
type: 'dot',
|
1167
|
+
gradient: {
|
1168
|
+
type: 'linear',
|
1169
|
+
rotation: 0,
|
1170
|
+
colorStops: [
|
1171
|
+
{ offset: 0, color: '#c70039' },
|
1172
|
+
{ offset: 1, color: '#900c3f' }
|
1173
|
+
]
|
1174
|
+
}
|
1175
|
+
}
|
1176
|
+
});
|
1177
|
+
```
|
1178
|
+
|
1179
|
+
### QR Code with Border Layout Adjustments
|
1180
|
+
|
1181
|
+
```typescript
|
1182
|
+
const qrCode = new QRCodeJs({
|
1183
|
+
data: 'Layout within Border',
|
1184
|
+
scale: 0.75, // Scale the QR code down to 75% within the border
|
1185
|
+
offset: -15, // Move the QR code up slightly within the border
|
1186
|
+
dotsOptions: {
|
1187
|
+
type: 'square',
|
1188
|
+
color: '#333333'
|
1189
|
+
},
|
1190
|
+
borderOptions: {
|
1191
|
+
hasBorder: true,
|
1192
|
+
thickness: 60,
|
1193
|
+
color: '#CCCCCC',
|
1194
|
+
radius: '10%',
|
1195
|
+
decorations: {
|
1196
|
+
bottom: {
|
1197
|
+
enableText: true,
|
1198
|
+
type: 'text',
|
1199
|
+
value: 'SCALED & OFFSET',
|
1200
|
+
style: {
|
1201
|
+
fontFace: 'Arial',
|
1202
|
+
fontSize: 24,
|
1203
|
+
fontColor: '#555555',
|
1204
|
+
fontWeight: 'normal'
|
1205
|
+
}
|
1206
|
+
}
|
1207
|
+
}
|
1208
|
+
}
|
1209
|
+
});
|
1210
|
+
```
|
1211
|
+
|
1212
|
+
### Circular QR Code with Custom Styling
|
1213
|
+
|
1214
|
+
```typescript
|
1215
|
+
const qrCode = new QRCodeJs({
|
1216
|
+
data: 'https://example.com',
|
1217
|
+
shape: 'circle',
|
1218
|
+
dotsOptions: {
|
1219
|
+
type: 'rounded',
|
1220
|
+
color: '#6200EA'
|
1221
|
+
},
|
1222
|
+
cornersDotOptions: {
|
1223
|
+
type: 'dot',
|
1224
|
+
color: '#00C853'
|
1225
|
+
},
|
1226
|
+
cornersSquareOptions: {
|
1227
|
+
type: 'rounded',
|
1228
|
+
color: '#00C853'
|
1229
|
+
},
|
1230
|
+
backgroundOptions: {
|
1231
|
+
color: '#FFFFFF'
|
1232
|
+
}
|
1233
|
+
});
|
1234
|
+
```
|
1235
|
+
|
1236
|
+
## API Reference
|
1237
|
+
|
1238
|
+
### Constructors
|
1239
|
+
|
1240
|
+
```typescript
|
1241
|
+
new QRCodeJs(options: QRCodeJsOptions)
|
1242
|
+
```
|
1243
|
+
|
1244
|
+
### Methods
|
1245
|
+
|
1246
|
+
#### `append()`
|
1247
|
+
|
1248
|
+
Appends the QR code to a container element.
|
1249
|
+
|
1250
|
+
```typescript
|
1251
|
+
qrCode.append(container: HTMLElement): QRCodeJs | undefined
|
1252
|
+
```
|
1253
|
+
|
1254
|
+
#### `serialize()`
|
1255
|
+
|
1256
|
+
Converts the QR code to an SVG string.
|
1257
|
+
|
1258
|
+
```typescript
|
1259
|
+
qrCode.serialize(inverted?: boolean): Promise<string | undefined>
|
1260
|
+
```
|
1261
|
+
|
1262
|
+
#### `download()`
|
1263
|
+
|
1264
|
+
Downloads the QR code as a file.
|
1265
|
+
|
1266
|
+
```typescript
|
1267
|
+
qrCode.download(
|
1268
|
+
downloadOptions?: {
|
1269
|
+
name?: string;
|
1270
|
+
extension: 'svg' | 'png' | 'jpeg' | 'webp'
|
1271
|
+
},
|
1272
|
+
canvasOptions?: CanvasOptions
|
1273
|
+
): Promise<void>
|
1274
|
+
```
|
1275
|
+
|
1276
|
+
#### `update()`
|
1277
|
+
|
1278
|
+
Updates the QR code with new options.
|
1279
|
+
|
1280
|
+
```typescript
|
1281
|
+
qrCode.update(options?: RecursivePartial<Options>): void
|
1282
|
+
```
|
1283
|
+
|
1284
|
+
#### `validateScanning()` (Premium)
|
1285
|
+
|
1286
|
+
Validates that the QR code is scannable.
|
1287
|
+
|
1288
|
+
```typescript
|
1289
|
+
qrCode.validateScanning(
|
1290
|
+
validatorId?: string,
|
1291
|
+
debug?: boolean
|
1292
|
+
): Promise<ScanValidatorResponse>
|
1293
|
+
```
|
1294
|
+
|
1295
|
+
### Static Methods (License Management)
|
1296
|
+
|
1297
|
+
These methods are called directly on the `QRCodeJs` class (or `QRCodeJs` imported from `qrcode-js/node`).
|
1298
|
+
|
1299
|
+
#### `initializeIfNeeded()`
|
1300
|
+
|
1301
|
+
Initializes the license manager if needed.
|
1302
|
+
|
1303
|
+
```typescript
|
1304
|
+
QRCodeJs.initializeIfNeeded(): Promise<boolean>
|
1305
|
+
```
|
1306
|
+
|
1307
|
+
#### `getLicenseDetails()`
|
1308
|
+
|
1309
|
+
Returns the decoded token object if a valid license is active.
|
1310
|
+
|
1311
|
+
```typescript
|
1312
|
+
QRCodeJs.getLicenseDetails(): DecodedLicenseToken | null
|
1313
|
+
```
|
1314
|
+
|
1315
|
+
#### `license()`
|
1316
|
+
|
1317
|
+
Activates a license using a license key.
|
1318
|
+
|
1319
|
+
```typescript
|
1320
|
+
QRCodeJs.license(licenseKey: string): Promise<ValidationResult>
|
1321
|
+
```
|
1322
|
+
|
1323
|
+
#### `token()`
|
1324
|
+
|
1325
|
+
Activates a license using a pre-fetched JWT token.
|
1326
|
+
|
1327
|
+
```typescript
|
1328
|
+
QRCodeJs.token(token: string | null): Promise<ValidationResult>
|
1329
|
+
```
|
1330
|
+
|
1331
|
+
#### `configureLicenseFetcher()`
|
1332
|
+
|
1333
|
+
Configures a custom function for fetching license tokens.
|
1334
|
+
|
1335
|
+
```typescript
|
1336
|
+
QRCodeJs.configureLicenseFetcher(fetcher: (licenseKey: string) => Promise<string>): void
|
1337
|
+
```
|
1338
|
+
|
1339
|
+
#### `setLicenseUrl()`
|
1340
|
+
|
1341
|
+
Sets the URL endpoint for license key validation.
|
1342
|
+
|
1343
|
+
```typescript
|
1344
|
+
QRCodeJs.setLicenseUrl(url: string): void
|
1345
|
+
```
|
1346
|
+
|
1347
|
+
## FAQ
|
1348
|
+
|
1349
|
+
### General Questions
|
1350
|
+
|
1351
|
+
#### Can I use SVG output?
|
1352
|
+
Yes, set `type: 'svg'` and use the `.svg` property.
|
1353
|
+
|
1354
|
+
#### Can I use QRCode.js for free without a license?
|
1355
|
+
|
1356
|
+
Yes, QRCode.js can be used for free without a license key. This allows you to create full-featured, styled QR codes with all the basic features including custom dot styles, colors, shapes, and image embedding. The only limitations are on advanced border features and scan validation.
|
1357
|
+
|
1358
|
+
#### Can I use border features in the free version?
|
1359
|
+
|
1360
|
+
Yes, you can use basic border features in the free version, but the library will automatically add "QR-Platform" branding text in the bottom border of your QR code. This branding cannot be removed or customized in the free version.
|
1361
|
+
|
1362
|
+
#### Does the QR-Platform branding affect the scannability of the QR code?
|
1363
|
+
|
1364
|
+
No, the QR-Platform branding only appears in the border area, which is outside the actual QR code area. It does not affect the scannability or functionality of the QR code itself. However, it does affect the visual appearance of your QR code.
|
1365
|
+
|
1366
|
+
### Do you provide support for licensed users?
|
1367
|
+
Yes, we do provide support for licensed users. If you have any questions or need assistance, please contact us at support@qr-platform.com.
|
1368
|
+
|
1369
|
+
### What is QR-Platform?
|
1370
|
+
QR-Platform is a powerful and comprehensive solution for managing and deploying QR codes, it enables businesses to effortlessly Create, Store, Manage, and Deploy Beautiful, Stylish, and Fully Customizable QR codes. QRCode.js library license is included free of charge with all paid QR-Platform plans, offering seamless integration and powerful customization capabilities for businesses of any size.
|
1371
|
+
|
1372
|
+
#### Can I modify or remove the QR-Platform branding in the free version?
|
1373
|
+
|
1374
|
+
No, the QR-Platform branding in the bottom border is automatically added when using border features in the free version and cannot be modified or removed. This is a limitation of the free version. Purchasing a license allows you to remove the branding and fully customize your border text.
|
1375
|
+
|
1376
|
+
#### Can I make the QR-Platform branding less noticeable without a license?
|
1377
|
+
|
1378
|
+
While you cannot remove the branding, you can somewhat reduce its visual impact by:
|
1379
|
+
- Using colors that create less contrast with the text
|
1380
|
+
- Using thinner borders
|
1381
|
+
- Using a small border radius to make the overall design less attention-grabbing
|
1382
|
+
|
1383
|
+
However, the branding will still be present, and these approaches might reduce the aesthetic appeal of your QR code.
|
1384
|
+
|
1385
|
+
#### What happens if I try to use premium border features without a license?
|
1386
|
+
|
1387
|
+
The library will not throw errors but will instead gracefully fall back to the free version behavior. It will ignore premium-only properties like `inner`, `borderOuter`, and `borderInner`, and will still display the QR-Platform branding in the bottom border.
|
1388
|
+
|
1389
|
+
#### Do I need to activate the license on every page load?
|
1390
|
+
|
1391
|
+
- **Browser**: No, license persists in `localStorage` until expiration
|
1392
|
+
- **Node.js**: Yes, unless token is managed externally
|
1393
|
+
|
1394
|
+
#### What happens if the license expires?
|
1395
|
+
|
1396
|
+
`getLicenseDetails()` returns `null`; you'll need to renew with `license()` or `token()`.
|
1397
|
+
|
1398
|
+
## TypeScript Types
|
1399
|
+
|
1400
|
+
### Main Options Interface
|
1401
|
+
|
1402
|
+
```typescript
|
1403
|
+
interface Options {
|
1404
|
+
// Core Data & QR Algorithm
|
1405
|
+
data: string; // Required: Content to encode
|
1406
|
+
qrOptions: {
|
1407
|
+
typeNumber: number; // Default 0 (auto)
|
1408
|
+
mode?: Mode; // Default: auto-detected
|
1409
|
+
errorCorrectionLevel: ErrorCorrectionLevel; // Default 'Q'
|
1410
|
+
};
|
1411
|
+
|
1412
|
+
// Overall Shape & Layout
|
1413
|
+
shape: ShapeType; // Default 'square'
|
1414
|
+
margin?: number; // Default 0: Space around QR code (pixels)
|
1415
|
+
isResponsive?: boolean; // Default false: Allow SVG resizing
|
1416
|
+
scale?: number; // Default 1: Scale QR code within container/border (0-1.5)
|
1417
|
+
offset?: number; // Default 0: Vertical offset relative to center
|
1418
|
+
verticalOffset?: number; // Default 0: Absolute vertical offset
|
1419
|
+
horizontalOffset?: number; // Default 0: Absolute horizontal offset
|
1420
|
+
|
1421
|
+
// Dot Styling
|
1422
|
+
dotsOptions: {
|
1423
|
+
type: DotType; // Default 'square'
|
1424
|
+
color: string; // Default '#000000'
|
1425
|
+
gradient?: Gradient;
|
1426
|
+
size: number; // Default 10 (pixels)
|
1427
|
+
};
|
1428
|
+
|
1429
|
+
// Corner Square Styling (Overrides dotsOptions)
|
1430
|
+
cornersSquareOptions?: {
|
1431
|
+
type?: CornerSquareType; // Default: inherits dotsOptions.type or 'dot'
|
1432
|
+
color?: string; // Default: inherits dotsOptions.color or '#000000'
|
1433
|
+
gradient?: Gradient;
|
1434
|
+
};
|
1435
|
+
|
1436
|
+
// Corner Dot Styling (Overrides cornersSquareOptions)
|
1437
|
+
cornersDotOptions?: {
|
1438
|
+
type?: CornerDotType; // Default: inherits cornersSquareOptions.type or 'dot'
|
1439
|
+
color?: string; // Default: inherits cornersSquareOptions.color or '#000000'
|
1440
|
+
gradient?: Gradient;
|
1441
|
+
};
|
1442
|
+
|
1443
|
+
// Background Styling
|
1444
|
+
backgroundOptions?: {
|
1445
|
+
color?: string; // Default '#FFFFFF'
|
1446
|
+
gradient?: Gradient;
|
1447
|
+
round?: number | string; // Default 0: Corner rounding (0-1 or %)
|
1448
|
+
} | false; // Set to false to disable background
|
1449
|
+
|
1450
|
+
// Image Embedding
|
1451
|
+
image?: string | Buffer | Blob; // Image source (URL, Buffer, Blob)
|
1452
|
+
imageOptions: {
|
1453
|
+
mode?: ImageMode; // Default 'center'
|
1454
|
+
imageSize: number; // Default 0.4: Relative image size (0-1)
|
1455
|
+
margin: number; // Default 0: Margin around image (dot units)
|
1456
|
+
crossOrigin?: string; // Default undefined: CORS setting
|
1457
|
+
fill?: {
|
1458
|
+
color: string; // Default 'rgba(255,255,255,1)'
|
1459
|
+
gradient?: Gradient;
|
1460
|
+
};
|
1461
|
+
};
|
1462
|
+
|
1463
|
+
// Borders (Basic features in free version, advanced in premium)
|
1464
|
+
borderOptions?: {
|
1465
|
+
hasBorder: boolean; // Master switch to enable/disable borders
|
1466
|
+
thickness: number; // Thickness of the main border in pixels
|
1467
|
+
color: string; // Color of the main border
|
1468
|
+
radius: string; // Corner rounding of the border (e.g., '10%', '20px')
|
1469
|
+
noBorderThickness: number; // Thickness for border sides with disabled decorations
|
1470
|
+
background?: string; // Background color for the border area
|
1471
|
+
inner?: {
|
1472
|
+
radius: string;
|
1473
|
+
scale: number;
|
1474
|
+
horizontalOffset: number;
|
1475
|
+
verticalOffset: number;
|
1476
|
+
};
|
1477
|
+
borderOuter?: {
|
1478
|
+
color: string;
|
1479
|
+
thickness: number;
|
1480
|
+
};
|
1481
|
+
borderInner?: {
|
1482
|
+
color: string;
|
1483
|
+
thickness: number;
|
1484
|
+
};
|
1485
|
+
decorations?: {
|
1486
|
+
top?: DecorationOptions;
|
1487
|
+
right?: DecorationOptions;
|
1488
|
+
bottom?: DecorationOptions;
|
1489
|
+
left?: DecorationOptions;
|
1490
|
+
};
|
1491
|
+
};
|
1492
|
+
}
|
1493
|
+
|
1494
|
+
// Supporting Interfaces
|
1495
|
+
interface Gradient {
|
1496
|
+
type: 'linear' | 'radial';
|
1497
|
+
rotation?: number;
|
1498
|
+
colorStops: Array<{ offset: number; color: string }>;
|
1499
|
+
}
|
1500
|
+
|
1501
|
+
interface DecorationOptions {
|
1502
|
+
disabled: boolean;
|
1503
|
+
enableText: boolean;
|
1504
|
+
offset: number;
|
1505
|
+
curveAdjustment: number;
|
1506
|
+
curveDisabled: boolean;
|
1507
|
+
curveRadius: string;
|
1508
|
+
type: 'text' | 'image';
|
1509
|
+
value: string;
|
1510
|
+
style?: {
|
1511
|
+
fontFace: string;
|
1512
|
+
fontSize: number;
|
1513
|
+
fontColor: string;
|
1514
|
+
letterSpacing: number;
|
1515
|
+
fontWeight: 'normal' | 'bold';
|
1516
|
+
};
|
1517
|
+
}
|
1518
|
+
|
1519
|
+
// Enums
|
1520
|
+
enum ShapeType {
|
1521
|
+
square = 'square',
|
1522
|
+
circle = 'circle'
|
1523
|
+
}
|
1524
|
+
|
1525
|
+
enum Mode {
|
1526
|
+
numeric = 'numeric',
|
1527
|
+
alphanumeric = 'alphanumeric',
|
1528
|
+
byte = 'byte',
|
1529
|
+
kanji = 'kanji',
|
1530
|
+
unicode = 'unicode'
|
1531
|
+
}
|
1532
|
+
|
1533
|
+
enum ErrorCorrectionLevel {
|
1534
|
+
L = 'L', // 7% error recovery
|
1535
|
+
M = 'M', // 15% error recovery
|
1536
|
+
Q = 'Q', // 25% error recovery
|
1537
|
+
H = 'H' // 30% error recovery
|
1538
|
+
}
|
1539
|
+
|
1540
|
+
enum DotType {
|
1541
|
+
dot = 'dot',
|
1542
|
+
square = 'square',
|
1543
|
+
rounded = 'rounded',
|
1544
|
+
extraRounded = 'extra-rounded',
|
1545
|
+
classy = 'classy',
|
1546
|
+
classyRounded = 'classy-rounded',
|
1547
|
+
verticalLine = 'vertical-line',
|
1548
|
+
horizontalLine = 'horizontal-line',
|
1549
|
+
randomDot = 'random-dot',
|
1550
|
+
smallSquare = 'small-square',
|
1551
|
+
tinySquare = 'tiny-square',
|
1552
|
+
star = 'star',
|
1553
|
+
plus = 'plus',
|
1554
|
+
diamond = 'diamond'
|
1555
|
+
}
|
1556
|
+
|
1557
|
+
enum CornerSquareType {
|
1558
|
+
dot = 'dot',
|
1559
|
+
square = 'square',
|
1560
|
+
rounded = 'rounded',
|
1561
|
+
classy = 'classy',
|
1562
|
+
outpoint = 'outpoint',
|
1563
|
+
inpoint = 'inpoint'
|
1564
|
+
}
|
1565
|
+
|
1566
|
+
enum CornerDotType {
|
1567
|
+
dot = 'dot',
|
1568
|
+
square = 'square',
|
1569
|
+
heart = 'heart',
|
1570
|
+
rounded = 'rounded',
|
1571
|
+
classy = 'classy',
|
1572
|
+
outpoint = 'outpoint',
|
1573
|
+
inpoint = 'inpoint'
|
1574
|
+
}
|
1575
|
+
|
1576
|
+
enum ImageMode {
|
1577
|
+
center = 'center',
|
1578
|
+
overlay = 'overlay',
|
1579
|
+
background = 'background'
|
1580
|
+
}
|
1581
|
+
```
|
1582
|
+
|
1583
|
+
---
|
1584
|
+
|
1585
|
+
### See Also
|
1586
|
+
- [QRCode.js Documentation](./documentation.md#start)
|
1587
|
+
- [Quick References Guide](./quick-references-guide.md#start)
|
1588
|
+
- [API Reference Guide](./api-reference-guide.md#start)
|
1589
|
+
- [TypeScript Types and Definitions](./typescript-types-definitions.md#start)
|
1590
|
+
- [License Management](./license-management.md#start)
|
1591
|
+
- [Basic Examples](./examples.md#start)
|
1592
|
+
- [Advanced Examples](./advanced-examples.md#start)
|