Sha256: b0e328800d40b48f5d5900e8e3f036065b7f90b9e4fae415afb6701092a9ecd0

Contents?: true

Size: 1.11 KB

Versions: 27

Compression:

Stored size: 1.11 KB

Contents

module BrDanfe
  module CceLib
    class Document
      def initialize
        @document = Prawn::Document.new(
          page_size: "A4",
          page_layout: :portrait,
          left_margin: 30,
          right_margin: 30,
          top_margin: 30,
          botton_margin: 30)

        @document.font "Times-Roman"
        @document.line_width = 0.3
      end

      def method_missing(method_name, *args, &block)
        @document.send(method_name, *args, &block)
      end

      def box(height:, pad:5, &block)
        bounding_box([0, cursor], width: page_width, height: height) do
          pad(pad) { indent(pad) { yield if block_given? } }
          stroke_bounds
        end
      end

      def text(text, options = {})
        pad = options.delete(:pad) || 0
        options = { align: :left, size: 12, style: nil }.merge(options)

        pad(pad) do
          @document.text text, size: options[:size], style: options[:style],
            align: options[:align]
        end
      end

      private
      def page_width
        page.dimensions[2] - (page.margins[:left] + page.margins[:right])
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
br_danfe-0.11.1 lib/br_danfe/cce_lib/document.rb
br_danfe-0.11.0 lib/br_danfe/cce_lib/document.rb
br_danfe-0.10.1 lib/br_danfe/cce_lib/document.rb
br_danfe-0.10.0 lib/br_danfe/cce_lib/document.rb
br_danfe-0.8.0 lib/br_danfe/cce_lib/document.rb
br_danfe-0.7.7 lib/br_danfe/cce_lib/document.rb
br_danfe-0.7.6 lib/br_danfe/cce_lib/document.rb
br_danfe-0.7.5 lib/br_danfe/cce_lib/document.rb
br_danfe-0.7.4 lib/br_danfe/cce_lib/document.rb
br_danfe-0.7.3 lib/br_danfe/cce_lib/document.rb
br_danfe-0.7.2 lib/br_danfe/cce_lib/document.rb
br_danfe-0.7.1 lib/br_danfe/cce_lib/document.rb
br_danfe-0.7.0 lib/br_danfe/cce_lib/document.rb
br_danfe-0.6.1 lib/br_danfe/cce_lib/document.rb
br_danfe-0.6.0 lib/br_danfe/cce_lib/document.rb
br_danfe-0.5.2 lib/br_danfe/cce_lib/document.rb
br_danfe-0.5.1 lib/br_danfe/cce_lib/document.rb
br_danfe-0.5.0 lib/br_danfe/cce_lib/document.rb
br_danfe-0.4.3 lib/br_danfe/cce_lib/document.rb
br_danfe-0.4.2 lib/br_danfe/cce_lib/document.rb