npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@venomous-maker/dmvic-file-reader

v1.0.0

Published

Isomorphic (Node + browser) OCR reader that extracts structured data from Kenyan DMVIC motor insurance certificates supplied as PDF or image, powered by tesseract.js.

Readme

@venomous-maker/dmvic-file-reader

Isomorphic OCR reader that extracts structured data from Kenyan DMVIC (Digital Motor Vehicle Insurance Certificate) documents supplied as a PDF or an image — on both the backend (Node) and the frontend (browser).

Powered by tesseract.js for OCR and pdf.js for PDF rasterization, with built-in watermark removal tuned for these certificates (they overlay diagonal "DUPLICATE" / "FILE COPY" / repeating "INSURANCE CERTIFICATE" watermarks that otherwise wreck OCR).

Companion to dmvic-ts, the TypeScript client for the DMVIC API.

Install

npm install @venomous-maker/dmvic-file-reader

tesseract.js and pdfjs-dist are regular dependencies. On Node, PDF rendering and image binarization additionally need the native canvas, installed automatically as an optional dependency:

npm install @napi-rs/canvas   # only if it did not install automatically

Quick start

import { DmvicFileReader } from '@venomous-maker/dmvic-file-reader';

const reader = new DmvicFileReader();

// Accepts a path (Node), Buffer/Uint8Array, ArrayBuffer, Blob/File (browser),
// a data: URL, or an http(s) URL — PDF or image, auto-detected.
const { certificate, text, pages } = await reader.read('./Certificate-C27605244.pdf');

console.log(certificate);
// {
//   certificateNo:   'C27605244',
//   policyHolder:    'Simon Kithome',
//   policyNo:        'MOR-0701-1-2026 (TPO)',
//   commencingDate:  '20/07/2026 ; 12:19 EAT',
//   expiring:        '18/08/2026',
//   registrationNo:  'KVT676T',
//   chassisNumber:   'NZE-65T65T',
//   coverType:       'PRIVATE CAR',
//   insurer:         'AKI / Bima Yangu'
// }

await reader.close(); // free the tesseract worker

Browser

import { DmvicFileReader } from '@venomous-maker/dmvic-file-reader';

const reader = new DmvicFileReader();
input.addEventListener('change', async () => {
  const file = input.files[0];           // a File/Blob
  const { certificate } = await reader.read(file);
  render(certificate);
});

Everything runs client-side — no file ever leaves the browser.

Extracted fields (IDmvicCertificate)

| Field | Example | Notes | |---|---|---| | certificateNo | C27605244 | Recovered from the file name when masked on-page | | policyHolder | Simon Kithome | | | policyNo | MOR-0701-1-2026 (TPO) | | | commencingDate | 20/07/2026 ; 12:19 EAT | As printed | | expiring | 18/08/2026 | | | registrationNo | KVT676T | | | chassisNumber | NZE-65T65T | | | coverType | PRIVATE CAR | ECoverType | | insurer | AKI / Bima Yangu | |

Unresolved fields are null — the result shape is always complete.

Options

await reader.read(input, {
  languages: 'eng',   // tesseract language(s)
  dpi: 300,           // PDF render DPI (higher = sharper, slower)
  preprocess: true,   // binarize to strip the watermark (recommended)
  threshold: 100,     // 0-255 darkness cutoff for binarization
  fileName: 'Certificate-C27605244.pdf', // for cert-number recovery
  logger: (m, p) => console.log(m, p),   // progress
});

Force a specific reader with reader.readPdf(input, opts) or reader.readImage(input, opts).

Architecture

The package is built from small, injectable contracts (interfaces), each with a default implementation you can swap:

| Interface | Default implementation | Responsibility | |---|---|---| | IFileReader | ImageReader, PdfReader | Public read contract | | IOcrEngine | TesseractOcrEngine | Image → text | | IPdfRasterizer | PdfjsRasterizer | PDF → per-page images | | IImagePreprocessor | BinarizePreprocessor | Watermark removal | | — | DmvicCertificateParser | Text → structured fields |

ImageReader and PdfReader both extends AbstractReader, which owns the shared pipeline (normalize input → images → OCR → parse). Inject your own collaborators to customize any stage:

import {
  DmvicFileReader,
  type IOcrEngine,
} from '@venomous-maker/dmvic-file-reader';

class MyOcrEngine implements IOcrEngine { /* ... */ }

const reader = new DmvicFileReader({ ocrEngine: new MyOcrEngine() });

Errors

All failures throw a typed DmvicReaderError with a machine-readable code (UNSUPPORTED_INPUT, PDF_RENDER_FAILED, OCR_FAILED, PREPROCESS_FAILED, PARSE_FAILED, MISSING_DEPENDENCY, ENVIRONMENT_UNSUPPORTED).

Scripts

npm run build       # dual CJS + ESM build (tsup) with .d.ts
npm test            # jest test suite
npm run typecheck   # tsc --noEmit
npm run docs        # typedoc

License

ISC © Morgan Okumu