Skip to content

Create ISDOC.PDF (PDF/A-3 with ISDOC attachment), create ISDOCX (ZIP archive with PDF and ISDOC) or extract ISDOC from PDF - Czechia's standard invoice format for data exchange

License

Notifications You must be signed in to change notification settings

deltazero-cz/node-isdoc-pdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ISDOC-PDF Node.js library

ISDOC is an XML Invoicing Standard for the Czech Republic.

This library can:

  • extract ISDOC invoices from PDFs
  • create ISDOC.PDF (PDF/A-3B with ISDOC attached)
  • create IDDOCX archives (zips with PDF and ISDOC)

It also provides Node.js API for ISDOC format, see node-isdoc, incl. XSD xchema validation.

Installation

npm i isdoc-pdf

To create ISDOC.PDF (PDF/A-3B with ISDOC attached), this package depends on Bash-like shell and Ghostscript, see isdoc-pdf (bash).

Usage

Extract ISDOC from existing PDF

import { hasISDOC, extractISDOC } from 'isdoc-pdf'

const plainInvoice = await fs.readFile('invoice.pdf'),
      isdocInvoice = await fs.readFile('invoice.isdoc.pdf')

await hasISDOC(plainInvoice)
// -> false

await hasISDOC(isdocInvoice)
// -> true

await extractISDOC(plainInvoice)
// -> null 

await extractISDOC(isdocInvoice)
// -> Invoice { DocumentType: number, ID: string, IssueDate: Date, ... }

Create ISDOC.PDF (attach ISDOC to PDF and convert into PDF/A-3)

import { attachISDOC } from 'isdoc-pdf'

const invoice = await fs.readFile('invoice.pdf'),
      isdoc = await fs.readFile('invoice.isdoc')

const pdfa = await attachISDOC(invoice, isdoc)
// -> Buffer with PDF/A-3

Create ISDOC.PDF with a new Invoice

import { Invoice, attachISDOC } from 'isdoc-pdf'

const isdoc = new Invoice({
  DocumentType: 1,
  ID: '2022123456',
  ... // see https://github.com/deltazero-cz/node-isdoc
})

const pdf = await fs.readFile('invoice.pdf')

const pdfa = await attachISDOC(pdf, isdoc)
// -> Buffer with PDF/A-3

Create IDDOCX archives (ZIP archives with PDF and ISDOC)

import { createISDOCX } from 'isdoc-pdf'

const invoice = await fs.readFile('invoice.pdf'),
      isdoc = await fs.readFile('invoice.isdoc')

const isdocx = await createISDOCX(invoice, invoice)
// -> Buffer with ISDOCX (ZIP archive)

Create IDDOCX with a new Invoice

import { Invoice, createISDOCX } from 'isdoc-pdf'

const isdoc = new Invoice({
  DocumentType: 1,
  ID: '2022123456',
  ... // see https://github.com/deltazero-cz/node-isdoc
})

const pdf = await fs.readFile('invoice.pdf')

const isdocx = await createISDOCX(pdf, isdoc)
// -> Buffer with ISDOCX (ZIP archive)