GithubHelp home page GithubHelp logo

isabella232 / grails-qrcode Goto Github PK

View Code? Open in Web Editor NEW

This project forked from objectpartners/grails-qrcode

0.0 0.0 0.0 5.32 MB

The Grails QR Code plugin

Home Page: http://grails.org/plugin/qrcode

License: Apache License 2.0

Groovy 100.00%

grails-qrcode's Introduction

This plugin allows you to create QR codes as part of your Grails application without the need for an external service.

QrcodeController

Render text QRCode at default size (300x300px)

.../qrcode/text/Hello+World

Render text QRCode in 30x30px

.../qrcode/text?w=30&text=test

QRCode

Render url QRCode

.../qrcode/url?u=http://grails.org/plugin/qrcode

QrCodeService

qrCodeService.renderPng("test", 30, outputStream)

Tag Library

Namespace: qrcode

Render text as QRCode

<qrcode:image height="100" width="100" text="TEST TEXT"/>

If you want to include a QRCode image in an email and you use a GSP to render email content you must set attribute absolute="true". Otherwise the image url will not start with http:// and will probably not render correct.

<qrcode:image height="100" width="100" text="#648357" alt="Invoice #648357" absolute="true"/>

Render current request url as QRCode

<qrcode:url width="64"/>

Render vCard contact information as QRCode

In this example we have a method on the Person domain class that returns contact information as a vCard formatted String.

class Person {
    ...
    transient String getVcard() {
        def s = new StringBuilder()
        s << "BEGIN:VCARD\n"
        s << "VERSION:3.0\n"
        s << "N:${lastName};${firstName};;;\n"
        s << "FN: ${fullName}\n"
        s << "ORG:${companyName}\n"
        s << "TITLE:${title ? title.replace(',', '\\,') : ''}\n"
        s << "TEL;TYPE=work,voice,pref:${phone}\n"
        s << "TEL;TYPE=cell,voice:${cellphone}\n"
        s << "EMAIL;type=internet,pref:${email}\n"
        s << "ADR;TYPE=work,postal,pref:;;${address};${city};${state};${postalCode};${country}\n"
        def timestampFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'")
        s << "REV:${timestampFormat.format(lastUpdated ?: dateCreated)}\n"
        s << "END:VCARD\n"
        return s.toString()
    }
}

Now it's easy to render a QRCode of the contact information. This QRCode can be scanned with a smartphone and imported as a contact.

<qrcode:image height="150" text="${person.vcard}" alt="${person.fullName} ${person.address} ${person.city}"/>

grails-qrcode's People

Contributors

goeh avatar hrabalo avatar mootinator avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.