Class: Renalware::Letters::Printing::CreatePdfByInterleavingAddressSheetAndLetterForEachRecipient::UsingSeparatePdfForEachLetterSection
- Inherits:
-
Object
- Object
- Renalware::Letters::Printing::CreatePdfByInterleavingAddressSheetAndLetterForEachRecipient::UsingSeparatePdfForEachLetterSection
- Includes:
- PdfCombining
- Defined in:
- app/models/renalware/letters/printing/create_pdf_by_interleaving_address_sheet_and_letter_for_each_recipient.rb
Overview
This approach generates a PDF for each address cover sheet and each letter. It shells to ghostscript to merge the PDFs together in the right order.
Pros:
-
uses the letter PDF already in the cache from when we rendered it to deduce the page count after the letter was archived
-
uses very little memory as PDF concatenation done on disk
-
concatentation itslef reasonable fast
Cons:
-
slow because it shells to wkhtmltopdf for each cover sheet, and these are unklikely to be found in tha cache. So for main recip and 2 CCs it wil call wkhtmltopdf 3 times to render the address cover sheets, and the letter PDF should be pulled from cache so that is quick at least.
Instance Method Summary collapse
Methods included from PdfCombining
#combine_multiple_pdfs_into_one, #copy_tempfile_to_output_file, #files, #in_a_temporary_folder, #rails_tmp_folder, #shell_to_ghostscript_to_combine_files_into, #using_a_temporary_output_file
Instance Method Details
#call ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'app/models/renalware/letters/printing/create_pdf_by_interleaving_address_sheet_and_letter_for_each_recipient.rb', line 108 def call in_a_temporary_folder do |dir| Array(letters).each do |letter| letter_filename = create_letter_pdf_in(dir, letter) PrintableRecipients.for(letter).each do |recipient| files << create_cover_sheet_for(recipient, letter, dir) files << letter_filename end end combine_multiple_pdfs_into_one(dir, output_file) end end |