Files
fil/docs/snippets/wasm/ocr/ocr_extraction.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

830 B

import { enableOcr, extractFromFile, initWasm } from "@kreuzberg/wasm";

await initWasm();
await enableOcr();

const fileInput = document.getElementById("file") as HTMLInputElement;
const file = fileInput.files?.[0];

if (file) {
  const result = await extractFromFile(file, file.type, {
    ocr: {
      backend: "kreuzberg-tesseract",
      language: "eng",
    },
  });
  console.log(result.content);
}
import { enableOcr, extractFile, initWasm } from "@kreuzberg/wasm";

await initWasm();
await enableOcr(); // Uses native kreuzberg-tesseract backend

const result = await extractFile("./scanned_document.png", "image/png", {
  ocr: {
    backend: "kreuzberg-tesseract",
    language: "eng",
  },
});
console.log(result.content);