ruby-zint 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.standard.yml +3 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +79 -0
- data/LICENSE.txt +21 -0
- data/README.md +80 -0
- data/Rakefile +8 -0
- data/lib/ruby-zint.rb +1 -0
- data/lib/zint/aus_post.rb +7 -0
- data/lib/zint/aus_redirect.rb +7 -0
- data/lib/zint/aus_reply.rb +7 -0
- data/lib/zint/aus_route.rb +7 -0
- data/lib/zint/azrune.rb +7 -0
- data/lib/zint/aztec.rb +7 -0
- data/lib/zint/barcode.rb +148 -0
- data/lib/zint/bind.rb +7 -0
- data/lib/zint/bitmap.rb +4 -0
- data/lib/zint/bitmap_pixel.rb +4 -0
- data/lib/zint/box.rb +7 -0
- data/lib/zint/c25iata.rb +7 -0
- data/lib/zint/c25ind.rb +7 -0
- data/lib/zint/c25inter.rb +7 -0
- data/lib/zint/c25logic.rb +7 -0
- data/lib/zint/c25matrix.rb +7 -0
- data/lib/zint/c25standard.rb +7 -0
- data/lib/zint/channel.rb +7 -0
- data/lib/zint/codabar.rb +7 -0
- data/lib/zint/codablock_f.rb +7 -0
- data/lib/zint/code11.rb +7 -0
- data/lib/zint/code128.rb +7 -0
- data/lib/zint/code128b.rb +7 -0
- data/lib/zint/code16k.rb +7 -0
- data/lib/zint/code32.rb +7 -0
- data/lib/zint/code39.rb +7 -0
- data/lib/zint/code49.rb +7 -0
- data/lib/zint/code93.rb +7 -0
- data/lib/zint/code_one.rb +7 -0
- data/lib/zint/constants/capability_flags.rb +18 -0
- data/lib/zint/constants/debug_flags.rb +9 -0
- data/lib/zint/constants/errors.rb +19 -0
- data/lib/zint/constants/input_data_types.rb +14 -0
- data/lib/zint/constants/output_options.rb +18 -0
- data/lib/zint/constants/specific_options.rb +12 -0
- data/lib/zint/constants/symbologies.rb +130 -0
- data/lib/zint/constants/warn_levels.rb +9 -0
- data/lib/zint/constants/warnings.rb +12 -0
- data/lib/zint/daft.rb +7 -0
- data/lib/zint/data_matrix.rb +18 -0
- data/lib/zint/dbarexp.rb +7 -0
- data/lib/zint/dbarexpstk.rb +7 -0
- data/lib/zint/dbarltd.rb +7 -0
- data/lib/zint/dbaromn.rb +7 -0
- data/lib/zint/dbaromnstk.rb +7 -0
- data/lib/zint/dbarstk.rb +7 -0
- data/lib/zint/dot_code.rb +7 -0
- data/lib/zint/dotty_mode.rb +7 -0
- data/lib/zint/dpd.rb +7 -0
- data/lib/zint/dpident.rb +7 -0
- data/lib/zint/dpleit.rb +7 -0
- data/lib/zint/ean128.rb +7 -0
- data/lib/zint/ean14.rb +7 -0
- data/lib/zint/eanx.rb +7 -0
- data/lib/zint/eanxchk.rb +7 -0
- data/lib/zint/excode39.rb +7 -0
- data/lib/zint/fim.rb +7 -0
- data/lib/zint/flat.rb +7 -0
- data/lib/zint/grid_matrix.rb +7 -0
- data/lib/zint/gs1_128.rb +9 -0
- data/lib/zint/hanxin.rb +7 -0
- data/lib/zint/hibc128.rb +7 -0
- data/lib/zint/hibc39.rb +7 -0
- data/lib/zint/hibcaztec.rb +7 -0
- data/lib/zint/hibcblockf.rb +7 -0
- data/lib/zint/hibcdm.rb +7 -0
- data/lib/zint/hibcmicpdf.rb +7 -0
- data/lib/zint/hibcpdf.rb +7 -0
- data/lib/zint/hibcqr.rb +7 -0
- data/lib/zint/isbnx.rb +7 -0
- data/lib/zint/itf14.rb +7 -0
- data/lib/zint/japan_post.rb +7 -0
- data/lib/zint/kix.rb +7 -0
- data/lib/zint/korea_post.rb +7 -0
- data/lib/zint/logmars.rb +7 -0
- data/lib/zint/mailmark.rb +7 -0
- data/lib/zint/maxi_code.rb +7 -0
- data/lib/zint/micro_pdf417.rb +7 -0
- data/lib/zint/micro_qr.rb +7 -0
- data/lib/zint/msiplessey.rb +7 -0
- data/lib/zint/noascii.rb +7 -0
- data/lib/zint/nve18.rb +7 -0
- data/lib/zint/one_code.rb +7 -0
- data/lib/zint/pdf417.rb +7 -0
- data/lib/zint/pdf417comp.rb +7 -0
- data/lib/zint/pdf417trunc.rb +7 -0
- data/lib/zint/pharma.rb +7 -0
- data/lib/zint/pharmatwo.rb +7 -0
- data/lib/zint/planet.rb +7 -0
- data/lib/zint/plessey.rb +7 -0
- data/lib/zint/postnet.rb +7 -0
- data/lib/zint/pzn.rb +7 -0
- data/lib/zint/qr.rb +17 -0
- data/lib/zint/rmqr.rb +7 -0
- data/lib/zint/rss14.rb +7 -0
- data/lib/zint/rss14stack.rb +7 -0
- data/lib/zint/rss14stackomni.rb +7 -0
- data/lib/zint/rssexp.rb +7 -0
- data/lib/zint/rssexpstack.rb +7 -0
- data/lib/zint/rssltd.rb +7 -0
- data/lib/zint/stdout.rb +7 -0
- data/lib/zint/structs/circle.rb +11 -0
- data/lib/zint/structs/hexagon.rb +11 -0
- data/lib/zint/structs/rect.rb +12 -0
- data/lib/zint/structs/symbol.rb +41 -0
- data/lib/zint/structs/vector.rb +12 -0
- data/lib/zint/structs/vector_string.rb +15 -0
- data/lib/zint/telepen.rb +7 -0
- data/lib/zint/telepennum.rb +7 -0
- data/lib/zint/ultra.rb +7 -0
- data/lib/zint/upc_a.rb +7 -0
- data/lib/zint/upc_a_chk.rb +7 -0
- data/lib/zint/upc_e.rb +7 -0
- data/lib/zint/upc_e_chk.rb +7 -0
- data/lib/zint/upnqr.rb +7 -0
- data/lib/zint/uspsimail.rb +7 -0
- data/lib/zint/version.rb +3 -0
- data/lib/zint/vin.rb +7 -0
- data/lib/zint.rb +236 -0
- metadata +186 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7f734d5ae4c7959fb5753621a438396bccf285508bb17d80a847e80722f30378
|
4
|
+
data.tar.gz: 2207324efb9029cd4f6423b4b1aa04d8d8f9339e3fcca5464d048162c72f631d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 58b054d6ca8c39d9421a9dfdc49517402659b0935455fc61d0d3b7a65791980ef93b8ce10c36a820940d1a54240589dd928c6cb6ef618e7d87dddd655ae450b0
|
7
|
+
data.tar.gz: 9b7184006218407385bd2f84c1eb465ab3aa1742b08a98eae58dde5a6653e839d80835f8d234f2d6f768908b10926de94f215a32d6446c0c1de2e202f9a85a7b
|
data/.rspec
ADDED
data/.standard.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in ruby-zint.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
gem "rake", "~> 13.0"
|
7
|
+
|
8
|
+
gem "rspec", "~> 3.0"
|
9
|
+
|
10
|
+
gem "simplecov", require: false
|
11
|
+
|
12
|
+
gem "chunky_png"
|
13
|
+
|
14
|
+
gem "byebug"
|
15
|
+
|
16
|
+
gem "standard", "~> 1.3"
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ruby-zint (1.0.0)
|
5
|
+
ffi (~> 1.15)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
ast (2.4.2)
|
11
|
+
byebug (11.1.3)
|
12
|
+
chunky_png (1.4.0)
|
13
|
+
diff-lcs (1.5.0)
|
14
|
+
docile (1.4.0)
|
15
|
+
ffi (1.15.5)
|
16
|
+
json (2.6.3)
|
17
|
+
language_server-protocol (3.17.0.3)
|
18
|
+
parallel (1.22.1)
|
19
|
+
parser (3.2.1.1)
|
20
|
+
ast (~> 2.4.1)
|
21
|
+
rainbow (3.1.1)
|
22
|
+
rake (13.0.6)
|
23
|
+
regexp_parser (2.7.0)
|
24
|
+
rexml (3.2.5)
|
25
|
+
rspec (3.12.0)
|
26
|
+
rspec-core (~> 3.12.0)
|
27
|
+
rspec-expectations (~> 3.12.0)
|
28
|
+
rspec-mocks (~> 3.12.0)
|
29
|
+
rspec-core (3.12.1)
|
30
|
+
rspec-support (~> 3.12.0)
|
31
|
+
rspec-expectations (3.12.2)
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
+
rspec-support (~> 3.12.0)
|
34
|
+
rspec-mocks (3.12.5)
|
35
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
36
|
+
rspec-support (~> 3.12.0)
|
37
|
+
rspec-support (3.12.0)
|
38
|
+
rubocop (1.48.1)
|
39
|
+
json (~> 2.3)
|
40
|
+
parallel (~> 1.10)
|
41
|
+
parser (>= 3.2.0.0)
|
42
|
+
rainbow (>= 2.2.2, < 4.0)
|
43
|
+
regexp_parser (>= 1.8, < 3.0)
|
44
|
+
rexml (>= 3.2.5, < 4.0)
|
45
|
+
rubocop-ast (>= 1.26.0, < 2.0)
|
46
|
+
ruby-progressbar (~> 1.7)
|
47
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
48
|
+
rubocop-ast (1.28.0)
|
49
|
+
parser (>= 3.2.1.0)
|
50
|
+
rubocop-performance (1.16.0)
|
51
|
+
rubocop (>= 1.7.0, < 2.0)
|
52
|
+
rubocop-ast (>= 0.4.0)
|
53
|
+
ruby-progressbar (1.13.0)
|
54
|
+
simplecov (0.21.2)
|
55
|
+
docile (~> 1.1)
|
56
|
+
simplecov-html (~> 0.11)
|
57
|
+
simplecov_json_formatter (~> 0.1)
|
58
|
+
simplecov-html (0.12.3)
|
59
|
+
simplecov_json_formatter (0.1.4)
|
60
|
+
standard (1.25.3)
|
61
|
+
language_server-protocol (~> 3.17.0.2)
|
62
|
+
rubocop (~> 1.48.1)
|
63
|
+
rubocop-performance (~> 1.16.0)
|
64
|
+
unicode-display_width (2.4.2)
|
65
|
+
|
66
|
+
PLATFORMS
|
67
|
+
x86_64-linux
|
68
|
+
|
69
|
+
DEPENDENCIES
|
70
|
+
byebug
|
71
|
+
chunky_png
|
72
|
+
rake (~> 13.0)
|
73
|
+
rspec (~> 3.0)
|
74
|
+
ruby-zint!
|
75
|
+
simplecov
|
76
|
+
standard (~> 1.3)
|
77
|
+
|
78
|
+
BUNDLED WITH
|
79
|
+
2.4.8
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 Elias Fröhner
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
# ruby-zint
|
2
|
+
|
3
|
+
[![CI](https://github.com/api-walker/ruby-zint/actions/workflows/main.yml/badge.svg)](https://github.com/api-walker/ruby-zint/actions/workflows/main.yml)
|
4
|
+
|
5
|
+
This gem is a Ruby FFI binding for the [libzint](http://www.zint.org.uk) barcode generation library.
|
6
|
+
|
7
|
+
See the [documentation](https://rubydoc.info/github/api-walker/ruby-zint) for a full API description.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Install the libzint binary with your package manager (eg. `apt install zint` or perhaps `brew install zint`).
|
12
|
+
|
13
|
+
Other platforms require building [from source](https://www.zint.org.uk/manual/chapter/2).
|
14
|
+
|
15
|
+
**NOTE:** It is assumed that you are using libzint with the version [2.10](https://sourceforge.net/projects/zint/files/zint/2.10.0/).
|
16
|
+
|
17
|
+
Then install this gem with:
|
18
|
+
|
19
|
+
```
|
20
|
+
$ gem install ruby-zint
|
21
|
+
```
|
22
|
+
|
23
|
+
Or include `gem "ruby-zint"` in your Gemfile.
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require "zint"
|
29
|
+
|
30
|
+
barcode = Zint::Barcode.new(value: "Test", type: Zint::BARCODE_CODE128)
|
31
|
+
|
32
|
+
# Export to file
|
33
|
+
barcode.to_file(path: "out.png")
|
34
|
+
|
35
|
+
# Export file to memory
|
36
|
+
barcode.to_memory_file(extension: ".png")
|
37
|
+
|
38
|
+
# Write from Bitmap to own canvas
|
39
|
+
require "chunky_png"
|
40
|
+
png = ChunkyPNG::Image.new(bitmap.width, bitmap.height, ChunkyPNG::Color::TRANSPARENT)
|
41
|
+
white = ChunkyPNG::Color("white")
|
42
|
+
black = ChunkyPNG::Color("black")
|
43
|
+
|
44
|
+
bitmap = barcode.to_buffer
|
45
|
+
bitmap.pixels.each do |pixel|
|
46
|
+
png.compose_pixel(pixel.x, pixel.y, (pixel.colour == "K") ? black : white)
|
47
|
+
end
|
48
|
+
|
49
|
+
png.save(buffer_outfile)
|
50
|
+
|
51
|
+
# Use vector export
|
52
|
+
vector_struct = barcode.to_vector
|
53
|
+
# See manual: https://zint.org.uk/manual/chapter/5#buffering-symbols-in-memory-vector
|
54
|
+
|
55
|
+
# Use file as input
|
56
|
+
barcode = Zint::Barcode.new(input_file: "/tmp/test.txt")
|
57
|
+
barcode.to_file(path: "out.png")
|
58
|
+
|
59
|
+
# Use of comfort classes
|
60
|
+
|
61
|
+
# EAN
|
62
|
+
ean_barcode = Zint::Eanx.new(value: "012345678912")
|
63
|
+
ean_barcode.to_file(path: "ean.png")
|
64
|
+
|
65
|
+
# Code128
|
66
|
+
code_128_barcode = Zint::Code128.new(value: "012345678912")
|
67
|
+
code_128_barcode.to_file(path: "code_128.png")
|
68
|
+
|
69
|
+
```
|
70
|
+
|
71
|
+
## Contributing
|
72
|
+
|
73
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/api-walker/ruby-zint.
|
74
|
+
|
75
|
+
## License
|
76
|
+
|
77
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
78
|
+
|
79
|
+
## Credits
|
80
|
+
The project is based on the work and ideas of Angel Pizarro's [zint](https://github.com/delagoya/zint).
|
data/Rakefile
ADDED
data/lib/ruby-zint.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "zint"
|
data/lib/zint/azrune.rb
ADDED
data/lib/zint/aztec.rb
ADDED
data/lib/zint/barcode.rb
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
module Zint
|
2
|
+
# Base class to represent the barcode
|
3
|
+
#
|
4
|
+
# @example Create new barcode
|
5
|
+
# barcode = Zint::Barcode.new(value: "Test", type: Zint::BARCODE_QRCODE, options: {option_1: 1})
|
6
|
+
# barcode.to_file(path: "qr.png")
|
7
|
+
class Barcode
|
8
|
+
# @return [String, NilClass] Content of the barcode
|
9
|
+
attr_accessor :value
|
10
|
+
# @return [String, NilClass] Path to input file with content of the barcode
|
11
|
+
attr_accessor :input_file
|
12
|
+
# @return [Integer] Type of barcode
|
13
|
+
attr_reader :type
|
14
|
+
# @return [Zint::Structs::Symbol] The underlying FFI struct of the Zint C struct
|
15
|
+
attr_reader :zint_symbol
|
16
|
+
|
17
|
+
# @param value [String, NilClass] Content of the barcode
|
18
|
+
# @param input_file [String, NilClass] Path to input file with content of the barcode
|
19
|
+
# @param type [Integer] Type of barcode
|
20
|
+
# @param options [Hash] Specific options for Zint symbol
|
21
|
+
def initialize(value: nil, input_file: nil, type: Zint::BARCODE_CODE128, options: {})
|
22
|
+
raise ArgumentError, "value or input_file must be given!" if value&.empty? && input_file&.empty?
|
23
|
+
raise ArgumentError, "input_file not found!" if input_file && !File.exist?(input_file)
|
24
|
+
|
25
|
+
@zint_symbol = create_symbol(type)
|
26
|
+
options.each do |key, value|
|
27
|
+
@zint_symbol[key] = value
|
28
|
+
end
|
29
|
+
|
30
|
+
@type = type
|
31
|
+
@value = value
|
32
|
+
@input_file = input_file
|
33
|
+
end
|
34
|
+
|
35
|
+
# Sets type of barcode
|
36
|
+
#
|
37
|
+
# @param type [Integer] Type of barcode
|
38
|
+
def type=(type)
|
39
|
+
@type = type
|
40
|
+
|
41
|
+
call_function(:ZBarcode_Clear, zint_symbol)
|
42
|
+
|
43
|
+
@zint_symbol[:symbology] = type
|
44
|
+
end
|
45
|
+
|
46
|
+
# Exports barcode to file
|
47
|
+
#
|
48
|
+
# @param path [String] Path to export file
|
49
|
+
# @param rotate_angle [Integer] Rotate angle in degrees (0, 90, 180, 270)
|
50
|
+
def to_file(path:, rotate_angle: 0)
|
51
|
+
@zint_symbol[:outfile] = path
|
52
|
+
|
53
|
+
if input_file
|
54
|
+
call_function(:ZBarcode_Encode_File_and_Print, zint_symbol, input_file, rotate_angle)
|
55
|
+
else
|
56
|
+
call_function(:ZBarcode_Encode_and_Print, zint_symbol, value, 0, rotate_angle)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Exports barcode to memory file
|
61
|
+
#
|
62
|
+
# @param extension [String] Extension exported memory file
|
63
|
+
# @param rotate_angle [Integer] Rotate angle in degrees (0, 90, 180, 270)
|
64
|
+
# @return [String] Exported memory file
|
65
|
+
def to_memory_file(extension: ".png", rotate_angle: 0)
|
66
|
+
require "tempfile"
|
67
|
+
file = Tempfile.new(["zint", extension])
|
68
|
+
|
69
|
+
to_file(path: file.path, rotate_angle: rotate_angle)
|
70
|
+
|
71
|
+
file.rewind
|
72
|
+
buffer = file.read
|
73
|
+
file.close
|
74
|
+
file.unlink
|
75
|
+
|
76
|
+
buffer
|
77
|
+
end
|
78
|
+
|
79
|
+
# Exports barcode to buffer
|
80
|
+
#
|
81
|
+
# @param rotate_angle [Integer] Rotate angle in degrees (0, 90, 180, 270)
|
82
|
+
# @param raw_bitmap [Boolean] Export raw zint bitmap
|
83
|
+
# @return [Zint::Bitmap, String] Exported memory file
|
84
|
+
def to_buffer(rotate_angle: 0, raw_bitmap: false)
|
85
|
+
@zint_symbol[:output_options] = Zint::OUT_BUFFER_INTERMEDIATE
|
86
|
+
|
87
|
+
if input_file
|
88
|
+
call_function(:ZBarcode_Encode_File_and_Buffer, zint_symbol, input_file, rotate_angle)
|
89
|
+
else
|
90
|
+
call_function(:ZBarcode_Encode_and_Buffer, zint_symbol, value, 0, rotate_angle)
|
91
|
+
end
|
92
|
+
|
93
|
+
zint_bitmap = zint_symbol[:bitmap].read_string((zint_symbol[:bitmap_width] * zint_symbol[:bitmap_height]))
|
94
|
+
|
95
|
+
if raw_bitmap
|
96
|
+
zint_bitmap
|
97
|
+
else
|
98
|
+
pixels = []
|
99
|
+
zint_symbol[:bitmap_height].times do |row|
|
100
|
+
zint_symbol[:bitmap_width].times do |column|
|
101
|
+
pixel = zint_bitmap.slice!(0, 1)
|
102
|
+
colour = if %w[0 1].include?(pixel)
|
103
|
+
(pixel == "1") ? "K" : "W"
|
104
|
+
else
|
105
|
+
pixel
|
106
|
+
end
|
107
|
+
pixels << BitmapPixel.new(column, row, colour)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
Bitmap.new(zint_symbol[:bitmap_width], zint_symbol[:bitmap_height], pixels)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# Exports barcode as Zint vector
|
116
|
+
#
|
117
|
+
# @param rotate_angle [Integer] Rotate angle in degrees (0, 90, 180, 270)
|
118
|
+
# @return [Zint::Structs::Vector] Vector data of barcode
|
119
|
+
def to_vector(rotate_angle: 0)
|
120
|
+
if input_file
|
121
|
+
call_function(:ZBarcode_Encode_File_and_Buffer_Vector, zint_symbol, input_file, rotate_angle)
|
122
|
+
else
|
123
|
+
call_function(:ZBarcode_Encode_and_Buffer_Vector, zint_symbol, value, 0, rotate_angle)
|
124
|
+
end
|
125
|
+
|
126
|
+
Structs::Vector.new(zint_symbol[:vector])
|
127
|
+
end
|
128
|
+
|
129
|
+
private
|
130
|
+
|
131
|
+
def call_function(function_name, *args)
|
132
|
+
error_code = Zint.send(function_name.to_s, *args)
|
133
|
+
|
134
|
+
if Zint::ERRORS[error_code]
|
135
|
+
Zint.raise_error(error_code, zint_symbol[:errtxt])
|
136
|
+
end
|
137
|
+
|
138
|
+
error_code
|
139
|
+
end
|
140
|
+
|
141
|
+
def create_symbol(type)
|
142
|
+
symbol = Structs::Symbol.new(Zint.ZBarcode_Create)
|
143
|
+
symbol[:symbology] = type
|
144
|
+
|
145
|
+
symbol
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
data/lib/zint/bind.rb
ADDED
data/lib/zint/bitmap.rb
ADDED
data/lib/zint/box.rb
ADDED
data/lib/zint/c25iata.rb
ADDED
data/lib/zint/c25ind.rb
ADDED
data/lib/zint/channel.rb
ADDED
data/lib/zint/codabar.rb
ADDED
data/lib/zint/code11.rb
ADDED
data/lib/zint/code128.rb
ADDED
data/lib/zint/code16k.rb
ADDED
data/lib/zint/code32.rb
ADDED
data/lib/zint/code39.rb
ADDED
data/lib/zint/code49.rb
ADDED
data/lib/zint/code93.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Zint
|
2
|
+
module Constants
|
3
|
+
# Capability flags (ZBarcode_Cap() `cap_flag`)
|
4
|
+
module CapabilityFlags
|
5
|
+
ZINT_CAP_HRT = 0x0001 # Prints Human Readable Text?
|
6
|
+
ZINT_CAP_STACKABLE = 0x0002 # Is stackable?
|
7
|
+
ZINT_CAP_EXTENDABLE = 0x0004 # Is extendable with add-on data? (Is UPC/EAN?)
|
8
|
+
ZINT_CAP_COMPOSITE = 0x0008 # Can have composite data?
|
9
|
+
ZINT_CAP_ECI = 0x0010 # Supports Extended Channel Interpretations?
|
10
|
+
ZINT_CAP_GS1 = 0x0020 # Supports GS1 data?
|
11
|
+
ZINT_CAP_DOTTY = 0x0040 # Can be output as dots?
|
12
|
+
ZINT_CAP_FIXED_RATIO = 0x0100 # Has fixed width-to-height (aspect) ratio?
|
13
|
+
ZINT_CAP_READER_INIT = 0x0200 # Supports Reader Initialisation?
|
14
|
+
ZINT_CAP_FULL_MULTIBYTE = 0x0400 # Supports full-multibyte option?
|
15
|
+
ZINT_CAP_MASK = 0x0800 # Is mask selectable?
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|