Question

I made an OCaml program that draws L-systems using the turtle interpretation. What I'm looking for is to save what I draw with graphics to an image of EPS and PDF file. But I never done this before and I don't know how to do, so I've looked in graphics librairy and all I've found is get_image to get an Image file and dump_image to get an matrix color from an Image file but from here I don't know how to save the data into a EPS or PDF file.

Does anybody have an idea about how to do that?

Was it helpful?

Solution

I never used it, but there is graphicspdf which implements the Graphics interface but outputs to PDF (opam install graphicspdf). Similar for postscript is GraphPS (not packaged in opam).

Alternatively if you program is well designed you should be able to render to multiple backends. In that case Vg allows you to render to PDF, SVG or the html canvas (opam install vg). There is also ocaml-cairo that provides you bindings to the C library libcairo and allows you to render to multiple rendering backends (opam install cairo).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top