Sha256: a3bb910f7281b1ae7dbce5a286a55825e7c6a29c20cf918d5e44ce5efe789a6c
Contents?: true
Size: 962 Bytes
Versions: 9
Compression:
Stored size: 962 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]) data[:additional_variables] = options[:additional_variables] || {} 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
9 entries across 9 versions & 1 rubygems