NativeElixirPdfUtilities.Text (native_elixir_pdf_utilities v0.5.1)
View SourceBest-effort embedded text extraction for classic PDFs.
This module is native Elixir and does not perform OCR. It reads PDF content streams, decodes supported Flate-compressed streams, applies ToUnicode CMaps where present, and reconstructs approximate page layout from text matrix coordinates.
Summary
Functions
Extracts embedded text from a PDF binary.
Reads a PDF file and extracts embedded text from it.
Types
@type error_reason() :: :empty_pdf_text | :invalid_options | :invalid_pdf_input | :invalid_path | File.posix()
@type extract_option() :: {:layout, boolean()}
@type object_record() :: %{ obj: integer(), gen: integer(), tokens: [NativeElixirPdfUtilities.Tokenizer.token()] }
Functions
@spec extract(binary(), [extract_option()]) :: {:ok, String.t()} | {:error, {error_reason(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}
Extracts embedded text from a PDF binary.
Options:
:layout- when true, approximate visible text layout using spaces and line breaks. This is currently the only output mode and defaults to true.
@spec extract_file(String.t(), [extract_option()]) :: {:ok, String.t()} | {:error, {error_reason(), NativeElixirPdfUtilities.Diagnostics.diagnostic()}}
Reads a PDF file and extracts embedded text from it.