Class: Bookit::Emitter::Pdf

Inherits:
Abstract show all
Defined in:
lib/bookit/emitter/pdf.rb

Constant Summary

Constants inherited from Abstract

Abstract::DEFAULT_OPTIONS

Instance Attribute Summary

Attributes inherited from Abstract

#article, #options

Instance Method Summary collapse

Methods inherited from Abstract

#initialize

Constructor Details

This class inherits a constructor from Bookit::Emitter::Abstract

Instance Method Details

#generateObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/bookit/emitter/pdf.rb', line 11

def generate
  @pdf = Prawn::Document.new(info: {
    :Title => @article.title,
    :CreationDate => @article.date_published,
    :Author => @article.author,
    :Source => @article.url }, 
    margin: 0.5.in, page_size: 'LEGAL')

  @pdf.font_size = options[:font_size]

  @pdf.text @article.title, size: options[:header_size], style: options[:header_style]
  @pdf.text @article.author, style: :bold
  
  @pdf.text @article.date_published, size: options[:subtitle_size], style: options[:subtitle_style]
  @pdf.text @article.url, size: options[:subtitle_size], style: options[:subtitle_style]
  
  @pdf.text "\n\n"
  
  @article.content.formatted_content.each do |item|
    output(render(item))
  end

  @pdf
end