Class: PetitFelix::Task::TemplatePDFTask

Inherits:
DefaultTask show all
Defined in:
lib/task/template_pdf_task.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DefaultTask

#prepare_options, #render_files

Class Method Details

.default_optionsObject

Default options of the application



17
18
19
20
21
22
23
24
25
# File 'lib/task/template_pdf_task.rb', line 17

def self.default_options 

  return {
    "template" => (File.join(File.dirname(__FILE__),"..","..","templates","test.json")),
    "output_file" => "test.pdf",
    "right_to_left" => false
  }
  
end

.nameObject



10
11
12
13
14
# File 'lib/task/template_pdf_task.rb', line 10

def self.name

  "template-pdf"
  
end

Instance Method Details

#render_zineObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/task/template_pdf_task.rb', line 27

def render_zine

  # Only continue if metadata has a title
  # Generates PDF
    
  pdf = PetitFelix::Worker::TemplatePDFWriter.new(
    page_layout: @metaoptions["page_layout"],
    print_scaling: @metaoptions["print_scaling"])
    
  pdf.set_options @metaoptions, override_options: @override_options

  pdf.init_values @metaoptions, pdf

  pdf.read_template
  
  # Outputs to file
  pdf.output

end