PaperForge.Document (paper_forge v0.1.0)

Copy Markdown View Source

Internal object graph of a PDF document.

A new document automatically contains:

  • the root page tree;
  • the document catalog;
  • a default Helvetica font.

Summary

Functions

Adds a new indirect object to the document.

Adds a page reference to the document page tree.

Returns all indirect objects sorted by their object ID.

Adds document metadata.

Updates the value of an existing indirect object.

Types

t()

@type t() :: %PaperForge.Document{
  default_font: PaperForge.Reference.t(),
  info: PaperForge.Reference.t() | nil,
  next_object_id: pos_integer(),
  objects: %{optional(pos_integer()) => PaperForge.Object.t()},
  pages: PaperForge.Reference.t(),
  root: PaperForge.Reference.t()
}

Functions

add_object(document, value)

@spec add_object(t(), term()) :: {t(), PaperForge.Reference.t()}

Adds a new indirect object to the document.

Returns the updated document and a reference to the object.

append_page(document, page_reference)

@spec append_page(t(), PaperForge.Reference.t()) :: t()

Adds a page reference to the document page tree.

new()

@spec new() :: t()

objects(document)

@spec objects(t()) :: [PaperForge.Object.t()]

Returns all indirect objects sorted by their object ID.

put_metadata(document, metadata)

@spec put_metadata(t(), PaperForge.Metadata.t()) :: t()

Adds document metadata.

Calling this function more than once replaces the active metadata reference, although previous objects remain in the object graph.

update_object(document, reference, function)

@spec update_object(
  t(),
  PaperForge.Reference.t(),
  (term() -> term())
) :: t()

Updates the value of an existing indirect object.