Sha256: ae3e301e5f0266a4e45b7209cbbd933de54af6b255b92486e8c0ab0d0e189108

Contents?: true

Size: 720 Bytes

Versions: 35

Compression:

Stored size: 720 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)
        unless letter.respond_to?(:to_html)
          letter = LetterPresenterFactory.new(letter)
        end
        PdfLetterCache.fetch(letter) do
          WickedPdf.new.pdf_from_string(letter.to_html, OPTIONS)
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
renalware-core-2.0.46 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.45 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.44 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.43 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.42 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.41 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.40 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.39 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.38 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.37 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.36 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.35 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.34 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.33 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.32 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.31 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.30 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.28 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.27 app/models/renalware/letters/pdf_renderer.rb
renalware-core-2.0.26 app/models/renalware/letters/pdf_renderer.rb