NativeElixirPdfUtilities.Validators.TextValidator (native_elixir_pdf_utilities v0.13.0)
View SourceText-extraction validation and preparation for parsed PDF documents.
The validator consumes a shared PDF validation context, validates effective page geometry and content-stream references, decodes the streams once, and converts content syntax into operation instructions. The extractor consumes those prepared values instead of reopening page dictionaries or tokenizing content independently.
Summary
Types
A text-specific context prepared from the shared PDF context.
A validated content instruction with operands in source order.
One page prepared for strict text extraction.
A validated public text-extraction request.
Functions
Validates and tokenizes one decoded PDF content stream into instructions.
Converts one PDF numeric token into its semantic number.
Converts an exact-length list of PDF numeric tokens into floating-point values.
Prepares all resolved pages and their content streams for text extraction.
Validates a public file-extraction path before file access.
Validates and normalizes a public text-extraction request.
Validates balanced graphics-state and text-object scopes across instruction streams.
Types
@type context() :: %{ document: NativeElixirPdfUtilities.Validators.PdfValidator.document(), pages: [page_context()], preparation_stats: preparation_stats() }
A text-specific context prepared from the shared PDF context.
A validated content instruction with operands in source order.
@type page_context() :: %{ number: pos_integer(), ref: NativeElixirPdfUtilities.Validators.PdfValidator.ref(), media_box: [number()], rotation: integer(), contents: [[instruction()]] }
One page prepared for strict text extraction.
@type request() :: %{ pdf: binary(), options: %{optional(:layout) => boolean(), optional(:order) => atom()} }
A validated public text-extraction request.
Functions
@spec instructions(binary(), pos_integer()) :: {:ok, [instruction()]} | {:error, {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}
Validates and tokenizes one decoded PDF content stream into instructions.
Converts one PDF numeric token into its semantic number.
@spec numbers([term()], non_neg_integer()) :: {:ok, [float()]} | :error
Converts an exact-length list of PDF numeric tokens into floating-point values.
@spec prepare(NativeElixirPdfUtilities.Validators.PdfValidator.context()) :: {:ok, context()} | {:error, {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}
Prepares all resolved pages and their content streams for text extraction.
@spec validate_path(term(), atom()) :: {:ok, String.t()} | {:error, {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}
Validates a public file-extraction path before file access.
@spec validate_request(term(), term(), :extract | :extract_spans) :: {:ok, request()} | {:error, {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}
Validates and normalizes a public text-extraction request.
@spec validate_scopes([[instruction()]], pos_integer()) :: :ok | {:error, {atom(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}
Validates balanced graphics-state and text-object scopes across instruction streams.
The instruction lists are treated as one logical sequence so page scopes may
cross /Contents stream boundaries. Form XObjects should pass their single
instruction list separately because their scopes are independent.