# `PdfElixide.Editor`
[🔗](https://github.com/r8/pdf_elixide/blob/v0.3.1/lib/pdf_elixide/editor.ex#L1)

Mutable, in-memory PDF editor backed by `pdf_oxide`'s `DocumentEditor`.

# `save_opts`

```elixir
@type save_opts() :: [
  incremental: boolean(),
  compress: boolean(),
  linearize: boolean(),
  garbage_collect: boolean()
]
```

Options accepted by `save/3` and `save!/3`.

  * `:incremental` — write an incremental update instead of a full
    rewrite. Defaults to `false`.
  * `:compress` — compress streams. Defaults to `true`.
  * `:linearize` — linearize the output for fast web view. Defaults
    to `false`.
  * `:garbage_collect` — drop unreferenced objects. Defaults to
    `true`.

Defaults mirror `pdf_oxide`'s `SaveOptions::full_rewrite()`, so
calling `save/2` is equivalent to `save/3` with no options.

# `t`

```elixir
@type t() :: %PdfElixide.Editor{ref: reference(), source_path: Path.t() | nil}
```

# `from_binary`

```elixir
@spec from_binary(binary()) :: {:ok, t()} | {:error, term()}
```

Opens a PDF document for editing from the given binary data.

# `from_binary!`

```elixir
@spec from_binary!(binary()) :: t()
```

Opens a PDF document for editing from the given binary data,
raising an error if it fails.

# `open`

```elixir
@spec open(Path.t()) :: {:ok, t()} | {:error, term()}
```

Opens a PDF document for editing from the specified file path.

# `open!`

```elixir
@spec open!(Path.t()) :: t()
```

Opens a PDF document for editing from the specified file path,
raising an error if it fails.

# `save`

```elixir
@spec save(t(), Path.t(), save_opts()) :: :ok | {:error, term()}
```

Writes all in-memory changes to a PDF file at the given path.

# `save!`

```elixir
@spec save!(t(), Path.t(), save_opts()) :: :ok
```

Writes all in-memory changes to a PDF file at the given path, raising an error if it fails.

# `source_path`

```elixir
@spec source_path(t()) :: Path.t() | nil
```

Returns the file path from which the editor was loaded, or `nil` if it
was loaded from binary data.

# `to_binary`

```elixir
@spec to_binary(t(), save_opts()) :: {:ok, binary()} | {:error, term()}
```

Serialises all in-memory changes into a PDF binary.

The result is a fully self-contained PDF that can be written to disk,
stored in a database, or streamed over HTTP.

Accepts the same `t:save_opts/0` keyword list as `save/3`. Note that
`:incremental` is not supported here — upstream returns
`{:error, _}` because incremental updates can only be appended to
the original file.

# `to_binary!`

```elixir
@spec to_binary!(t(), save_opts()) :: binary()
```

Serialises all in-memory changes into a PDF binary, raising an error if it fails.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
