| Class | Barby::PDFWriterOutputter |
| In: |
lib/barby/outputter/pdfwriter_outputter.rb
|
| Parent: | Outputter |
Annotates a PDFWriter document with the barcode
Registers the annotate_pdf method
| height | [RW] | |
| x | [RW] | |
| xdim | [RW] | |
| y | [RW] |
Annotate a PDFWriter document with the barcode
Valid options are:
x, y - The point in the document to start rendering from height - The height of the bars in PDF units xdim - The X dimension in PDF units
# File lib/barby/outputter/pdfwriter_outputter.rb, line 22
22: def annotate_pdf(pdf, options={})
23: with_options options do
24:
25: xpos, ypos = x, y
26: orig_xpos = xpos
27:
28: if barcode.two_dimensional?
29: boolean_groups.reverse_each do |groups|
30: groups.each do |bar,amount|
31: if bar
32: pdf.move_to(xpos, ypos).
33: line_to(xpos, ypos+xdim).
34: line_to(xpos+(xdim*amount), ypos+xdim).
35: line_to(xpos+(xdim*amount), ypos).
36: line_to(xpos, ypos).
37: fill
38: end
39: xpos += (xdim*amount)
40: end
41: xpos = orig_xpos
42: ypos += xdim
43: end
44: else
45: boolean_groups.each do |bar,amount|
46: if bar
47: pdf.move_to(xpos, ypos).
48: line_to(xpos, ypos+height).
49: line_to(xpos+(xdim*amount), ypos+height).
50: line_to(xpos+(xdim*amount), ypos).
51: line_to(xpos, ypos).
52: fill
53: end
54: xpos += (xdim*amount)
55: end
56: end
57:
58: end
59:
60: pdf
61: end