Sha256: ea80cd2f95346f8e1ee5957ec70f896f62b486be2d9173f433650e634715b48f

Contents?: true

Size: 516 Bytes

Versions: 12

Compression:

Stored size: 516 Bytes

Contents

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

    def initialize(pdf:, qr_code_tag:, box_size:)
      @pdf = pdf
      @qr_code_tag = qr_code_tag
      @box_size = box_size
    end

    def render
      qrcode = RQRCode::QRCode.new(@qr_code_tag)
      image = Tempfile.new(%w[qrcode png], binmode: true)
      image.write(qrcode.as_png(module_px_size: 12).to_s)

      @pdf.image(image, width: @box_size, height: @box_size, position: :center)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
br_danfe-1.0.0 lib/br_danfe/qr_code.rb
br_danfe-0.20.0 lib/br_danfe/qr_code.rb
br_danfe-0.19.0 lib/br_danfe/qr_code.rb
br_danfe-0.18.0 lib/br_danfe/qr_code.rb
br_danfe-0.17.8 lib/br_danfe/qr_code.rb
br_danfe-0.17.7 lib/br_danfe/qr_code.rb
br_danfe-0.17.6 lib/br_danfe/qr_code.rb
br_danfe-0.17.5 lib/br_danfe/qr_code.rb
br_danfe-0.17.4 lib/br_danfe/qr_code.rb
br_danfe-0.17.3 lib/br_danfe/qr_code.rb
br_danfe-0.17.2 lib/br_danfe/qr_code.rb
br_danfe-0.17.1 lib/br_danfe/qr_code.rb