emon 0.3.0-preview.8
emon: ^0.3.0-preview.8 copied to clipboard
PDF and image to semantic HTML and JSON, with OCR that just works: the emon core, the platform's OCR adapters, and model packs fetched on demand.
emon #
PDF and image to semantic HTML and JSON, with OCR that works on this platform out of the box. The pure-Dart turnkey of emon: emon_core, plus the OCR adapters of each platform,
plus the defaults of emon's turnkey table. For Flutter apps use emon_flutter (it adds ML Kit on Android and a ChangeNotifier for pack downloads).
import 'package:emon/emon.dart';
final emon = await openEmon();
final model = await emon.convert(EmonInput.file('scan.pdf'));
print(await model.html());
await emon.close();
- The default OCR engines are Windows.Media.Ocr on Windows, Apple Vision on iOS and macOS, and Tesseract on Linux. Standalone Dart on Android uses Tesseract when the app enables it. Flutter on Android uses ML Kit through
emon_flutter. Enable native engines with the adapter'sbundlebuild-hook option or supply aNativeAdaptertoopenEmon. - Language models are packs, fetched on first use over the platform's own HTTPS stack, verified against a SHA-256 catalogue, and cached.
emon.engines(),emon.prepare(),emon.packs.ensure(),onPackNeededandemon.packs.eventslet app code decide what is downloaded and show progress.EMON_OFFLINE=1orpacks: PackMode.neverfetches nothing. - Conversions still use a PDF's usable embedded text if OCR cannot run. When an OCR failure leaves the entire document unread, conversion throws an
EmonErrorwith the available failure details. dart run example/main.dart --engine vision scan.pdf out.html.
On the web #
The same API runs on Flutter web and Dart web over emon's wasm build and the JS SDK: pass web: WebAssets(...) (see emon_core's README) to openEmon. Nothing is downloaded by the library on the web, and tesseract.js loads its own models from where you serve them.