Creates an SVG graphic of a QR Code.
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
.gitignore
Gemfile
README.md
Rakefile
rqrcode_to_svg.gemspec

README.md

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.