Sha256: 62cac63d1a7acfe0e081fb05495e828cb8076fb6710e78e9847fb1f21b2c6c84

Contents?: true

Size: 588 Bytes

Versions: 10

Compression:

Stored size: 588 Bytes

Contents

module BrDanfe
  module DanfeLib
    module NfceLib
      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.new(%w[qrcode png], binmode: true)
          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
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
br_danfe-0.15.1 lib/br_danfe/danfe_lib/nfce_lib/qr_code.rb
br_danfe-0.15.0 lib/br_danfe/danfe_lib/nfce_lib/qr_code.rb
br_danfe-0.14.5 lib/br_danfe/danfe_lib/nfce_lib/qr_code.rb
br_danfe-0.14.4 lib/br_danfe/danfe_lib/nfce_lib/qr_code.rb
br_danfe-0.14.3 lib/br_danfe/danfe_lib/nfce_lib/qr_code.rb
br_danfe-0.14.2 lib/br_danfe/danfe_lib/nfce_lib/qr_code.rb
br_danfe-0.14.0 lib/br_danfe/danfe_lib/nfce_lib/qr_code.rb
br_danfe-0.13.3 lib/br_danfe/danfe_lib/nfce_lib/qr_code.rb
br_danfe-0.13.2 lib/br_danfe/danfe_lib/nfce_lib/qr_code.rb
br_danfe-0.13.1 lib/br_danfe/danfe_lib/nfce_lib/qr_code.rb