Sha256: 9073bd67738539dd272a08625a91b76c241214b0a1d4b991982f78f7a3c8921f

Contents?: true

Size: 1.44 KB

Versions: 18

Compression:

Stored size: 1.44 KB

Contents

# frozen_string_literal: true

require "collection_presenter"

module Renalware
  module Letters
    module Printing
      # Renders a PDF for printing with interleaved address and letter pages for multiple recipients
      class DuplexInterleavedPdfRenderer
        # Note we can't support page numbers here as they would start on the first address page and
        # end on the last letter, so the last letter if there are 3 recipients might say
        # Page 5 of 6 on the address page and Page 6 of 6 on the letter.
        OPTIONS = {
          page_size: "A4",
          encoding: "UTF-8"
        }.freeze

        def self.call(letter)
          unless letter.respond_to?(:to_html)
            letter = LetterPresenterFactory.new(letter)
          end
          # NB not caching the pdf for now until we can find a more standard way of using the
          # letter cache across adhoc and env stuffer renderers. Here for example we should be
          # using a hex digest of the interleaved letter but currently would not be.
          # PdfLetterCache.fetch(letter) do
          WickedPdf.new.pdf_from_string(
            LettersController.new.render_to_string_with_wicked_pdf(
              template: "/renalware/letters/printable_letters/show",
              locals: { letter: letter, recipients: PrintableRecipients.for(letter) },
              encoding: "UTF-8"
            ),
            OPTIONS
          )
          # end
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
renalware-core-2.1.1 app/models/renalware/letters/printing/duplex_interleaved_pdf_renderer.rb
renalware-core-2.1.0 app/models/renalware/letters/printing/duplex_interleaved_pdf_renderer.rb
renalware-core-2.0.167 app/models/renalware/letters/printing/duplex_interleaved_pdf_renderer.rb
renalware-core-2.0.166 app/models/renalware/letters/printing/duplex_interleaved_pdf_renderer.rb
renalware-core-2.0.165 app/models/renalware/letters/printing/duplex_interleaved_pdf_renderer.rb
renalware-core-2.0.164 app/models/renalware/letters/printing/duplex_interleaved_pdf_renderer.rb
renalware-core-2.0.163 app/models/renalware/letters/printing/duplex_interleaved_pdf_renderer.rb
renalware-core-2.0.162 app/models/renalware/letters/printing/duplex_interleaved_pdf_renderer.rb
renalware-core-2.0.161 app/models/renalware/letters/printing/duplex_interleaved_pdf_renderer.rb
renalware-core-2.0.160 app/models/renalware/letters/printing/duplex_interleaved_pdf_renderer.rb
renalware-core-2.0.159 app/models/renalware/letters/printing/duplex_interleaved_pdf_renderer.rb
renalware-core-2.0.158 app/models/renalware/letters/printing/duplex_interleaved_pdf_renderer.rb
renalware-core-2.0.157 app/models/renalware/letters/printing/duplex_interleaved_pdf_renderer.rb
renalware-core-2.0.156 app/models/renalware/letters/printing/duplex_interleaved_pdf_renderer.rb
renalware-core-2.0.155 app/models/renalware/letters/printing/duplex_interleaved_pdf_renderer.rb
renalware-core-2.0.153 app/models/renalware/letters/printing/duplex_interleaved_pdf_renderer.rb
renalware-core-2.0.152 app/models/renalware/letters/printing/duplex_interleaved_pdf_renderer.rb
renalware-core-2.0.151 app/models/renalware/letters/printing/duplex_interleaved_pdf_renderer.rb