PaperForge.Page (PaperForge v0.2.0)

Copy Markdown View Source

Represents a PDF page and its drawing operations.

Pages store high-level operations until they are added to a document.

Summary

Functions

Compiles the page and adds it to a document.

Adds a circle operation.

Compiles the page operations into an uncompressed content-stream binary.

Returns the bottom content boundary.

Returns the usable page height after margins.

Returns the left content boundary.

Returns the top content boundary.

Returns the usable page width after margins.

Adds a JPEG or PNG image from a path or binary.

Adds a line operation.

Creates a new page.

Adds a rectangle operation.

Adds a line of text.

Adds wrapped multiline text.

Types

operation()

@type operation() ::
  {:text, binary(), keyword()}
  | {:text_box, binary(), keyword()}
  | {:line, keyword()}
  | {:rectangle, keyword()}
  | {:circle, keyword()}
  | {:image, binary(), keyword()}

t()

@type t() :: %PaperForge.Page{
  height: number(),
  margins: PaperForge.Margins.t(),
  operations: [operation()],
  origin: PaperForge.Coordinates.origin(),
  width: number()
}

Functions

add_to_document(page, document)

@spec add_to_document(t(), PaperForge.Document.t()) :: PaperForge.Document.t()

Compiles the page and adds it to a document.

circle(page, options)

@spec circle(
  t(),
  keyword()
) :: t()

Adds a circle operation.

content(page)

@spec content(t()) :: binary()

Compiles the page operations into an uncompressed content-stream binary.

This function is retained for compatibility with PaperForge v0.1.0. Image operations require a document and therefore cannot be compiled through this function.

content_bottom(page)

@spec content_bottom(t()) :: number()

Returns the bottom content boundary.

content_height(page)

@spec content_height(t()) :: number()

Returns the usable page height after margins.

content_left(page)

@spec content_left(t()) :: number()

Returns the left content boundary.

content_top(page)

@spec content_top(t()) :: number()

Returns the top content boundary.

content_width(page)

@spec content_width(t()) :: number()

Returns the usable page width after margins.

image(page, source, options)

@spec image(t(), binary(), keyword()) :: t()

Adds a JPEG or PNG image from a path or binary.

line(page, options)

@spec line(
  t(),
  keyword()
) :: t()

Adds a line operation.

new(options \\ [])

@spec new(keyword()) :: t()

Creates a new page.

rectangle(page, options)

@spec rectangle(
  t(),
  keyword()
) :: t()

Adds a rectangle operation.

text(page, text, options \\ [])

@spec text(t(), binary(), keyword()) :: t()

Adds a line of text.

text_box(page, text, options)

@spec text_box(t(), binary(), keyword()) :: t()

Adds wrapped multiline text.