Files
fil/docs/snippets/elixir/getting-started/extract_with_ocr.md
Henrik Jess Nielsen b4c07d3693
All checks were successful
Deploy fil (kreuzberg) / deploy (push) Successful in 49s
Nomad changes
2026-06-01 23:40:55 +02:00

498 B

defmodule ExtractWithOcr do
  def extract_scanned_document do
    # Build configuration with OCR settings as JSON string
    config = ~s({"ocr": {"backend": "tesseract", "language": "eng"}})

    case Kreuzberg.extract_file_sync("scanned.pdf", nil, config) do
      {:ok, result} ->
        IO.puts("Extracted via OCR:")
        IO.puts(result)
        :ok

      {:error, reason} ->
        IO.puts("OCR extraction failed: #{reason}")
        :error
    end
  end
end