lib/ruby_danfe/document.rb in ruby_danfe-1.13.2 vs lib/ruby_danfe/document.rb in ruby_danfe-1.15.0

- old
+ new

@@ -1,17 +1,19 @@ module RubyDanfe class Document - def initialize - @document = Prawn::Document.new( + def initialize(opts = {}) + default_opts = { :page_size => 'A4', :page_layout => :portrait, :left_margin => 0, :right_margin => 0, :top_margin => 0, :botton_margin => 0 - ) + } + @document = Prawn::Document.new(default_opts.merge(opts)) + @document.font "Times-Roman" end def method_missing(method_name, *args, &block) @document.send(method_name, *args, &block) @@ -24,14 +26,15 @@ def ititle(h, w, x, y, title) self.text_box title, :size => 10, :at => [x.cm, Helper.invert(y.cm) - 2], :width => w.cm, :height => h.cm, :style => :bold end def ibarcode(h, w, x, y, info) + info = info.gsub(/\D/, '') Barby::Code128C.new(info).annotate_pdf(self, :x => x.cm, :y => Helper.invert(y.cm), :width => w.cm, :height => h.cm) if info != '' end - def iqrcode(h, w, x, y, info) - Barby::QrCode.new(info, :level => :q).annotate_pdf(self, :x => x.cm, :y => Helper.invert(y.cm), :width => w.cm, :height => h.cm) if info != '' + def iqrcode(x, y, info, size = nil) + Barby::QrCode.new(info, :level => :q, :size => size).annotate_pdf(self, :x => x.cm, :y => Helper.invert(y.cm)) if info != '' end def irectangle(h, w, x, y) self.stroke_rectangle [x.cm, Helper.invert(y.cm)], w.cm, h.cm end