This commit is contained in:
24
docs/snippets/wasm/ocr/ocr_elements.md
Normal file
24
docs/snippets/wasm/ocr/ocr_elements.md
Normal file
@@ -0,0 +1,24 @@
|
||||
```typescript title="WASM"
|
||||
import init, { extractBytes } from "kreuzberg-wasm";
|
||||
|
||||
await init();
|
||||
|
||||
const documentData = await fetch("scanned.pdf").then((res) => res.arrayBuffer());
|
||||
|
||||
const result = await extractBytes(documentData, "application/pdf", {
|
||||
ocr: {
|
||||
backend: "tesseract",
|
||||
language: "eng",
|
||||
element_config: {
|
||||
include_elements: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (result.ocr_elements) {
|
||||
for (const element of result.ocr_elements) {
|
||||
console.log("Text:", element.text);
|
||||
console.log("Confidence:", element.confidence);
|
||||
}
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user