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

czech-invoice-parser

v0.1.0

Published

Client-side PDF parser for Czech invoices using PDF.js

Readme

Czech Invoice Parser

Client-side PDF parser for Czech invoices using PDF.js. Extracts structured data from Czech invoice PDFs directly in the browser.

Features

  • Client-side processing - All parsing happens in the browser, no server required
  • PDF.js powered - Robust PDF text extraction
  • Czech invoice support - Optimized for Czech invoice formats
  • Own data filtering - Exclude your own company data from detection
  • TypeScript - Full type safety
  • Zero dependencies (except pdfjs-dist)
  • Test-driven - Comprehensive test coverage

Installation

pnpm add czech-invoice-parser

Quick Start

Basic Usage

import { parseInvoice } from 'czech-invoice-parser';

// Parse from File input
const fileInput = document.querySelector('input[type="file"]');
fileInput.addEventListener('change', async (e) => {
  const file = e.target.files[0];
  const result = await parseInvoice(file);

  console.log('Invoice number:', result.data.invoiceNumber);
  console.log('Total:', result.data.totalWithVat);
  console.log('Supplier IČO:', result.data.supplier?.ico);
});

With Own Company Data Filtering

import { parseInvoice, type ParserOptions } from 'czech-invoice-parser';

const options: ParserOptions = {
  ownCompanyData: {
    ico: '12345678',
    dic: 'CZ12345678',
    email: '[email protected]'
  },
  ownIdentifiers: {
    accountNumbers: ['123456789/0100']
  }
};

const result = await parseInvoice(file, options);
// Now your own company data won't be confused with supplier data

Parse Multiple Invoices

import { parseInvoices } from 'czech-invoice-parser';

const files = Array.from(fileInput.files);
const results = await parseInvoices(files, options);

results.forEach(result => {
  console.log('Invoice:', result.data.invoiceNumber);
  console.log('Confidence:', result.data.confidence);
});

API Reference

parseInvoice(source, options?)

Parse a single invoice PDF.

Parameters:

  • source: File | Uint8Array | ArrayBuffer | string - PDF source
  • options: ParserOptions - Optional parsing configuration

Returns: Promise<ParseResult>

parseInvoices(sources, options?)

Parse multiple invoice PDFs in batch.

Parameters:

  • sources: Array of PDF sources
  • options: ParserOptions - Optional parsing configuration

Returns: Promise<ParseResult[]>

Types

InvoiceData

Extracted invoice data structure:

interface InvoiceData {
  invoiceNumber?: string;
  variableSymbol?: string;
  issueDate?: Date;
  dueDate?: Date;
  taxDate?: Date;
  supplier?: CompanyInfo;
  customer?: CompanyInfo;
  totalWithoutVat?: number;
  vatAmount?: number;
  totalWithVat?: number;
  currency?: string;
  payment?: PaymentInfo;
  confidence?: number; // 0-1
}

CompanyInfo

Company information (supplier or customer):

interface CompanyInfo {
  name?: string;
  address?: string;
  ico?: string;      // Company registration number
  dic?: string;      // VAT number
  email?: string;
  phone?: string;
}

PaymentInfo

Payment information:

interface PaymentInfo {
  accountNumber?: string;
  bankCode?: string;
  iban?: string;
  swift?: string;
}

ParserOptions

Configuration options:

interface ParserOptions {
  // Own company data to exclude from supplier detection
  ownCompanyData?: Partial<CompanyInfo>;

  // Additional own identifiers to filter out
  ownIdentifiers?: {
    ico?: string[];
    dic?: string[];
    emails?: string[];
    accountNumbers?: string[];
  };

  debug?: boolean;
  language?: 'cs' | 'en';
}

ParseResult

Result with metadata:

interface ParseResult {
  data: InvoiceData;
  errors?: string[];
  warnings?: string[];
  processingTime?: number; // in milliseconds
}

Detected Fields

The parser attempts to extract the following information:

Invoice Information

  • Invoice number (Číslo faktury)
  • Variable symbol (Variabilní symbol)
  • Issue date (Datum vystavení)
  • Due date (Datum splatnosti)
  • Tax date (Datum zdanitelného plnění)

Company Information

  • Company name (Název)
  • IČO (Company registration number)
  • DIČ (VAT number)
  • Email address
  • Phone number
  • Address

Payment Information

  • Bank account number (Číslo účtu)
  • IBAN
  • Bank code

Amounts

  • Total without VAT (Celkem bez DPH)
  • VAT amount (DPH)
  • Total with VAT (Celkem k úhradě)
  • Currency (default: CZK)

Confidence Score

Each parsed invoice includes a confidence score (0-1) indicating the reliability of the extraction:

  • > 0.7 - High confidence, most fields detected
  • 0.4 - 0.7 - Medium confidence, some fields missing
  • < 0.4 - Low confidence, many fields missing

Use in Svelte/SvelteKit

<script lang="ts">
  import { parseInvoice, type ParseResult } from 'czech-invoice-parser';

  let result: ParseResult | null = null;

  async function handleFile(event: Event) {
    const file = (event.target as HTMLInputElement).files?.[0];
    if (file) {
      result = await parseInvoice(file);
    }
  }
</script>

<input type="file" accept=".pdf" on:change={handleFile} />

{#if result}
  <div>
    <h3>Invoice: {result.data.invoiceNumber}</h3>
    <p>Total: {result.data.totalWithVat} {result.data.currency}</p>
    <p>Supplier IČO: {result.data.supplier?.ico}</p>
  </div>
{/if}

Testing

The package includes comprehensive tests. To run tests:

pnpm test

To add test invoices, place PDF files in the test-invoices/ directory.

Development

# Install dependencies
pnpm install

# Run dev server with demo
pnpm dev

# Build package
pnpm build

# Run tests
pnpm test

# Type check
pnpm check

How It Works

  1. PDF Text Extraction: Uses PDF.js to extract text content from PDF files
  2. Pattern Matching: Applies regex patterns optimized for Czech invoice formats
  3. Data Extraction: Identifies and extracts structured data (IČO, DIČ, dates, amounts)
  4. Own Data Filtering: Filters out your company data to avoid confusion with supplier data
  5. Confidence Calculation: Calculates confidence score based on detected fields

Limitations

  • Only text-based PDFs are supported (scanned images require OCR)
  • Parser is optimized for Czech invoices
  • Complex multi-page invoices may have reduced accuracy
  • Custom invoice formats may require tuning

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

For issues and questions, please open an issue on GitHub.