Skip to content

Commit 9ee2d73

Browse files
authored
Merge pull request #4 from slidoapp/docs
2 parents 6b13dca + 4382b87 commit 9ee2d73

2 files changed

Lines changed: 72 additions & 70 deletions

File tree

README.md

Lines changed: 71 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# node-qrcode
2-
> QR code/2d barcode generator.
2+
> Generate Quick Response (QR) codes using JavaScript in a browser, server side code, or using a command line tool.
33
44
![build status](https://img.shields.io/github/actions/workflow/status/slidoapp/node-qrcode/build.yml?style=flat-square)
55
[![npm](https://img.shields.io/npm/v/%40slidoapp%2Fqrcode.svg?style=flat-square)](https://www.npmjs.com/package%40slidoapp%2Fqrcode)
@@ -73,7 +73,8 @@ Examples:
7373
qrcode -o out.png "some text" Save as png image
7474
qrcode -d F00 -o out.png "some text" Use red as foreground color
7575
```
76-
If not specified, output type is guessed from file extension.<br>
76+
77+
If not specified, output type is guessed from file extension.
7778
Recognized extensions are `png`, `svg` and `txt`.
7879

7980
### Browser
@@ -167,7 +168,7 @@ const generateQR = async text => {
167168
Error correction capability allows to successfully scan a QR Code even if the symbol is dirty or damaged.
168169
Four levels are available to choose according to the operating environment.
169170

170-
Higher levels offer a better error resistance but reduce the symbol's capacity.<br>
171+
Higher levels offer a better error resistance but reduce the symbol's capacity.
171172
If the chances that the QR Code symbol may be corrupted are low (for example if it is showed through a monitor)
172173
is possible to safely use a low error level such as `Low` or `Medium`.
173174

@@ -182,7 +183,7 @@ Possible levels are shown below:
182183

183184
The percentage indicates the maximum amount of damaged surface after which the symbol becomes unreadable.
184185

185-
Error level can be set through `options.errorCorrectionLevel` property.<br>
186+
Error level can be set through `options.errorCorrectionLevel` property.
186187
If not specified, the default value is `M`.
187188

188189
```javascript
@@ -194,10 +195,11 @@ QRCode.toDataURL('some text', { errorCorrectionLevel: 'H' }, function (err, url)
194195
## QR Code capacity
195196
Capacity depends on symbol version and error correction level. Also encoding modes may influence the amount of storable data.
196197

197-
The QR Code versions range from version **1** to version **40**.<br>
198-
Each version has a different number of modules (black and white dots), which define the symbol's size.
199-
For version 1 they are `21x21`, for version 2 `25x25` e so on.
200-
Higher is the version, more are the storable data, and of course bigger will be the QR Code symbol.
198+
The QR Code versions range from version **1** to version **40**.
199+
Each version has a different number of modules (black and white dots), which define size of the symbol.
200+
For version 1 symbol size is `21x21` modules, for version 2 `25x25` and so on up to `177x177` modules
201+
for the largest symbol size.
202+
The higher the version, the more data can be stored in the QR code and of course the bigger the symbol will be.
201203

202204
The table below shows the maximum number of storable characters in each encoding mode and for each error correction level.
203205

@@ -210,8 +212,8 @@ The table below shows the maximum number of storable characters in each encoding
210212

211213
**Note:** Maximum characters number can be different when using [Mixed modes](#mixed-modes).
212214

213-
QR Code version can be set through `options.version` property.<br>
214-
If no version is specified, the more suitable value will be used. Unless a specific version is required, this option is not needed.
215+
QR Code version can be set through `options.version` property.
216+
If no version is specified, the most suitable value will be used. Unless a specific version is required, this option is not needed.
215217

216218
```javascript
217219
QRCode.toDataURL('some text', { version: 2 }, function (err, url) {
@@ -220,8 +222,8 @@ QRCode.toDataURL('some text', { version: 2 }, function (err, url) {
220222
```
221223

222224
## Encoding modes
223-
Modes can be used to encode a string in a more efficient way.<br>
224-
A mode may be more suitable than others depending on the string content.
225+
Modes can be used to encode a string in a more efficient way.
226+
A mode may be more suitable than the others depending on the data content.
225227
A list of supported modes are shown in the table below:
226228

227229
| Mode | Characters | Compression |
@@ -231,18 +233,18 @@ A list of supported modes are shown in the table below:
231233
| Kanji | Characters from the Shift JIS system based on JIS X 0208 | 2 kanji are represented by 13 bits |
232234
| Byte | Characters from the ISO/IEC 8859-1 character set | Each characters are represented by 8 bits |
233235

234-
Choose the right mode may be tricky if the input text is unknown.<br>
235-
In these cases **Byte** mode is the best choice since all characters can be encoded with it. (See [Multibyte characters](#multibyte-characters))<br>
236+
Choosing the right mode may be tricky if the input text is unknown.
237+
In these cases **Byte** mode is the best choice since all characters can be encoded with it (see [Multibyte characters](#multibyte-characters)).
236238
However, if the QR Code reader supports mixed modes, using [Auto mode](#auto-mode) may produce better results.
237239

238240
### Mixed modes
239-
Mixed modes are also possible. A QR code can be generated from a series of segments having different encoding modes to optimize the data compression.<br>
241+
Mixed modes are also possible. A QR code can be generated from a series of segments having different encoding modes to optimize the data compression.
240242
However, switching from a mode to another has a cost which may lead to a worst result if it's not taken into account.
241243
See [Manual mode](#manual-mode) for an example of how to specify segments with different encoding modes.
242244

243245
### Auto mode
244-
By **default**, automatic mode selection is used.<br>
245-
The input string is automatically splitted in various segments optimized to produce the shortest possible bitstream using mixed modes.<br>
246+
By **default**, automatic mode selection is used.
247+
The input string is automatically splitted in various segments optimized to produce the shortest possible bitstream using mixed modes.
246248
This is the preferred way to generate the QR Code.
247249

248250
For example, the string **ABCDE12345678?A1A** will be splitted in 3 segments with the following modes:
@@ -253,12 +255,12 @@ For example, the string **ABCDE12345678?A1A** will be splitted in 3 segments wit
253255
| 12345678 | Numeric |
254256
| ?A1A | Byte |
255257

256-
Any other combinations of segments and modes will result in a longer bitstream.<br>
258+
Any other combinations of segments and modes will result in a longer bitstream.
257259
If you need to keep the QR Code size small, this mode will produce the best results.
258260

259261
### Manual mode
260262
If auto mode doesn't work for you or you have specific needs, is also possible to manually specify each segment with the relative mode.
261-
In this way no segment optimizations will be applied under the hood.<br>
263+
In this way no segment optimizations will be applied under the hood.
262264
Segments list can be passed as an array of object:
263265

264266
```javascript
@@ -275,8 +277,8 @@ Segments list can be passed as an array of object:
275277
```
276278

277279
### Kanji mode
278-
With kanji mode is possible to encode characters from the Shift JIS system in an optimized way.<br>
279-
Unfortunately, there isn't a way to calculate a Shifted JIS values from, for example, a character encoded in UTF-8, for this reason a conversion table from the input characters to the SJIS values is needed.<br>
280+
With kanji mode is possible to encode characters from the Shift JIS system in an optimized way.
281+
Unfortunately, there isn't a way to calculate a Shifted JIS values from, for example, a character encoded in UTF-8, for this reason a conversion table from the input characters to the SJIS values is needed.
280282
This table is not included by default in the bundle to keep the size as small as possible.
281283

282284
If your application requires kanji support, you will need to pass a function that will take care of converting the input characters to appropriate values.
@@ -402,11 +404,11 @@ Type: `Object`
402404
}
403405
```
404406

405-
<br>
407+
406408

407409
#### `toCanvas(canvasElement, text, [options], [cb(error)])`
408410
#### `toCanvas(text, [options], [cb(error, canvas)])`
409-
Draws qr code symbol to canvas.<br>
411+
Draws qr code symbol to canvas.
410412
If `canvasElement` is omitted a new canvas is returned.
411413

412414
##### `canvasElement`
@@ -437,11 +439,11 @@ QRCode.toCanvas('text', { errorCorrectionLevel: 'H' }, function (err, canvas) {
437439
})
438440
```
439441

440-
<br>
442+
441443

442444
#### `toDataURL(text, [options], [cb(error, url)])`
443445
#### `toDataURL(canvasElement, text, [options], [cb(error, url)])`
444-
Returns a Data URI containing a representation of the QR Code image.<br>
446+
Returns a Data URI containing a representation of the QR Code image.
445447
If provided, `canvasElement` will be used as canvas to generate the data URI.
446448

447449
##### `canvasElement`
@@ -456,14 +458,14 @@ Text to encode or a list of objects describing segments.
456458

457459
##### `options`
458460
- ###### `type`
459-
Type: `String`<br>
461+
Type: `String`
460462
Default: `image/png`
461463

462-
Data URI format.<br>
463-
Possible values are: `image/png`, `image/jpeg`, `image/webp`.<br>
464+
Data URI format.
465+
Possible values are: `image/png`, `image/jpeg`, `image/webp`.
464466

465467
- ###### `rendererOpts.quality`
466-
Type: `Number`<br>
468+
Type: `Number`
467469
Default: `0.92`
468470

469471
A Number between `0` and `1` indicating image quality if the requested type is `image/jpeg` or `image/webp`.
@@ -495,11 +497,11 @@ QRCode.toDataURL('text', opts, function (err, url) {
495497
img.src = url
496498
})
497499
```
498-
<br>
500+
499501

500502
#### `toString(text, [options], [cb(error, string)])`
501503

502-
Returns a string representation of the QR Code.<br>
504+
Returns a string representation of the QR Code.
503505

504506

505507
##### `text`
@@ -509,10 +511,10 @@ Text to encode or a list of objects describing segments.
509511

510512
##### `options`
511513
- ###### `type`
512-
Type: `String`<br>
514+
Type: `String`
513515
Default: `utf8`
514516

515-
Output format.<br>
517+
Output format.
516518
Possible values are: `terminal`,`utf8`, and `svg`.
517519

518520
See [Options](#options) for other settings.
@@ -530,14 +532,14 @@ QRCode.toString('http://www.google.com', function (err, string) {
530532
})
531533
```
532534

533-
<br>
535+
534536

535537

536538
### Server API
537539
#### `create(text, [options])`
538540
See [create](#createtext-options).
539541

540-
<br>
542+
541543

542544
#### `toCanvas(canvas, text, [options], [cb(error)])`
543545
Draws qr code symbol to [node canvas](https://github.com/Automattic/node-canvas).
@@ -555,10 +557,10 @@ Type: `Function`
555557

556558
Callback function called on finish.
557559

558-
<br>
560+
559561

560562
#### `toDataURL(text, [options], [cb(error, url)])`
561-
Returns a Data URI containing a representation of the QR Code image.<br>
563+
Returns a Data URI containing a representation of the QR Code image.
562564
Only works with `image/png` type for now.
563565

564566
##### `text`
@@ -574,10 +576,10 @@ Type: `Function`
574576

575577
Callback function called on finish.
576578

577-
<br>
579+
578580

579581
#### `toString(text, [options], [cb(error, string)])`
580-
Returns a string representation of the QR Code.<br>
582+
Returns a string representation of the QR Code.
581583
If choosen output format is `svg` it will returns a string containing xml code.
582584

583585
##### `text`
@@ -587,10 +589,10 @@ Text to encode or a list of objects describing segments.
587589

588590
##### `options`
589591
- ###### `type`
590-
Type: `String`<br>
592+
Type: `String`
591593
Default: `utf8`
592594

593-
Output format.<br>
595+
Output format.
594596
Possible values are: `utf8`, `svg`, `terminal`.
595597

596598
See [Options](#options) for other settings.
@@ -608,11 +610,11 @@ QRCode.toString('http://www.google.com', function (err, string) {
608610
})
609611
```
610612

611-
<br>
613+
612614

613615
#### `toFile(path, text, [options], [cb(error)])`
614-
Saves QR Code to image file.<br>
615-
If `options.type` is not specified, the format will be guessed from file extension.<br>
616+
Saves QR Code to image file.
617+
If `options.type` is not specified, the format will be guessed from file extension.
616618
Recognized extensions are `png`, `svg`, `txt`.
617619

618620
##### `path`
@@ -627,20 +629,20 @@ Text to encode or a list of objects describing segments.
627629

628630
##### `options`
629631
- ###### `type`
630-
Type: `String`<br>
632+
Type: `String`
631633
Default: `png`
632634

633-
Output format.<br>
635+
Output format.
634636
Possible values are: `png`, `svg`, `utf8`.
635637

636638
- ###### `rendererOpts.deflateLevel` **(png only)**
637-
Type: `Number`<br>
639+
Type: `Number`
638640
Default: `9`
639641

640642
Compression level for deflate.
641643

642644
- ###### `rendererOpts.deflateStrategy` **(png only)**
643-
Type: `Number`<br>
645+
Type: `Number`
644646
Default: `3`
645647

646648
Compression strategy for deflate.
@@ -665,7 +667,7 @@ QRCode.toFile('path/to/filename.png', 'Some text', {
665667
})
666668
```
667669

668-
<br>
670+
669671

670672
#### `toFileStream(stream, text, [options])`
671673
Writes QR Code image to stream. Only works with `png` format for now.
@@ -683,76 +685,76 @@ Text to encode or a list of objects describing segments.
683685
##### `options`
684686
See [Options](#options).
685687

686-
<br>
688+
687689

688690
### Options
689691

690692
#### QR Code options
691693
##### `version`
692-
Type: `Number`<br>
694+
Type: `Number`
693695

694696
QR Code version. If not specified the more suitable value will be calculated.
695697

696698
##### `errorCorrectionLevel`
697-
Type: `String`<br>
699+
Type: `String`
698700
Default: `M`
699701

700-
Error correction level.<br>
702+
Error correction level.
701703
Possible values are `low, medium, quartile, high` or `L, M, Q, H`.
702704

703705
##### `maskPattern`
704-
Type: `Number`<br>
706+
Type: `Number`
705707

706-
Mask pattern used to mask the symbol.<br>
707-
Possible values are `0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`.<br>
708+
Mask pattern used to mask the symbol.
709+
Possible values are `0`, `1`, `2`, `3`, `4`, `5`, `6`, `7`.
708710
If not specified the more suitable value will be calculated.
709711

710712
##### `toSJISFunc`
711-
Type: `Function`<br>
713+
Type: `Function`
712714

713-
Helper function used internally to convert a kanji to its Shift JIS value.<br>
715+
Helper function used internally to convert a kanji to its Shift JIS value.
714716
Provide this function if you need support for Kanji mode.
715717

716718
#### Renderers options
717719
##### `margin`
718-
Type: `Number`<br>
720+
Type: `Number`
719721
Default: `4`
720722

721723
Define how much wide the quiet zone should be.
722724

723725
##### `scale`
724-
Type: `Number`<br>
726+
Type: `Number`
725727
Default: `4`
726728

727729
Scale factor. A value of `1` means 1px per modules (black dots).
728730

729731
##### `small`
730-
Type: `Boolean`<br>
732+
Type: `Boolean`
731733
Default: `false`
732734

733735
Relevant only for terminal renderer. Outputs smaller QR code.
734736

735737
##### `width`
736-
Type: `Number`<br>
738+
Type: `Number`
737739

738-
Forces a specific width for the output image.<br>
739-
If width is too small to contain the qr symbol, this option will be ignored.<br>
740+
Forces a specific width for the output image.
741+
If width is too small to contain the qr symbol, this option will be ignored.
740742
Takes precedence over `scale`.
741743

742744
##### `color.dark`
743-
Type: `String`<br>
745+
Type: `String`
744746
Default: `#000000ff`
745747

746-
Color of dark module. Value must be in hex format (RGBA).<br>
748+
Color of dark module. Value must be in hex format (RGBA).
747749
Note: dark color should always be darker than `color.light`.
748750

749751
##### `color.light`
750-
Type: `String`<br>
752+
Type: `String`
751753
Default: `#ffffffff`
752754

753-
Color of light module. Value must be in hex format (RGBA).<br>
755+
Color of light module. Value must be in hex format (RGBA).
754756

755-
<br>
757+
756758

757759
## GS1 QR Codes
758760
There was a real good discussion here about them. but in short any qrcode generator will make gs1 compatible qrcodes, but what defines a gs1 qrcode is a header with metadata that describes your gs1 information.

0 commit comments

Comments
 (0)