Class: Pdf::Components::QrCode

Inherits:
Pdf::Component show all
Defined in:
lib/pdf/components/qr_code.rb

Instance Attribute Summary

Attributes inherited from Pdf::Component

#pdf

Instance Method Summary collapse

Methods inherited from Pdf::Component

#initialize

Constructor Details

This class inherits a constructor from Pdf::Component

Instance Method Details

#render(data:, size: 80, position: :right, **_options) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/pdf/components/qr_code.rb', line 8

def render(data:, size: 80, position: :right, **_options)
  png_data = generate_qr_png(data, size)

  if position == :right
    @pdf.float do
      bounding_box([bounds.width - size, cursor], width: size) do
        @pdf.image StringIO.new(png_data), width: size, height: size
      end
    end
  else
    @pdf.image StringIO.new(png_data), width: size, height: size
  end
end