Sha256: 5cf390daf5d9426b1f2b483c48f24e12b08996cc04d52750f0ad8f3c9d8e3928

Contents?: true

Size: 1.32 KB

Versions: 14

Compression:

Stored size: 1.32 KB

Contents

require 'br_invoices_pdf/cfe/renderer/company_identification'
require 'br_invoices_pdf/cfe/renderer/fisco_info'
require 'br_invoices_pdf/cfe/renderer/header'
require 'br_invoices_pdf/cfe/renderer/payment_forms'
require 'br_invoices_pdf/cfe/renderer/product_table'
require 'br_invoices_pdf/cfe/renderer/qr_code'
require 'br_invoices_pdf/cfe/renderer/taxes_info'
require 'br_invoices_pdf/cfe/renderer/totals'

module BrInvoicesPdf
  module Cfe
    module Renderer
      module_function

      AUTO_HEIGHT_MOCK = 2000

      RENDERERS = [
        CompanyIdentification,
        Header,
        ProductTable,
        Totals,
        PaymentForms,
        TaxesInfo,
        QrCode,
        FiscoInfo
      ].freeze

      # :reek:FeatureEnvy
      def pdf(data, options)
        page_width = Renderer::BaseRenderer.page_paper_width(options[:page_size])

        Prawn::Document.new(options.merge(page_size: [page_width, AUTO_HEIGHT_MOCK])) do |pdf|
          pdf_content(pdf, data, page_width)
        end
      end

      def pdf_content(pdf, data, page_width)
        pdf.font_size(7) do
          RENDERERS.each do |renderer|
            renderer.execute(pdf, data)
          end

          page = pdf.page
          page.dictionary.data[:MediaBox] = [0, pdf.y - page.margins[:bottom], page_width, AUTO_HEIGHT_MOCK]
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
br_invoices_pdf-0.2.6 lib/br_invoices_pdf/cfe/renderer.rb
br_invoices_pdf-0.2.6.alpha.18 lib/br_invoices_pdf/cfe/renderer.rb
br_invoices_pdf-0.2.5.alpha.17 lib/br_invoices_pdf/cfe/renderer.rb
br_invoices_pdf-0.2.5 lib/br_invoices_pdf/cfe/renderer.rb
br_invoices_pdf-0.2.5.alpha.16 lib/br_invoices_pdf/cfe/renderer.rb
br_invoices_pdf-0.2.4 lib/br_invoices_pdf/cfe/renderer.rb
br_invoices_pdf-0.2.4.alpha.15 lib/br_invoices_pdf/cfe/renderer.rb
br_invoices_pdf-0.2.4.alpha.14 lib/br_invoices_pdf/cfe/renderer.rb
br_invoices_pdf-0.2.3 lib/br_invoices_pdf/cfe/renderer.rb
br_invoices_pdf-0.2.2 lib/br_invoices_pdf/cfe/renderer.rb
br_invoices_pdf-0.2.1 lib/br_invoices_pdf/cfe/renderer.rb
br_invoices_pdf-0.2.0 lib/br_invoices_pdf/cfe/renderer.rb
br_invoices_pdf-0.2.0.alpha.13 lib/br_invoices_pdf/cfe/renderer.rb
br_invoices_pdf-0.2.0.alpha.12 lib/br_invoices_pdf/cfe/renderer.rb