Sha256: aab60ca533ed55693cb23bbc79310f4e7d92afd2ad584c0505e7a7b55f22cf55
Contents?: true
Size: 1.26 KB
Versions: 2
Compression:
Stored size: 1.26 KB
Contents
require 'open-uri' # for open(http://...) module Elegant class Footer include Prawn::View def initialize(document, options = {}) @document = document @text = options[:text] end # Draws in the header of each page a horizontal line, the name of the # author, the title and the page number. The author must be provided in # the configuration, and the title when initializing the document. def render repeat(:all) do transparent(0.25) { stroke_horizontal_line 0, bounds.width, at: 0 } render_author render_text if @text end render_page_number end private def render_author options = {at: [0, -6], width: 50, height: 10, size: 7, valign: :top} text_box Elegant.configuration.author, options end def render_text left = 50 options = {size: 7, align: :center, valign: :top, inline_format: true} options[:at] = [left, -6] options[:width] = bounds.width - 2 * left options[:height] = 10 text_box @text, options end def render_page_number options = {width: 50, height: 10, size: 7, align: :right, valign: :top} options[:at] = [bounds.width - options[:width], -6] number_pages "Page <page>", options end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
elegant-1.2.1 | lib/elegant/footer.rb |
elegant-1.2.0 | lib/elegant/footer.rb |