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 number of pages to put on one page, 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 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



205
206
207
208
209
# File 'lib/pdfmult.rb', line 205

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

Instance Method Details

#to_sObject



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

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

  latex.result(binding)
end