Module: Platformx::PdfHelpers

Defined in:
lib/platformx/pdf.rb

Overview

PDF helpers module

Author:

  • Tim Mushen

Instance Method Summary collapse

Instance Method Details

#x_fill_pdf(source_pdf: "", target_file_path: "", new_pdf_name: "", pdf_variables: {}, flatten: true) ⇒ Object

TODO:

Figure out what this method does and returns

Fill pdf helper

Parameters:

  • source_pdf (String) (defaults to: "")

    source pdf

  • target_file_path (String) (defaults to: "")

    target file path

  • new_pdf_name (String) (defaults to: "")

    new name of the pdf

  • pdf_variables (String) (defaults to: {})

    pdf variables

  • flatten (String) (defaults to: true)

    if to flatten or not



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/platformx/pdf.rb', line 14

def x_fill_pdf(source_pdf: "", target_file_path: "", new_pdf_name: "", pdf_variables: {}, flatten: true)
  # include pdftk
  pdftk = PdfForms.new(settings.pdftk_path)

  #find out the field names that are present in form.pdf
  #pdftk.get_field_names 'pdfs/cover_opt.pdf'
  #pdf_name = Time.new.to_i
  pdf_name = @proposal.id
  
  #Fill Out the forms
  pdftk.fill_form source_pdf, "#{target_file_path}/#{pdf_name}", 
    {
    Client: @proposal.client, 
    proposalDate: "#{format_date(Date.today)}", 
    expires: format_date(1.month.from_now)
    }, 
    :flatten => flatten
end