Class: RGhost::Convert

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

Overview

Convert PDF file to another format using commom render parameters of the Engine A additional parameter for this method is :range. Below someone examples:

Only cover page

Convert.new("/dir/myfile.pdf").to :jpeg, :filename => "/tmp/test.jpg"

One page per file

It's generate file with pattern test_0001.png, test_0002.png, etc

Convert.new("/dir/myfile.pdf").to :png, :multipage => true, :filename => "/tmp/test.png"

One page per file with page range

Convert.new("/dir/myfile.pdf").to :eps,  :multipage => true, :filename => "/tmp/test.eps", :range => 1..5

Getting files after convertion

files=Convert.new("/dir/myfile.pdf").to :eps,  :multipage => true, :filename => "/tmp/test.eps", :range => 1..5
files.class # => Array because parameter multipage is true

file=Convert.new("/dir/myfile.pdf").to :eps, :filename => "/tmp/test.eps"
file.class # => File

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ Convert


25
26
27
28
29
# File 'lib/rghost/convert.rb', line 25

def initialize(filename)
  @filename=filename
  
  
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error


22
23
24
# File 'lib/rghost/convert.rb', line 22

def error
  @error
end

#errorsObject (readonly)

Returns the value of attribute errors


22
23
24
# File 'lib/rghost/convert.rb', line 22

def errors
  @errors
end

Instance Method Details

#to(device, options = {}) ⇒ Object


32
33
34
35
36
37
38
39
40
# File 'lib/rghost/convert.rb', line 32

def to(device, options={})
  rge=RGhost::Engine.new(@filename,{:convert=>true}.merge(options))
  
  
  out=rge.render(device)
  @error=rge.error
  @errors=rge.errors
  out
end