Sha256: a27d0e6853c31786cc1336b5d52cbbc4d3aefb474b98d2bae0570d95f261916b

Contents?: true

Size: 523 Bytes

Versions: 2

Compression:

Stored size: 523 Bytes

Contents

module BrDanfe
  module DanfeNfceLib
    class QrCode
      require 'rqrcode'
      require 'chunky_png'
      require 'tempfile'

      def initialize(pdf, xml)
        @pdf = pdf
        @xml = xml
      end

      def render
        qrcode = RQRCode::QRCode.new(@xml['qrCode'])
        image = Tempfile.create('qrcode.png')
        image.write(qrcode.as_png(module_px_size: 12).to_s)

        box_size = 3.cm
        @pdf.image image, { width: box_size, height: box_size, position: :center }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
br_danfe-0.12.1 lib/br_danfe/danfe_nfce_lib/qr_code.rb
br_danfe-0.12.0 lib/br_danfe/danfe_nfce_lib/qr_code.rb