Press (press v0.1.0)

Copy Markdown View Source

Press is a dependency-free, pure-Elixir HTML+CSS to PDF engine.

Summary

Functions

Renders an HTML string with optional CSS and options into a PDF binary.

Renders an HTML string into a PDF binary, raising on error.

Functions

render(html, opts \\ [])

@spec render(
  String.t(),
  keyword()
) :: {:ok, binary()} | {:error, term()}

Renders an HTML string with optional CSS and options into a PDF binary.

Options

  • :css — external CSS string applied before embedded <style> blocks.
  • :images — a map of %{src => binary_data} for image references.

Examples

iex> {:ok, pdf} = Press.render("<h1>Invoice #123</h1>")
iex> is_binary(pdf)
true

render!(html, opts \\ [])

@spec render!(
  String.t(),
  keyword()
) :: binary()

Renders an HTML string into a PDF binary, raising on error.

Same as render/2, but returns the PDF binary directly or raises a RuntimeError if rendering fails.

Examples

iex> pdf = Press.render!("<h1>Invoice #123</h1>")
iex> is_binary(pdf)
true