Module: SEFAZ::Utils::PrawnHelper

Included in:
Webservice::SAT::Templates::Base
Defined in:
lib/sefaz/utils/prawn_helper.rb

Overview

Módulo com recursos adicionais para os templates baseados na Prawn

Instance Method Summary collapse

Instance Method Details

#barcode_128c(doc, value:, x:, y:, xdim: 1, height: 20, margin: 0, unbleed: 0, color: '000000') ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/sefaz/utils/prawn_helper.rb', line 15

def barcode_128c(doc, value:, x:, y:, xdim: 1, height: 20, margin: 0, unbleed: 0, color: '000000')
  barcode = Barby::Code128C.new(value)
  outputter = Barby::PrawnOutputter.new(barcode)
  outputter.x = x
  outputter.y = (y - height)
  outputter.xdim = xdim
  outputter.height = height
  outputter.margin = margin
  outputter.unbleed = unbleed
  outputter.color = color

  doc.move_down height
  outputter.annotate_pdf doc
end

#dash(doc, gap:, space:, line_width:, x1:, x2:, y:) ⇒ Object



8
9
10
11
12
13
# File 'lib/sefaz/utils/prawn_helper.rb', line 8

def dash(doc, gap:, space:, line_width:, x1:, x2:, y:)
  doc.dash(gap, space: space)
  doc.line_width line_width
  doc.stroke_horizontal_line x1, x2, at: y
  doc.move_down 2
end

#qrcode(doc, value:, x:, y:, xdim: 1, margin: 0, unbleed: 0, color: '000000') ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/sefaz/utils/prawn_helper.rb', line 30

def qrcode(doc, value:, x:, y:, xdim: 1, margin: 0, unbleed: 0, color: '000000')
  qrcode = Barby::QrCode.new(value)
  outputter = Barby::PrawnOutputter.new(qrcode)
  height = (outputter.boolean_groups.length * xdim)
  outputter.x = x
  outputter.y = (y - height)
  outputter.xdim = xdim
  outputter.margin = margin
  outputter.unbleed = unbleed
  outputter.color = color

  doc.move_down height
  outputter.annotate_pdf doc
end