pdbook 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pdbook.rb +1 -1
- data/lib/pdbook/converter.rb +9 -4
- metadata +1 -1
data/lib/pdbook.rb
CHANGED
data/lib/pdbook/converter.rb
CHANGED
@@ -9,11 +9,16 @@ require "prawn/measurement_extensions"
|
|
9
9
|
|
10
10
|
module Pdbook
|
11
11
|
class Converter
|
12
|
-
def initialize(input, output, font = "#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf", options = {:page_size => "A4", :margin => 0.6.in, :compress => true})
|
12
|
+
def initialize(input, output, font = "#{Prawn::BASEDIR}/data/fonts/gkai00mp.ttf", options = {:page_size => "A4", :margin => 0.6.in, :font_size => 20, :spacing => 10, :compress => true})
|
13
13
|
@input = input
|
14
14
|
@output = output
|
15
15
|
@font = font
|
16
16
|
@options = options
|
17
|
+
@options[:page_size] = ENV["page_size"] if ENV["page_size"]
|
18
|
+
@options[:margin] = ENV["margin"] if ENV["margin"]
|
19
|
+
@options[:font_size] = ENV["font_size"].to_i if ENV["font_size"]
|
20
|
+
@options[:spacing] = ENV["spacing"].to_i if ENV["spacing"]
|
21
|
+
|
17
22
|
@pdb = Palm::PDB.new(input)
|
18
23
|
@log = Logger.new($STDOUT)
|
19
24
|
end
|
@@ -29,7 +34,7 @@ module Pdbook
|
|
29
34
|
render_toc(doc, toc)
|
30
35
|
|
31
36
|
# render content
|
32
|
-
doc.text_options.update(:wrap => :character, :size =>
|
37
|
+
doc.text_options.update(:wrap => :character, :size => @options[:font_size], :spacing => @options[:spacing])
|
33
38
|
content.each do |record|
|
34
39
|
render_content(doc, record.data)
|
35
40
|
end
|
@@ -58,7 +63,7 @@ module Pdbook
|
|
58
63
|
|
59
64
|
# print cover
|
60
65
|
unless cover.nil?
|
61
|
-
doc.text_options.update(:wrap => :character, :size =>
|
66
|
+
doc.text_options.update(:wrap => :character, :size => @options[:font_size]*2, :spacing => @options[:spacing] * 2)
|
62
67
|
doc.bounding_box [doc.bounds.left, 2*doc.bounds.top/3], :width => doc.bounds.width do
|
63
68
|
doc.text cover
|
64
69
|
end
|
@@ -67,7 +72,7 @@ module Pdbook
|
|
67
72
|
|
68
73
|
# print toc
|
69
74
|
unless toc.nil?
|
70
|
-
doc.text_options.update(:wrap => :character, :size =>
|
75
|
+
doc.text_options.update(:wrap => :character, :size => @options[:font_size], :spacing => @options[:spacing])
|
71
76
|
toc = toc.split("\e")
|
72
77
|
section_cnt = toc.shift.to_i
|
73
78
|
if section_cnt == toc.size
|