# obsidian-text-extract

> > Work In Progress - Use with care, seriously.

Latest version **1.0.4** (published 2022-12-05) · GPL-3.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install obsidian-text-extract
pnpm add obsidian-text-extract
yarn add obsidian-text-extract
bun add obsidian-text-extract
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2022-12-05 |
| First published | 2022-11-05 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 1.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | scambier |

## Links

- npm: https://www.npmjs.com/package/obsidian-text-extract
- npm.io page: https://npm.io/package/obsidian-text-extract

## Dependencies (4)

- [dexie](https://npm.io/package/dexie.md) ^3.2.2
- [p-limit](https://npm.io/package/p-limit.md) ^4.0.0
- [pure-md5](https://npm.io/package/pure-md5.md) ^0.1.14
- [tesseract.js](https://npm.io/package/tesseract.js.md) ^3.0.3

## Recent versions

- 1.0.4 (latest) — 2022-12-05
- 1.0.3 — 2022-11-18
- 1.0.2 — 2022-11-06
- 1.0.1 — 2022-11-05
- 1.0.0 — 2022-11-05

## README

# Obsidian Text Extract Library

> Work In Progress - Use with care, seriously.

## What is this?

A library, designed for Obsidian plugins, to extract text from PDFs and images. It works by sharing a common cache and pool of workers between all library users.

It is currently used in [Omnisearch](https://github.com/scambier/obsidian-omnisearch)

## How does it work?

Since extracting text from PDFs and images takes a lot of resource, the main idea of this library is to make a globally available pool of workers, shared among all Obsidian plugins that wish to use it. As such, it is important to **not change the namespace or indexedDB database name**. Doing so would put an unnecessary strain on Obsidian that could crash it, and more generally will waste the device's resources. Be responsible.

## Installation & Usage

First, install it **with a fixed version**:
```json
"dependencies": {
    "obsidian-text-extract": "1.0.3"
}
```

(Yes I messed up with npm, and submitted the first version as `1.0.0`. Sorry.)

To use it:
```ts
import { getPdfText, getImageText } from 'obsidian-text-extract'

async function getTextFromFile(
  file: TFile
): Promise<string> {
  let content: string
  if (file.path.endsWith('.pdf')) {
    content = await getPdfText(file)
  } else if (file.path.endsWith('.png')) {
    content = await getImageText(file)
  }
  return content
}
```

## Limitations

Text extraction does not work on mobile; calling the functions will just immediately return an empty string.

## Build

You'll need [Rust](https://doc.rust-lang.org/book/ch01-01-installation.html), [wasm-pack](https://github.com/rustwasm/wasm-pack), and [pnpm](https://pnpm.io/installation). 

```sh
$ pnpm i
$ pnpm run build
```

Rust is quite slow to compile, so the first build will take some time.

---
_Source: https://npm.io/package/obsidian-text-extract · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
