public
Description: RGhost is a document creation and conversion API. It uses the Ghostscript framework for the format conversion, utilizes EPS templates and is optimized to work with larger documents. Support(PDF,PS,GIF,TIF,PNG,JPG,etc)
Home | Edit | New

Converting PDF into other formats

RGhost has a “utility“ class for converting PDF documents to other formats. The options from Document#render and

RGhost::Engine#render are used for the Convert#to method. Example:

preview = RGhost::Convert.new('/my/dir/file.pdf')
preview.to :png, :multipage => true, :resolution => 72  #returns an Array of Files

The :range option can be used to convert only a subset of a multipage file. Example, returns an Array of Files:

pages = RGhost::Convert.new('/tmp/test.pdf').to :jpeg, :multipage => true, :range => 5..6

Only the first page


  thumb = RGhost::Convert.new('/tmp/test.pdf').to :png  #returns File

Checking for errors

 
  thumb = RGhost::Convert.new('/tmp/test.pdf')
  out = thumb.to :png  #returns File
  if thumb.error
    raise Exception.new “Image error”
  else
     File.cp(out,”/my/dir”)
  end

Last edited by shairontoledo, Mon Aug 03 04:43:19 -0700 2009
Home | Edit | New
Versions: