Sha256: e9cf016f49c64c4b6dd601639dd7196fce64f3b44196107bef750dd5df82e950

Contents?: true

Size: 825 Bytes

Versions: 27

Compression:

Stored size: 825 Bytes

Contents

# frozen_string_literal: true

#
# Render a Letter to PDF. Try and get it from the cachefirst
# Lean on Letters::HTMLRenderer which already renders the letter to html via
# LetterPresenter#content.
#
module Renalware
  module Letters
    class PdfRenderer
      OPTIONS = {
        page_size: "A4",
        footer: {
          font_size: 8,
          right: "Page [page] of [topage]"
        },
        encoding: "UTF-8"
      }.freeze

      def self.call(letter, **options)
        unless letter.respond_to?(:to_html)
          letter = LetterPresenterFactory.new(letter)
        end
        PdfLetterCache.fetch(letter, **options) do
          Rails.logger.info "    Rendering PDF for letter #{letter.id}"
          WickedPdf.new.pdf_from_string(letter.to_html(**options), OPTIONS)
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
renalware-core-2.0.159 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.158 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.157 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.156 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.155 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.153 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.152 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.151 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.149 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.148 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.147 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.146 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.145 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.144 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.143 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.142 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.141 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.140 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.139 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.138 app/models/renalware/letters/pdf_renderer.rb