diff --git a/CHANGELOG.md b/CHANGELOG.md index dac7debbe..de98ff372 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ This can also be enabled programmatically with `warnings.simplefilter('default', ## [2.8.4] - Not released yet ### Added * documentation on [internal linking with variable page numbers](https://py-pdf.github.io/fpdf2/Links.html#internal-links) +* documentation on [generating rMQR Codes](https://py-pdf.github.io/fpdf2/Barcodes.html#rmqr-code) ### Fixed * an `IndexError` was raised in some cases when rendering HTML with nested lists - _cf._ [issue #1358](https://github.com/py-pdf/fpdf2/issues/1358) * 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) diff --git a/docs/Barcodes.md b/docs/Barcodes.md index 92ad4ed46..6f6396301 100644 --- a/docs/Barcodes.md +++ b/docs/Barcodes.md @@ -62,19 +62,24 @@ Here is an example on how to generate a [QR Code](https://en.wikipedia.org/wiki/ using the [`python-qrcode`](https://github.com/lincolnloop/python-qrcode) lib: ```python -from fpdf import FPDF -import qrcode +{% include "../tutorial/qrcode_demo.py" %} +``` -pdf = FPDF() -pdf.add_page() -img = qrcode.make("fpdf2") -pdf.image(img.get_image(), x=50, y=50) -pdf.output("qrcode.pdf") +Output preview: + +![QCode embedded with fpdf2](qrcode.png) + + +## rMQR Code ## +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: + +```python +{% include "../tutorial/rmqrcode_demo.py" %} ``` Output preview: -![](qrcode.png) +![rMQR code embedded with fpdf2](rmqrcode.png) ## DataMatrix ## diff --git a/docs/rmqrcode.png b/docs/rmqrcode.png new file mode 100644 index 000000000..a89785bae Binary files /dev/null and b/docs/rmqrcode.png differ diff --git a/tutorial/qrcode_demo.py b/tutorial/qrcode_demo.py new file mode 100644 index 000000000..d81c26869 --- /dev/null +++ b/tutorial/qrcode_demo.py @@ -0,0 +1,8 @@ +from fpdf import FPDF +import qrcode + +pdf = FPDF() +pdf.add_page() +img = qrcode.make("fpdf2") +pdf.image(img.get_image(), x=50, y=50) +pdf.output("qrcode.pdf") diff --git a/tutorial/rmqrcode_demo.py b/tutorial/rmqrcode_demo.py new file mode 100644 index 000000000..9649dad9e --- /dev/null +++ b/tutorial/rmqrcode_demo.py @@ -0,0 +1,10 @@ +from fpdf import FPDF +from rmqrcode import QRImage, rMQR + +qr = rMQR.fit("https://py-pdf.github.io/fpdf2/") +qrimg = QRImage(qr, module_size=1) + +pdf = FPDF() +pdf.add_page() +pdf.image(qrimg._img, w=100, x="CENTER") +pdf.output("rmqrcode.pdf")