Class: Pdfmult::LaTeXDocument

Inherits:
Object
  • Object
show all
Defined in:
lib/pdfmult.rb

Overview

Class for the LaTeX document.

Create an instance with LaTeXDocument.new, specifying the input file, the layout, and the page count of the input file.

The method to_s returns the document as multiline string.

Constant Summary collapse

TEMPLATE =
"\\documentclass[<%= class_options %>]{article}\n\\usepackage{pdfpages}\n\\pagestyle{empty}\n\\setlength{\\parindent}{0pt}\n\\begin{document}\n% pages_strings.each do |pages|\n\\includepdf[pages={<%= pages %>},nup=<%= geometry %>]{<%= pdffile %>}%\n% end\n\\end{document}\n"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ LaTeXDocument

Initializes a LaTeXDocument instance. Expects an argument hash with:

:pdffile - filename of input pdf file :layout - page layout :page_count - page count of the input file



211
212
213
214
215
# File 'lib/pdfmult.rb', line 211

def initialize(args)
  @pdffile    = args[:pdffile]
  @layout     = args[:layout]
  @page_count = args[:page_count]
end

Instance Attribute Details

#layoutObject (readonly)

Returns the value of attribute layout.



191
192
193
# File 'lib/pdfmult.rb', line 191

def layout
  @layout
end

#page_countObject (readonly)

Returns the value of attribute page_count.



191
192
193
# File 'lib/pdfmult.rb', line 191

def page_count
  @page_count
end

#pdffileObject (readonly)

Returns the value of attribute pdffile.



191
192
193
# File 'lib/pdfmult.rb', line 191

def pdffile
  @pdffile
end

Instance Method Details

#to_sObject



217
218
219
220
221
# File 'lib/pdfmult.rb', line 217

def to_s
  latex = ERB.new(TEMPLATE, trim_mode: "%<>")

  latex.result(binding)
end