Sha256: 08582583c863ebb6de9b23d9a8a2f01e78a0e527e8682ef217d9d9ed386c1d28

Contents?: true

Size: 886 Bytes

Versions: 14

Compression:

Stored size: 886 Bytes

Contents

# frozen_string_literal: true

module BrInvoicesPdf
  module Util
    module PdfRenderer
      extend Util::BaseRenderer

      module_function

      AUTO_HEIGHT_MOCK = 2000

      # :reek:FeatureEnvy
      def generate_pdf(data, options, renderers)
        page_width = Util::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: page_width, renderers: renderers)
        end
      end

      def pdf_content(pdf, data, options)
        pdf.font_size(7) do
          options[:renderers].each do |renderer|
            renderer.execute(pdf, data)
          end

          page = pdf.page
          page.dictionary.data[:MediaBox] = [0, pdf.y - page.margins[:bottom], options[: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.15 lib/br_invoices_pdf/util/pdf_renderer.rb
br_invoices_pdf-0.2.14 lib/br_invoices_pdf/util/pdf_renderer.rb
br_invoices_pdf-0.2.14.alpha.23 lib/br_invoices_pdf/util/pdf_renderer.rb
br_invoices_pdf-0.2.13 lib/br_invoices_pdf/util/pdf_renderer.rb
br_invoices_pdf-0.2.13.alpha.22 lib/br_invoices_pdf/util/pdf_renderer.rb
br_invoices_pdf-0.2.12.alpha.21 lib/br_invoices_pdf/util/pdf_renderer.rb
br_invoices_pdf-0.2.12.alpha.20 lib/br_invoices_pdf/util/pdf_renderer.rb
br_invoices_pdf-0.2.12 lib/br_invoices_pdf/util/pdf_renderer.rb
br_invoices_pdf-0.2.11 lib/br_invoices_pdf/util/pdf_renderer.rb
br_invoices_pdf-0.2.10 lib/br_invoices_pdf/util/pdf_renderer.rb
br_invoices_pdf-0.2.9 lib/br_invoices_pdf/util/pdf_renderer.rb
br_invoices_pdf-0.2.8 lib/br_invoices_pdf/util/pdf_renderer.rb
br_invoices_pdf-0.2.7 lib/br_invoices_pdf/util/pdf_renderer.rb
br_invoices_pdf-0.2.6.alpha.19 lib/br_invoices_pdf/util/pdf_renderer.rb