PaperForge.Page (PaperForge v1.1.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 PDF outline/bookmark pointing to this page.

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 named destination on this page.

Adds a highlight annotation over a rectangular text region.

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

Adds a line operation.

Adds a URI link annotation over a rectangular area.

Adds an internal link annotation to a named destination.

Adds an ordered or unordered list.

Creates a new page.

Adds a PDF text-note annotation.

Adds a paragraph using the multiline text-box layout engine.

Adds a vector path made of move, line, cubic curve, and close segments.

Adds a rectangle operation.

Adds a basic table.

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()}
  | {:link, binary(), keyword()}
  | {:link_to, binary() | atom(), keyword()}
  | {:destination, binary() | atom(), keyword()}
  | {:bookmark, binary(), keyword()}
  | {:note, binary(), keyword()}
  | {:highlight, 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.

bookmark(page, title, options \\ [])

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

Adds a PDF outline/bookmark pointing to this page.

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.

destination(page, name, options \\ [])

@spec destination(t(), binary() | atom(), keyword()) :: t()

Adds a named destination on this page.

highlight(page, contents, options)

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

Adds a highlight annotation over a rectangular text region.

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.

link(page, uri, options)

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

Adds a URI link annotation over a rectangular area.

list(page, items, options)

@spec list(t(), [term()], keyword()) :: t()

Adds an ordered or unordered list.

new(options \\ [])

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

Creates a new page.

note(page, contents, options)

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

Adds a PDF text-note annotation.

paragraph(page, text, options)

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

Adds a paragraph using the multiline text-box layout engine.

path(page, segments, options \\ [])

@spec path(t(), [PaperForge.Graphics.Path.segment()], keyword()) :: t()

Adds a vector path made of move, line, cubic curve, and close segments.

rectangle(page, options)

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

Adds a rectangle operation.

table(page, rows, options)

@spec table(t(), [[term()]], keyword()) :: t()

Adds a basic table.

Rows are lists of cell values. Table cells are drawn with rectangles and text operations so they work with the normal font pipeline.

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.