Feature request #21179
QR code generator for print layout
Status: | Open | ||
---|---|---|---|
Priority: | Normal | ||
Assignee: | - | ||
Category: | Map Composer/Printing | ||
Pull Request or Patch supplied: | No | Resolution: | |
Easy fix?: | No | Copied to github as #: | 28997 |
Description
When creating a print map or an atlas you might want to provide some of the information am the printed map in machine readable form by a QR code.
In addition to maps, textfields, images, ... there should be a QR code object which will generate dynamic QR code images that can be scanned with a phone.
History
#1 Updated by Julien Monticolo almost 6 years ago
As workaround, if you have internet connection, you can create a custom function :
from urllib import parse @qgsfunction(args='auto', group='url') def url_quote(string, feature, parent): """ Replace special characters in string using the %xx escape. Letters, digits, and the characters '_.-~' are never quoted, replace spaces by plus signs, as required for quoting HTML form values when building up a query string to go into a URL. By default, this function is intended for quoting the path section of URL. <h2>Example usage:</h2> <ul> <li>url_quote('/El Niño/') -> '%2FEl+Ni%C3%B1o%2F'</li> <li>url_quote('https://qgis.org/en/site/') -> 'https%3A%2F%2Fqgis.org%2Fen%2Fsite%2F'</li> </ul> """ string = parse.quote_plus(string) return string
and in the layout, add a label item with an html rendering (tick the option case), and paste the code :
[% '<img src="http://api.qrserver.com/v1/create-qr-code/?size=350x350&data=' || url_quote('HelloWorld!') || '"</img>' %]
for a 350 pixels QR code with the 'HelloWorld!' info.