Factur-X and Order-X JS library
Generate and extract Factur-X and Order-X invoices in TypeScript, using pdf-lib and libxmljs.
Usage
CLI
npx @stafyniaksacha/facturx --help
bunx @stafyniaksacha/facturx --help
npx @stafyniaksacha/facturx generate \
--pdf input.pdf
--xml input.xml
--output output.pdf
npx @stafyniaksacha/facturx extract input.pdf > output.xml
npx @stafyniaksacha/facturx check input.xml \
--flavor facturx \
--level en16931 \
Node.js
npm install @stafyniaksacha/facturx
import { readFile } from 'node:fs/promises'
import { generate, extract, check } from '@stafyniaksacha/facturx'
const pdf = await readFile('/path/to/input.pdf')
const xml = await readFile('/path/to/input.xml')
const buffer = await generate({
pdf,
xml,
check: true,
flavor: 'facturx',
level: 'en16931',
language: 'en-GB',
meta: {
author: 'John Doe',
title: 'John Doe',
subject: 'John Doe',
keywords: ['John', 'Doe'],
},
})
const [filename, content] = await extract({
pdf,
check: true,
flavor: 'facturx',
level: 'en16931',
})
const valid = await check({
xml,
flavor: 'facturx',
level: 'en16931',
})
Usefull links
License
Based on original work of akretion/factur-x
python library by Alexis de Lattre