Class: Renalware::Letters::RecipientAddressPdfRenderer

Inherits:
Object
  • Object
show all
Defined in:
app/models/renalware/letters/recipient_address_pdf_renderer.rb

Constant Summary collapse

OPTIONS =
{
  page_size: "A4",
  encoding: "UTF-8"
}.freeze

Class Method Summary collapse

Class Method Details

.call(recipient) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/models/renalware/letters/recipient_address_pdf_renderer.rb', line 11

def self.call(recipient)
  unless recipient.respond_to?(:to_html)
    recipient = RecipientPresenter::WithCurrentAddress.new(recipient)
  end
  WickedPdf.new.pdf_from_string(
    LettersController.new.render_to_string(
      partial: "/renalware/letters/formatted_letters/recipient_address_cover_sheet",
      locals: { recipient: recipient },
      encoding: "UTF-8"
    ),
    OPTIONS
  )
end