Document spec: immutable struct holding options and a list of pages.
Options:
:page_size-:a4,:letter, etc. (default:a4):margins- optional%{left: pt, right: pt, top: pt, bottom: pt}
The last page in pages is the "current" page for appending content.
Images are stored in images (list of image specs) and referenced by 1-based index.
Summary
Functions
Appends an image spec to the document. Returns {doc, image_id} (image_id is 1-based).
Appends a new page and returns the updated document. The new page becomes current.
Appends an annotation (e.g. link) to the current page. Returns the updated document.
Appends a content op to the current page. If there is no page, adds one first. Returns the updated document.
Returns the current page (last in the list), or nil if no pages.
Injects ops at the start and/or end of a page's content. Used for headers/footers.
Creates a new document with optional options.
Types
@type opts() :: keyword()
@type t() :: %PrawnEx.Document{ images: [map()], opts: keyword(), pages: [PrawnEx.Page.t()] }
Functions
@spec add_image(t(), map()) :: {t(), pos_integer()}
Appends an image spec to the document. Returns {doc, image_id} (image_id is 1-based).
Appends a new page and returns the updated document. The new page becomes current.
Appends an annotation (e.g. link) to the current page. Returns the updated document.
@spec append_op(t(), PrawnEx.Page.content_op()) :: t()
Appends a content op to the current page. If there is no page, adds one first. Returns the updated document.
@spec current_page(t()) :: PrawnEx.Page.t() | nil
Returns the current page (last in the list), or nil if no pages.
@spec inject_page_ops(t(), non_neg_integer(), [PrawnEx.Page.content_op()], [ PrawnEx.Page.content_op() ]) :: t()
Injects ops at the start and/or end of a page's content. Used for headers/footers.
page_index is 0-based. Returns the document with that page's content_ops
set to prepend_ops ++ current_ops ++ append_ops.
Creates a new document with optional options.
Examples
iex> doc = PrawnEx.Document.new()
iex> doc.pages
[]
iex> doc = PrawnEx.Document.new(page_size: :letter)
iex> doc.opts[:page_size]
:letter