package cairo2

  1. Overview
  2. Docs

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

To create a cairo context cr that will write the the PDF file fname with dimensions w×h points, do let cr = Cairo.create(Cairo.PDF.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 PDF surface of the specified size in points to be written to fname.

  • parameter w

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

  • parameter h

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

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

create_for_stream output width height creates a PDF 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.0 inch)

  • parameter h

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

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

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

  • parameter w

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

  • parameter h

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

    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.

OCaml

Innovation. Community. Security.