0.0
No commit activity in last 3 years
No release in over 3 years
Creates an SVG graphic of a QR Code. Adds a to_svg method to the RQRCode::QRCode class provided by the 'rqrcode' gem.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

Depreciated!

Newer versions of the rqrcode gem have native svg output, rendering this obsolete.

RQRCode to SVG

Generate QR Codes as vector graphics. This package adds a to_svg method to the excellent rqrcode gem. It's pure Ruby, with no outside dependencies on heavier image manipulation or XML tools like RMagick or Nokogiri.

Installation

gem install rqrcode_to_svg

Usage

Start by creating an RQRCode::QRCode object as supplied by rqrcode.

qr = RQRCode::QRCode.new("http://www.google.com", :size => 4, :level => 'h')

An SVG is just one step away.

qr.to_svg

Without any options, this will return a string of the SVG's XML.

But there are many options.

qr.to_svg(:file => 'test.svg', :px => 4, :border => true, :namespace => false, :indent => false)
  • :file will write the SVG out to a file and return the path.
  • :px increases the size of each code-point by the given number of pixels-per-side-of-the-square. Defaults to 4.
  • :border toggles the border around the QR code. Defaults to false.
  • :namespace toggles use of the XML namespace prefix within the SVG. Defaults to false.
  • :indent toggles the pretty printing of the SVG's internal XML. Defaults to tag soup at false.

All options optional. Check out the documentation within the code for additional tweaks.