ExPdfium.Text (ExPdfium v0.4.3)

Copy Markdown View Source

Repair extracted text degraded by legacy font encodings, recovering canonical Unicode. This is a deliberate, explicit layer over the raw text the NIF returns — extract_text/2 is never silently changed.

This is font-encoding canonicalization, not Unicode Normalization. For NFC/NFKC (ligatures, presentation forms), pipe through String.normalize/2.

Regimes

A regime names a text-encoding pathology and (when recoverable) its repair. Phase 1 ships one: :thai_pua (see ExPdfium.Text.Repair.ThaiPua).

{text, report} = ExPdfium.Text.repair(raw)              # :auto
{text, report} = ExPdfium.Text.repair(raw, regimes: [:thai_pua])
regimes        = ExPdfium.Text.detect(raw)

Summary

Functions

Detect (don't transform) which regimes apply. Returns one entry per firing regime.

Repair text. :regimes is :auto (default) or a list of regime ids.

Types

report()

@type report() :: %{applied: [map()], flagged: [map()]}

Functions

detect(text)

@spec detect(binary()) :: [map()]

Detect (don't transform) which regimes apply. Returns one entry per firing regime.

repair(text, opts \\ [])

@spec repair(
  binary(),
  keyword()
) :: {binary(), report()}

Repair text. :regimes is :auto (default) or a list of regime ids.