class JekyllPandocMultipleFormats::Printer
Constants
- SHEET_SIZES
TODO allow custom sheet sizes
- TEMPLATE
Attributes
extra_options[RW]
nup[RW]
original_file[RW]
output_file[RW]
pages[RW]
papersize[RW]
relative_path[RW]
sheetsize[RW]
template[RW]
Public Class Methods
new(file, papersize = nil, sheetsize = nil, extra_options = nil)
click to toggle source
# File lib/jekyll-pandoc-multiple-formats-jekyll34/printer.rb, line 57 def initialize(file, papersize = nil, sheetsize = nil, extra_options = nil) return unless /\.pdf\Z/ =~ file return unless pdf = PDF::Info.new(file) @original_file = File.realpath(file) @papersize = papersize || 'a5paper' @sheetsize = sheetsize || 'a4paper' @pages = pdf.metadata[:page_count] @nup = SHEET_SIZES[@sheetsize.to_sym] / SHEET_SIZES[@papersize.to_sym] @extra_options = extra_options || '' # These layouts require a landscape page @extra_options << 'landscape' if is_landscape? self end
Public Instance Methods
is_landscape?()
click to toggle source
# File lib/jekyll-pandoc-multiple-formats-jekyll34/printer.rb, line 88 def is_landscape? [2,8,32,128].include? @nup end
render_template()
click to toggle source
# File lib/jekyll-pandoc-multiple-formats-jekyll34/printer.rb, line 96 def render_template @template = TEMPLATE .gsub('@@nup@@', @nup.to_s) .gsub('@@sheetsize@@', @sheetsize) .gsub('@@extra_options@@', @extra_options) .gsub('@@document@@', @original_file) .gsub('@@pages@@', to_nup * ',') end
round_to_nearest(int, near)
click to toggle source
# File lib/jekyll-pandoc-multiple-formats-jekyll34/printer.rb, line 92 def round_to_nearest(int, near) (int + (near - 1)) / near * near end
write()
click to toggle source
# File lib/jekyll-pandoc-multiple-formats-jekyll34/printer.rb, line 78 def write # Create the imposed file pdflatex = RTeX::Document.new(template) pdflatex.to_pdf do |pdf_file| FileUtils.cp pdf_file, @output_file end File.exists? @output_file end