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

About RGhost

Ruby Ghostscript (RGhost) is a library for document developers wanting a quick and easy way to generate pdf files. Notable features include: inserting images, vector drawing , text,font support , EPS template support and multiple output formats. RGhost acts as a Ruby wrapper over the Ghostscript engine enriched by a predefined set of Postscript(ps) functions. For example:

In Ruby code you’ll write:


doc.horizontal_line :middle, :start_in => 3, :size => 2

This gets translated into the following Postscript function. Note how this is not actually raw Postscript; instead, it makes use of a set of predefined functions shipped with RGhost.


3 unit 2 unit exch gsave current_row row_height sqrt add moveto 0 rlineto stroke grestore

Unless embarking into deep Postscript wizardry you don’t need to be aware of this fact.

Basically RGhost is a helper for creating Postscript documents. The resulting Postscript document is rendered to the target format (usually pdf but not just) by invoking Ghostscript, the free Postscript interpreter. Ghostscript settings vary a lot depending on your platform. Initially RGhost was developed for *nix environments where Ghostscript is (almost always) native and used as a printing filter (CUPS, Windows Print Service, LPRng etc) and also as a document format converter.

During the conversion of the postscript code to the desired format, four files are created, three of them being temporary.

  1. input: The input file is a pure postscript file with a .rgin extension that will be automatically removed after the conversion process, even if errors show up.
  2. errors: Using a .rgerr extension, its content are the errors generated by ghostscript. It’ll be deleted after the conversion. The content of the file is available on the errors variable of the RGhost::Engine class.
  3. log: The log file is set using the option :logfile of the RGhost::Engine class, appending all logs to it. Disabled by default.
  4. output: The output files will have the extension passed to the RGhost::Engine#render method. For multi-page formats it will return an array of files. These files aren’t deleted automatically, meaning that the developer will have to deal with them.
Last edited by shairontoledo, Fri Dec 19 12:17:20 -0800 2008
Home | Edit | New
Versions: