@courseproof/parser
v0.1.1
Published
[](https://opensource.org/licenses/MIT)
Maintainers
Readme
@courseproof/parser
Multi-format certificate parser supporting PDF, images, QR codes, ZIP archives, HTML, JSON, CSV, and plain text. Extracts structured certificate data from various input formats.
Exports
Functions
| Function | Description |
|----------|-------------|
| parsePDF(buffer, options?) | Extracts text and certificate data from PDF buffers using pdfjs-dist |
| parseImage(buffer, options?) | Runs OCR via Tesseract.js on an image buffer |
| decodeQRCode(buffer) | Decodes QR codes from images using jsqr + jimp |
| parseZip(buffer, options?) | Iterates ZIP entries and parses contained PDF/HTML/JSON/CSV files |
| parseHTML(html) | Extracts certificates from HTML via JSON-LD scripts or microdata |
| parseFile(buffer, format, options?) | Dispatches to the correct parser based on InputFormat |
| extractCertFromText(text) | Regex-based extraction of certificate fields from plain text |
Interfaces
| Export | Description |
|--------|-------------|
| ParserResult | { success: boolean; certificates?: Certificate[]; text?: string; error?: string } |
| ParserOptions | { pdfPassword?: string; ocrLanguage?: string; zipPassword?: string } |
Usage
import { parsePDF, parseImage, parseFile } from "@courseproof/parser";
import fs from "node:fs";
// Parse a PDF certificate
const pdfBuffer = fs.readFileSync("certificate.pdf");
const result = await parsePDF(pdfBuffer);
console.log(result.certificates);
// Parse an image with OCR
const imgBuffer = fs.readFileSync("certificate.png");
const imgResult = await parseImage(imgBuffer, { ocrLanguage: "eng" });
// Auto-detect format and parse
const anyResult = await parseFile(pdfBuffer, "pdf");Installation
npm install @courseproof/parserLicense
MIT — see LICENSE for details.
Part of the CourseProof monorepo.
