Skip to content

Commit 10d6948

Browse files
committed
Adding doc on embedding rMQR codes
1 parent 60ad3aa commit 10d6948

File tree

5 files changed

+32
-8
lines changed

5 files changed

+32
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ This can also be enabled programmatically with `warnings.simplefilter('default',
1919
## [2.8.4] - Not released yet
2020
### Added
2121
* documentation on [internal linking with variable page numbers](https://py-pdf.github.io/fpdf2/Links.html#internal-links)
22+
* documentation on [generating rMQR Codes](https://py-pdf.github.io/fpdf2/Barcodes.html#rmqr-code)
2223
### Fixed
2324
* an `IndexError` was raised in some cases when rendering HTML with nested lists - _cf._ [issue #1358](https://github.com/py-pdf/fpdf2/issues/1358)
2425
* an `IndexError` was raised in some cases when using [text_columns()](https://py-pdf.github.io/fpdf2/TextColumns.html) with [text shaping enabled](https://py-pdf.github.io/fpdf2/TextShaping.html) - _cf._ [issue #1439](https://github.com/py-pdf/fpdf2/issues/1439)

docs/Barcodes.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,24 @@ Here is an example on how to generate a [QR Code](https://en.wikipedia.org/wiki/
6262
using the [`python-qrcode`](https://github.com/lincolnloop/python-qrcode) lib:
6363

6464
```python
65-
from fpdf import FPDF
66-
import qrcode
65+
{% include "../tutorial/qrcode_demo.py" %}
66+
```
6767

68-
pdf = FPDF()
69-
pdf.add_page()
70-
img = qrcode.make("fpdf2")
71-
pdf.image(img.get_image(), x=50, y=50)
72-
pdf.output("qrcode.pdf")
68+
Output preview:
69+
70+
![QCode embedded with fpdf2](qrcode.png)
71+
72+
73+
## rMQR Code ##
74+
rMQR Codes, aka Rectangular Micro QR Codes, can be inserted in PDF documents using `fpdf2` and the [`rmqrcode`](https://github.com/OUDON/rmqrcode-python) library:
75+
76+
```python
77+
{% include "../tutorial/rmqrcode_demo.py" %}
7378
```
7479

7580
Output preview:
7681

77-
![](qrcode.png)
82+
![rMQR code embedded with fpdf2](docs/rmqrcode.png)
7883

7984

8085
## DataMatrix ##

docs/rmqrcode.png

718 Bytes
Loading

tutorial/qrcode_demo.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from fpdf import FPDF
2+
import qrcode
3+
4+
pdf = FPDF()
5+
pdf.add_page()
6+
img = qrcode.make("fpdf2")
7+
pdf.image(img.get_image(), x=50, y=50)
8+
pdf.output("qrcode.pdf")

tutorial/rmqrcode_demo.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from fpdf import FPDF
2+
from rmqrcode import QRImage, rMQR
3+
4+
qr = rMQR.fit("https://py-pdf.github.io/fpdf2/")
5+
qrimg = QRImage(qr, module_size=1)
6+
7+
pdf = FPDF()
8+
pdf.add_page()
9+
pdf.image(qrimg._img, w=100, x="CENTER")
10+
pdf.output("rmqrcode.pdf")

0 commit comments

Comments
 (0)