Class: HexaPDF::Extras::Layout::ZintBox
- Inherits:
-
Layout::ImageBox
- Object
- Layout::ImageBox
- HexaPDF::Extras::Layout::ZintBox
- Defined in:
- lib/hexapdf/extras/layout/zint_box.rb
Overview
A ZintBox object is used for displaying a barcode.
Internally, GraphicObject::Zint is used, so any option except at
, width
and height
supported there can be used here.
The size of the barcode is determined by the width and height of the box. For details on how this works see GraphicObject::Zint#width.
Example:
#>pdf-composer100
composer.box(:barcode, height: 30, style: {position: :float},
data: {value: 'Test', symbology: :qrcode})
composer.box(:barcode, width: 60, style: {position: :float},
data: {value: 'Test', symbology: :code128, bgcolour: 'ff0000',
fgcolour: '00ffff'})
composer.box(:barcode, width: 30, height: 50, style: {position: :float},
data: {value: 'Test', symbology: :code128})
composer.box(:barcode, data: {value: 'Test', symbology: :code128})
Instance Attribute Summary collapse
-
#barcode ⇒ Object
readonly
The HexaPDF::Extras::GraphicObject::Zint object that will be drawn.
Instance Method Summary collapse
-
#initialize(data:, **kwargs) ⇒ ZintBox
constructor
Creates a new ZintBox object with the given arguments.
Constructor Details
#initialize(data:, **kwargs) ⇒ ZintBox
Creates a new ZintBox object with the given arguments.
The argument data
needs to contain a hash with the arguments that are passed on to GraphicObject::Zint.
Note: Although this box derives from ImageBox, the #image method will only return the correct object after #fit was called.
41 42 43 44 |
# File 'lib/hexapdf/extras/layout/zint_box.rb', line 41 def initialize(data:, **kwargs) super(image: nil, **kwargs) @barcode = GraphicObject::Zint.configure(**data) end |
Instance Attribute Details
#barcode ⇒ Object (readonly)
The HexaPDF::Extras::GraphicObject::Zint object that will be drawn.
32 33 34 |
# File 'lib/hexapdf/extras/layout/zint_box.rb', line 32 def @barcode end |