Nomad changes
All checks were successful
Deploy fil (kreuzberg) / deploy (push) Successful in 49s

This commit is contained in:
Henrik Jess Nielsen
2026-06-01 23:40:55 +02:00
parent 72b1a0a6ed
commit b4c07d3693
5723 changed files with 1130655 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
```elixir title="Elixir"
alias Kreuzberg.ExtractionConfig
# Extract text from a scanned PDF using OCR
# Tesseract processes the document and returns structured content
config = %ExtractionConfig{
ocr: %{
"enabled" => true,
"backend" => "tesseract"
},
chunking: %{
"max_characters" => 1500,
"overlap" => 150
},
language_detection: %{"enabled" => true},
use_cache: true
}
{:ok, result} = Kreuzberg.extract_file("scanned_invoice.pdf", nil, config)
# Process the extracted content
content = result.content
chunks = result.chunks || []
metadata = result.metadata || %{}
IO.puts("OCR Extraction Complete:")
IO.puts("Content length: #{byte_size(content)} bytes")
IO.puts("Number of chunks: #{length(chunks)}")
IO.puts("Detected languages: #{inspect(result.detected_languages)}")
IO.puts("Creation date: #{metadata["creation_date"] || "N/A"}")
IO.puts("\nFirst 200 characters of extracted text:")
IO.puts(String.slice(content, 0..199))
```