17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/barby/outputter/prawn_outputter.rb', line 17
def annotate_pdf(pdf, opts={})
opts = options(opts)
xpos, ypos, height, xdim = opts[:x], opts[:y], opts[:height], opts[:xdim]
ydim = opts[:ydim] || xdim
orig_xpos = xpos
if barcode.two_dimensional?
boolean_groups.reverse_each do |groups|
groups.each do |bar,amount|
if bar
pdf.move_to(xpos, ypos)
pdf.line_to(xpos, ypos+ydim)
pdf.line_to(xpos+(xdim*amount), ypos+ydim)
pdf.line_to(xpos+(xdim*amount), ypos)
pdf.line_to(xpos, ypos)
pdf.fill
end
xpos += (xdim*amount)
end
xpos = orig_xpos
ypos += ydim
end
else
boolean_groups.each do |bar,amount|
if bar
pdf.move_to(xpos, ypos)
pdf.line_to(xpos, ypos+height)
pdf.line_to(xpos+(xdim*amount), ypos+height)
pdf.line_to(xpos+(xdim*amount), ypos)
pdf.line_to(xpos, ypos)
pdf.fill
end
xpos += (xdim*amount)
end
end
pdf
end
|