Skip to main content

panthalassa_parsers 0.5.1 copy "panthalassa_parsers: ^0.5.1" to clipboard
panthalassa_parsers: ^0.5.1 copied to clipboard

Pure-Dart, zero-FFI document parsers for healthcare, EDI, binary, PDF, office, EPUB, email, HTML, Markdown, CSV and common image documents, with SHA-256/384/512 content addressing.

example/main.dart

// Minimal CLI to exercise the parsers on a real file.
//
//   dart run example/main.dart path/to/document.pdf
//
// Uses dart:io only here in the example (not in the library), so the library
// stays web-safe.
import 'dart:convert';
import 'dart:io';

import 'package:panthalassa_parsers/panthalassa_parsers.dart';

Future<void> main(List<String> args) async {
  if (args.isEmpty) {
    stderr.writeln('usage: dart run example/main.dart <file>');
    exitCode = 64;
    return;
  }

  final file = File(args.first);
  if (!file.existsSync()) {
    stderr.writeln('no such file: ${args.first}');
    exitCode = 66;
    return;
  }

  final bytes = await file.readAsBytes();
  final registry = ParserRegistry.standard();

  try {
    final result = await registry.parseInIsolate(bytes);
    stdout.writeln('format      : ${result.format.label}');
    stdout.writeln('documentId  : ${result.documentId}');
    stdout.writeln('bytes       : ${result.byteLength}');
    stdout.writeln(
      'metadata    : ${const JsonEncoder.withIndent('  ').convert(result.metadata)}',
    );
    if (result.warnings.isNotEmpty) {
      stdout.writeln('warnings    :');
      for (final w in result.warnings) {
        stdout.writeln('  - $w');
      }
    }
    if (result.hasText) {
      final preview = result.text!.length > 1000
          ? '${result.text!.substring(0, 1000)}…'
          : result.text!;
      stdout.writeln('text        :\n$preview');
    }
  } on ParseException catch (e) {
    stderr.writeln('parse failed: $e');
    exitCode = 65;
  }
}
4
likes
160
points
103
downloads

Documentation

API reference

Publisher

verified publisheryardenah.com

Weekly Downloads

Pure-Dart, zero-FFI document parsers for healthcare, EDI, binary, PDF, office, EPUB, email, HTML, Markdown, CSV and common image documents, with SHA-256/384/512 content addressing.

Repository (GitHub)
View/report issues

Topics

#documents #parsers

License

MIT (license)

Dependencies

archive, args, meta, pointycastle, pqforge, swissarmyknife, xml

More

Packages that depend on panthalassa_parsers