Class: HexaPDF::Extras::Layout::QRCodeBox
- Inherits:
-
Layout::Box
- Object
- Layout::Box
- HexaPDF::Extras::Layout::QRCodeBox
- Defined in:
- lib/hexapdf/extras/layout/qr_code_box.rb
Overview
A QRCodeBox object is used for displaying a QR code.
The size of the QR code is determined by the width and height of the box (to be exact: by the smaller of the two values). The QR code is always placed at the top left corner of the box.
Internally, HexaPDF::Extras::GraphicObject::QRCode is used, so any option except at
and size
supported there can be used here.
Example:
#>pdf-composer100
composer.box(:qrcode, height: 50, data: 'Test', style: {position: :float})
composer.box(:qrcode, width: 20, data: 'Test', dark_color: 'red', style: {position: :float})
composer.box(:qrcode, width: 30, height: 50, data: 'Test', dark_color: 'green',
style: {position: :float})
composer.box(:qrcode, data: 'Test', dark_color: 'blue')
Instance Attribute Summary collapse
-
#qr_code ⇒ Object
readonly
The HexaPDF::Extras::GraphicObject::QRCode object that will be drawn.
Instance Method Summary collapse
-
#initialize(dark_color: nil, light_color: nil, data: nil, code_size: nil, max_code_size: nil, level: nil, mode: nil, **kwargs) ⇒ QRCodeBox
constructor
Creates a new QRCodeBox object with the given arguments (see HexaPDF::Extras::GraphicObject::QRCode for details).
Constructor Details
#initialize(dark_color: nil, light_color: nil, data: nil, code_size: nil, max_code_size: nil, level: nil, mode: nil, **kwargs) ⇒ QRCodeBox
Creates a new QRCodeBox object with the given arguments (see HexaPDF::Extras::GraphicObject::QRCode for details).
At least data
needs to be specified.
36 37 38 39 40 41 42 43 |
# File 'lib/hexapdf/extras/layout/qr_code_box.rb', line 36 def initialize(dark_color: nil, light_color: nil, data: nil, code_size: nil, max_code_size: nil, level: nil, mode: nil, **kwargs) super(**kwargs) @qr_code = HexaPDF::Extras::GraphicObject::QRCode.configure( dark_color: dark_color, light_color: light_color, data: data, code_size: code_size, max_code_size: max_code_size, level: level, mode: mode ) end |
Instance Attribute Details
#qr_code ⇒ Object (readonly)
The HexaPDF::Extras::GraphicObject::QRCode object that will be drawn.
30 31 32 |
# File 'lib/hexapdf/extras/layout/qr_code_box.rb', line 30 def qr_code @qr_code end |