-
Notifications
You must be signed in to change notification settings - Fork 46
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.
- 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.
- 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.
- log: The log file is set using the option :logfile of the RGhost::Engine class, appending all logs to it. Disabled by default.
- 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.