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 =
%q(
  \documentclass[<%= class_options %>]{article}
  \usepackage{pdfpages}
  \pagestyle{empty}
  \setlength{\parindent}{0pt}
  \begin{document}
  % pages_strings.each do |pages|
    \includepdf[pages={<%= pages %>},nup=<%= geometry %>]{<%= pdffile %>}%
  % end
  \end{document}
).gsub(/\A\n/,'').gsub(/^ +/, '')

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



208
209
210
211
212
# File 'lib/pdfmult.rb', line 208

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.



188
189
190
# File 'lib/pdfmult.rb', line 188

def layout
  @layout
end

#page_countObject (readonly)

Returns the value of attribute page_count.



188
189
190
# File 'lib/pdfmult.rb', line 188

def page_count
  @page_count
end

#pdffileObject (readonly)

Returns the value of attribute pdffile.



188
189
190
# File 'lib/pdfmult.rb', line 188

def pdffile
  @pdffile
end

Instance Method Details

#to_sObject



214
215
216
217
218
219
220
# File 'lib/pdfmult.rb', line 214

def to_s
  class_options = 'a4paper'
  class_options << ',landscape'  if layout.landscape?
  latex = ERB.new(TEMPLATE, 0, '%<>')

  latex.result(binding)
end