PrawnEx.Page (prawn_ex v0.3.0)

Copy Markdown View Source

Represents a single PDF page with a list of content operations.

Content ops are stored in order and emitted by the PDF writer. Supported ops:

  • {:set_font, font_name, size}
  • {:text, string}
  • {:text_at, {x, y}, string}
  • {:line, {x1, y1}, {x2, y2}}
  • {:move_to, {x, y}}, {:line_to, {x, y}} (path building; then stroke/1)
  • {:rectangle, x, y, width, height}
  • :stroke, :fill
  • {:set_non_stroking_gray, g} (fill and text)
  • {:set_stroking_gray, g} (lines and strokes)
  • {:set_non_stroking_rgb, r, g, b} (fill and text, 0..1)
  • {:set_stroking_rgb, r, g, b} (lines and strokes, 0..1)
  • {:image, image_id, x, y, width, height} (draw image XObject)

Summary

Functions

Appends an annotation (e.g. link) to the page. Returns the updated page.

Appends a content operation to the page. Returns a new Page (immutable).

Creates a new empty page.

Types

content_op()

@type content_op() ::
  {:set_font, String.t(), number()}
  | {:text, String.t()}
  | {:text_at, {number(), number()}, String.t()}
  | {:line, {number(), number()}, {number(), number()}}
  | {:move_to, {number(), number()}}
  | {:line_to, {number(), number()}}
  | {:rectangle, number(), number(), number(), number()}
  | :stroke
  | :fill
  | {:set_non_stroking_gray, number()}
  | {:set_stroking_gray, number()}
  | {:set_non_stroking_rgb, number(), number(), number()}
  | {:set_stroking_rgb, number(), number(), number()}
  | {:image, pos_integer(), number(), number(), number(), number()}

t()

@type t() :: %PrawnEx.Page{annotations: [map()], content_ops: [content_op()]}

Functions

add_annotation(page, annot)

@spec add_annotation(t(), map()) :: t()

Appends an annotation (e.g. link) to the page. Returns the updated page.

add_op(page, op)

@spec add_op(t(), content_op()) :: t()

Appends a content operation to the page. Returns a new Page (immutable).

new()

@spec new() :: t()

Creates a new empty page.