Monday, December 17, 2012

How to create QR code or Barcode using Google Chart api

You can create a QR code on the fly with a URL GET request.

Overview

QR codes are a popular type of two-dimensional barcode. They are also known as hardlinks or physical world hyperlinks. QR Codes store up to 4,296 alphanumeric characters of arbitrary text. This text can be anything, for example URL, contact information, a telephone number, even a poem! QR codes can be read by an optical device with the appropriate software. Such devices range from dedicated QR code readers to mobile phones.

Syntax

Root URL: https://chart.googleapis.com/chart?
QR code requests support the following URL query parameters after the ? in the root URL:
ParameterRequired or OptionalDescription
cht=qrRequiredSpecifies a QR code.
chs=<width>x<height>RequiredImage size.
chl=<data>RequiredThe data to encode. Data can be digits (0-9), alphanumeric characters, binary bytes of data, or Kanji. You cannot mix data types within a QR code. The data must be UTF-8 URL-encoded. Note that URLs have a 2K maximum length, so if you want to encode more than 2K bytes (minus the other URL characters), you will have to send your data using POST.
choe=<output_encoding>OptionalHow to encode the data in the QR code. Here are the available values:
  • UTF-8 [Default]
  • Shift_JIS
  • ISO-8859-1
chld=<error_correction_level>|<margin>Optional
  • error_correction_level - QR codes support four levels of error correction to enable recovery of missing, misread, or obscured data. Greater redundancy is achieved at the cost of being able to store less data. See the appendix for details. Here are the supported values:
    • L - [Default] Allows recovery of up to 7% data loss
    • M - Allows recovery of up to 15% data loss
    • Q - Allows recovery of up to 25% data loss
    • H - Allows recovery of up to 30% data loss
  • margin - The width of the white border around the data portion of the code. This is in rows, not in pixels. (See below to learn what rows are in a QR code.) The default value is 4.



    • Example:

      https://chart.googleapis.com/chart?cht=qr&chl=Hello+world&choe=UTF-8&chs=200x200

      No comments:

      Post a Comment