Class: CVGen::Converter
- Inherits:
-
Kramdown::Converter::Pdf
- Object
- Kramdown::Converter::Pdf
- CVGen::Converter
- Defined in:
- lib/cvgen/converter.rb
Constant Summary collapse
- HEADER_SIZES =
[nil, 24, 16, 16, 12, 12, 12]
- HEADER_TOP_PADDING =
[nil, 0, 10, 10, 0, 0, 0]
- HEADER_BOTTOM_PADDING =
[nil, 4, 4, 6, 0, 0, 0]
Instance Method Summary collapse
- #document_options(root) ⇒ Object
- #dt_options(el, opts) ⇒ Object
- #header_options(el, opts) ⇒ Object
-
#initialize(root, options) ⇒ Converter
constructor
A new instance of Converter.
- #p_options(el, opts) ⇒ Object
- #render_header(el, opts) ⇒ Object
- #render_ul(el, opts) ⇒ Object
- #root_options(root, opts) ⇒ Object
- #ul_options(el, opts) ⇒ Object
- #with_block_padding(el, opts, floated = false) ⇒ Object
Constructor Details
Instance Method Details
#document_options(root) ⇒ Object
63 64 65 66 67 68 |
# File 'lib/cvgen/converter.rb', line 63 def (root) h = super.update(:margin => 72) h[:info][:Creator] = 'cvgen (using kramdown PDF converter)' h[:info].update(@options[:'document-info']) if @options[:'document-info'] h end |
#dt_options(el, opts) ⇒ Object
55 56 57 |
# File 'lib/cvgen/converter.rb', line 55 def (el, opts) super.update(:styles => [:italic]) end |
#header_options(el, opts) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/cvgen/converter.rb', line 21 def (el, opts) h = super h[:font] = opts[:header_font] if opts[:header_font] h.update({ :size => HEADER_SIZES[el.[:level]], :styles => [], :bottom_padding => HEADER_BOTTOM_PADDING[el.[:level]], :top_padding => HEADER_TOP_PADDING[el.[:level]]}) end |
#p_options(el, opts) ⇒ Object
59 60 61 |
# File 'lib/cvgen/converter.rb', line 59 def (el, opts) {:bottom_padding => 0} end |
#render_header(el, opts) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/cvgen/converter.rb', line 31 def render_header(el, opts) if el.['date'] @pdf.float do with_block_padding(el, opts, true) do @pdf.formatted_text [opts.merge(:text =>el.['date'])], :align => :right end end end super if el.[:level] == 2 @pdf.stroke_horizontal_rule @pdf.move_down 12 @current_padding += 12 end end |
#render_ul(el, opts) ⇒ Object
51 52 53 |
# File 'lib/cvgen/converter.rb', line 51 def render_ul(el, opts) @pdf.indent(15) { super } end |
#root_options(root, opts) ⇒ Object
17 18 19 |
# File 'lib/cvgen/converter.rb', line 17 def (root, opts) super.update(:font => "Helvetica", :leading => 1, :kerning => true, :header_font => @options[:'header-font']) end |
#ul_options(el, opts) ⇒ Object
47 48 49 |
# File 'lib/cvgen/converter.rb', line 47 def (el, opts) {} end |
#with_block_padding(el, opts, floated = false) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/cvgen/converter.rb', line 70 def with_block_padding(el, opts, floated = false) if opts.has_key?(:top_padding) top = opts[:top_padding] if top > @current_padding @pdf.move_down(top - @current_padding) end end @current_padding = 0 unless floated yield if opts.has_key?(:bottom_padding) @pdf.move_down(opts[:bottom_padding]) @current_padding = opts[:bottom_padding] unless floated end end |