Caml drawings in PostScript

Version 1.2

Pierre Weis

1  What is GraphPS ?

GraphPS is a Caml library that generates PostScript files from Caml graphics drawings.
With GraphPS you can print your Caml drawings or easily incorporate them into another document.

GraphPS provides a module similar to the usual graphics drawings module Graphics of the regular Caml distribution. This module, also named Graphics, has (almost) the same signature as the original Graphics module. Thus, using the GraphPS Graphics module, your Caml drawing programs transparently generate PostScript files (that can be encapsulated into TeX  or LATEX  files), instead of drawing graphics directly onto the screen. You can also use GraphPS to send your drawings to a PostScript interpreter or print them on any printer that understands PostScript or for which gs has a driver.

2  Download and Licence

GraphPS is distributed under the LGPL license.

You can freely obtain the latest version of GraphPS from the following URL:

3  Using GraphPS

3.1  The overall picture

Intended usage of this library could be seen as a three phases process:

3.2  Generation a file with GraphPS

A PostScript program corresponding to your Graphics sequence of commands is printed to the standard output of the program when close_graph () is evaluated (hence your program should normally end by close_graph ()).

4  Using the PostScript files produced by GraphPS

4.1  Direct visualization

You can visualize directly the files using any PostScript visualizers, for instance ghostview, gs, or gv.

4.2  Including PostScript files into your LATEX  files

This is not exactly a GraphPS problem, but a simple example may help to solve this LATEX  problem.

A very simple way to include your caml_drawings.eps file, is as follows: For instance, the following line will draw the drawings of the file euro.eps, centered in the current line.

5  Fonts

The fonts suitable for PostScript output are not the X fonts. Hence, when drawing characters, you must set the font to one of the available PostScript fonts, that is one of: If you try to set the font to something else GraphPS will emit a warning and raise Failure with argument set_font.

6  Trouble shooting

6.1  Caml problems

Most of the time, your original Caml program should work just fine with no modification when using the Graphics module provided by GraphPS.

However, some Graphics commands are not supported by the GraphPS library, since they have no meaning for PostScript files (e.g. mouse events handling commands). If the original program uses such commands, you should remove them.

6.2  PostScript problems

To ensure proper inclusion of generated PostScript files, GraphPS does not add any showpage order at the end of the file.

If you want to send the produced PostScript file directly to a PostScript printer, you may be obliged to add a showpage order at the end of the file.

This document was translated from LATEX by HEVEA.