Class Barby::PDFWriterOutputter
In: lib/barby/outputter/pdfwriter_outputter.rb
Parent: Outputter
EAN13 Bookland EAN8 Barcode1D Code128 Code25 Code93 Code39 Barcode Barcode2D QrCode Pdf417 Code128A Code128B Code128C GS1128 Outputter CairoOutputter PngOutputter ASCIIOutputter PDFWriterOutputter RmagickOutputter PrawnOutputter SvgOutputter Code25IATA Code25Interleaved lib/barby/barcode/gs1_128.rb lib/barby/outputter/png_outputter.rb lib/barby/outputter/svg_outputter.rb lib/barby/outputter/rmagick_outputter.rb lib/barby/barcode.rb lib/barby/outputter/ascii_outputter.rb lib/barby/outputter.rb lib/barby/barcode/code_128.rb lib/barby/barcode/code_39.rb lib/barby/outputter/pdfwriter_outputter.rb lib/barby/barcode/code_93.rb lib/barby/outputter/prawn_outputter.rb lib/barby/barcode/pdf_417.rb lib/barby/barcode/ean_8.rb lib/barby/barcode/code_25_iata.rb lib/barby/outputter/cairo_outputter.rb lib/barby/barcode/ean_13.rb lib/barby/barcode/code_25.rb lib/barby/barcode/code_25_interleaved.rb lib/barby/barcode/qr_code.rb lib/barby/barcode/bookland.rb VERSION Barby dot/m_22_0.png

Annotates a PDFWriter document with the barcode

Registers the annotate_pdf method

Methods

annotate_pdf   height   x   xdim   y  

Attributes

height  [RW] 
x  [RW] 
xdim  [RW] 
y  [RW] 

Public Instance methods

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

[Source]

    # 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

[Source]

    # File lib/barby/outputter/pdfwriter_outputter.rb, line 72
72:     def height
73:       @height || 50
74:     end

[Source]

    # File lib/barby/outputter/pdfwriter_outputter.rb, line 64
64:     def x
65:       @x || 10
66:     end

[Source]

    # File lib/barby/outputter/pdfwriter_outputter.rb, line 76
76:     def xdim
77:       @xdim || 1
78:     end

[Source]

    # File lib/barby/outputter/pdfwriter_outputter.rb, line 68
68:     def y
69:       @y || 10
70:     end

[Validate]