Module Cairo.PS

The PostScript surface is used to render cairo graphics to Adobe PostScript files and is a multi-page vector surface backend.

To create a cairo context cr that will write the the PS file fname with dimensions w×h points, do let cr = Cairo.create(Cairo.PS.create fname w h). Do not forget to call Surface.finish(get_target cr) when you are done drawing because the file may not be fully written before.

val create : string -> w:float -> h:float -> Surface.t

create fname w h creates a PostScript surface of the specified size in points to be written to fname.

  • parameter w

    width of the surface, in points (1 point = 1/72 inch)

  • parameter h

    height of the surface, in points (1 point = 1/72 inch)

val create_for_stream : ( string -> unit ) -> w:float -> h:float -> Surface.t

create_for_stream output w h creates a PostScript surface of the specified size in points to be written incrementally to the stream represented by output. Any exception that output raises is considered as a write error.

  • parameter w

    width of the surface, in points (1 point = 1/72 inch)

  • parameter h

    height of the surface, in points (1 point = 1/72 inch)

type level =
| LEVEL_2
| LEVEL_3

Describe the language level of the PostScript Language Reference that a generated PostScript file will conform to.

val restrict_to_level : Surface.t -> level -> unit

restrict_to_level level restricts the generated PostSript file to level. See Cairo.PS.get_levels for a list of available level values that can be used here.

This function should only be called before any drawing operations have been performed on the given surface. The simplest way to do this is to call this function immediately after creating the surface.

val get_levels : unit -> level list

Retrieves the list of supported levels.

val level_to_string : level -> string

level_to_string level return the string representation of the given level id.

val set_eps : Surface.t -> eps:bool -> unit

If eps is true, the PostScript surface will output Encapsulated PostScript.

This function should only be called before any drawing operations have been performed on the current page. The simplest way to do this is to call this function immediately after creating the surface. An Encapsulated PostScript file should never contain more than one page.

val get_eps : Surface.t -> bool

Check whether the PostScript surface will output Encapsulated PostScript.

val set_size : Surface.t -> w:float -> h:float -> unit

Changes the size of a PostScript surface for the current (and subsequent) pages.

This function should only be called before any drawing operations have been performed on the current page. The simplest way to do this is to call this function immediately after creating the surface or immediately after completing a page with either Cairo.show_page or Cairo.copy_page.

module Dsc : sig ... end

PostScript comments.