Class: Kitabu::Exporter::PDF
- Inherits:
-
Base
- Object
- Base
- Kitabu::Exporter::PDF
show all
- Defined in:
- lib/kitabu/exporter/pdf.rb
Instance Attribute Summary
Attributes inherited from Base
#root_dir, #source
Instance Method Summary
collapse
Methods inherited from Base
#config, #copy_directory, export, #handle_error, #initialize, #name, #render_template, #source_list, #spawn_command, #ui
Instance Method Details
13
14
15
16
17
|
# File 'lib/kitabu/exporter/pdf.rb', line 13
def
html = Footnotes::PDF.process(html_file.read).html
create_html_file(html_for_print, html, "print")
create_html_file(html_for_pdf, html, "pdf")
end
|
#create_html_file(target, html, class_name) ⇒ Object
19
20
21
22
23
24
25
26
27
|
# File 'lib/kitabu/exporter/pdf.rb', line 19
def create_html_file(target, html, class_name)
html.css("html").first.set_attribute "class", class_name
html
.css("link[name=stylesheet]")
.first
.set_attribute "href", "styles/#{class_name}.css"
File.open(target, "w") {|f| f << html.to_html }
end
|
#export ⇒ Object
6
7
8
9
10
11
|
# File 'lib/kitabu/exporter/pdf.rb', line 6
def export
super
spawn_command ["prince", html_for_pdf.to_s, "-o", pdf_file.to_s]
spawn_command ["prince", html_for_print.to_s, "-o", print_file.to_s]
end
|
#html_file ⇒ Object
37
38
39
|
# File 'lib/kitabu/exporter/pdf.rb', line 37
def html_file
root_dir.join("output/#{name}.html")
end
|
#html_for_pdf ⇒ Object
29
30
31
|
# File 'lib/kitabu/exporter/pdf.rb', line 29
def html_for_pdf
root_dir.join("output/#{name}.pdf.html")
end
|
#html_for_print ⇒ Object
33
34
35
|
# File 'lib/kitabu/exporter/pdf.rb', line 33
def html_for_print
root_dir.join("output/#{name}.print.html")
end
|
#pdf_file ⇒ Object
41
42
43
|
# File 'lib/kitabu/exporter/pdf.rb', line 41
def pdf_file
root_dir.join("output/#{name}.pdf")
end
|
#print_file ⇒ Object
45
46
47
|
# File 'lib/kitabu/exporter/pdf.rb', line 45
def print_file
root_dir.join("output/#{name}.print.pdf")
end
|