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
55
56
57
58
59
60
61
62
|
# File 'lib/barby/outputter/prawn_outputter.rb', line 19
def annotate_pdf(pdf, opts={})
with_options opts do
xpos, ypos = x, y
orig_xpos = xpos
orig_color = pdf.fill_color
pdf.fill_color = color if color
if barcode.two_dimensional?
boolean_groups.reverse_each do |groups|
groups.each do |bar,amount|
if bar
pdf.move_to(xpos+unbleed, ypos+unbleed)
pdf.line_to(xpos+unbleed, ypos+ydim-unbleed)
pdf.line_to(xpos+(xdim*amount)-unbleed, ypos+ydim-unbleed)
pdf.line_to(xpos+(xdim*amount)-unbleed, ypos+unbleed)
pdf.line_to(xpos+unbleed, ypos+unbleed)
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+unbleed, ypos)
pdf.line_to(xpos+unbleed, ypos+height)
pdf.line_to(xpos+(xdim*amount)-unbleed, ypos+height)
pdf.line_to(xpos+(xdim*amount)-unbleed, ypos)
pdf.line_to(xpos+unbleed, ypos)
pdf.fill
end
xpos += (xdim*amount)
end
end
pdf.fill_color = orig_color
end
pdf
end
|