Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including easyinvoice with all npm packages installed. Try it out:

require("pdfjs-dist/package.json"); // pdfjs-dist is a peer dependency. var easyinvoice = require("easyinvoice")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

easyinvoice v1.0.103

Easily create beautiful pdf invoices.

Easy Invoice logo

Version Build Status Coverage Status Build Status
Downloads License Pull Request's Welcome

If this package helped you out please star us on Github!
Much appreciated!
Pull Request's Welcome

Features

  • [x] Create invoices
  • [ ] List, get, update, delete invoices (api ready / npm in progress)
  • [ ] Create, list, get, update, delete clients (api ready / npm in progress)
  • [ ] More soon...

Demo

JS Fiddle: Plain Javascript
JS Fiddle: Vue
JS Fiddle: React
JS Fiddle: Angular

Installing

Using npm:

$ npm install easyinvoice --save

Using yarn:

$ yarn add easyinvoice

Using unkpg CDN:

<script src="https://unpkg.com/easyinvoice/dist/easyinvoice.min.js"></script>

Using jsDelivr CDN:

<script src="https://cdn.jsdelivr.net/npm/easyinvoice/dist/easyinvoice.min.js"></script>

Import

Html

<script src="https://unpkg.com/easyinvoice/dist/easyinvoice.min.js"></script>

NodeJS

var easyinvoice = require('easyinvoice');

Vue/React

import easyinvoice from 'easyinvoice';

Angular

import * as easyinvoice from 'easyinvoice';
//ór (not both)
import { easyinvoice } from 'easyinvoice';

Example (NodeJS)

//Import the library into your project
var easyinvoice = require('easyinvoice');

var data = {
    //"documentTitle": "RECEIPT", //Defaults to INVOICE
    "currency": "USD",
    "taxNotation": "vat", //or gst
    "marginTop": 25,
    "marginRight": 25,
    "marginLeft": 25,
    "marginBottom": 25,
    "logo": "https://www.easyinvoice.cloud/img/logo.png", //or base64
    //"logoExtension": "png", //only when logo is base64
    "sender": {
        "company": "Sample Corp",
        "address": "Sample Street 123",
        "zip": "1234 AB",
        "city": "Sampletown",
        "country": "Samplecountry"
        //"custom1": "custom value 1",
        //"custom2": "custom value 2",
        //"custom3": "custom value 3"
    },
    "client": {
        "company": "Client Corp",
        "address": "Clientstreet 456",
        "zip": "4567 CD",
        "city": "Clientcity",
        "country": "Clientcountry"
        //"custom1": "custom value 1",
        //"custom2": "custom value 2",
        //"custom3": "custom value 3"
    },
    "invoiceNumber": "2020.0001",
    "invoiceDate": "05-01-2020",
    "products": [
        {
            "quantity": "2",
            "description": "Test1",
            "tax": 6,
            "price": 33.87
        },
        {
            "quantity": "4",
            "description": "Test2",
            "tax": 21,
            "price": 10.45
        }
    ],
    "bottomNotice": "Kindly pay your invoice within 15 days."
};

//Create your invoice! Easy!
easyinvoice.createInvoice(data, function (result) {
    //The response will contain a base64 encoded PDF file
    console.log(result.pdf);
});

Async/await support

const result = await easyinvoice.createInvoice(data);
console.log(result.pdf);

To store the file locally (NodeJS)

var fs = require('fs');

const data = {};
const result = await easyinvoice.createInvoice(data);                       
await fs.writeFileSync("invoice.pdf", result.pdf, 'base64');

Download your invoice (browser only)

Using callback

const data = {};
easyinvoice.createInvoice(data, function (result) {
    easyinvoice.download('myInvoice.pdf', result.pdf);
    //  you can download like this as well:
    //  easyinvoice.download();
    //  easyinvoice.download('myInvoice.pdf');   
});

Using async/await

const data = {};
const result = await easyinvoice.createInvoice(data);                       
easyinvoice.download('myInvoice.pdf', result.pdf);
//  you can download like this as well:
//  easyinvoice.download();
//  easyinvoice.download('myInvoice.pdf');

Render(view) your invoice (browser only)

html

<!-- Only include when rendering is required -->
<script src="https://unpkg.com/pdfjs-dist/build/pdf.min.js"></script>
<script src="https://unpkg.com/pdfjs-dist/build/pdf.worker.min.js"></script>

<!-- Include pdfjs version 2.3.200 for Internet Explorer compatibility, no worker required -->
<!-- <script src="https://unpkg.com/pdfjs-dist@2.3.200/build/pdf.min.js"></script> -->

<!-- The pdf will be rendered within this div -->
<div id="pdf"></div>

css (optional)

#pdf {
  text-align: center;
}

#pdf canvas {
  border: 1px solid black;
  width: 95%;
}

js: Using Callback

var data = {};
var elementId = 'pdf';
easyinvoice.createInvoice(data, function(result) {
    easyinvoice.render(elementId, result.pdf, function(){
        console.log('Invoice rendered!');
    });
});

js: Using async/await

const data = {}; 
const elementId = 'pdf'; 
const result = await easyinvoice.createInvoice(data);      
await easyinvoice.render(elementId, result.pdf);

You could view your base64 pdf through the following website: https://base64.guru/converter/decode/pdf

Paste the base64 string and click 'Decode Base64 to PDF'.

Supported currencies

AEDAED
AFNAFN
ALLALL
AMDAMD
ANGANG
AOAAOA
ARSARS
AUDA$
AWGAWG
AZNAZN
BAMBAM
BBDBBD
BDTBDT
BGNBGN
BHDBHD
BIFBIF
BMDBMD
BNDBND
BOBBOB
BRLR$
BSDBSD
BTCBTC
BTNBTN
BTSBTS
BWPBWP
BYNBYN
BZDBZD
CADCA$
CDFCDF
CHFCHF
CLFCLF
CLPCLP
CNHCNH
CNYCN¥
COPCOP
CRCCRC
CUCCUC
CUPCUP
CVECVE
CZKCZK
DASHDASH
DJFDJF
DKKDKK
DOGEDOGE
DOPDOP
DZDDZD
EACEAC
EGPEGP
EMCEMC
ERNERN
ETBETB
ETHETH
EUR
FCTFCT
FJDFJD
FKPFKP
FTCFTC
GBP£
GELGEL
GGPGGP
GHSGHS
GIPGIP
GMDGMD
GNFGNF
GTQGTQ
GYDGYD
HKDHK$
HNLHNL
HRKHRK
HTGHTG
HUFHUF
IDRIDR
ILS
IMPIMP
INR
IQDIQD
IRRIRR
ISKISK
JEPJEP
JMDJMD
JODJOD
JPY¥
KESKES
KGSKGS
KHRKHR
KMFKMF
KPWKPW
KRW
KWDKWD
KYDKYD
KZTKZT
LAKLAK
LBPLBP
LDLD
LKRLKR
LRDLRD
LSLLSL
LTCLTC
LYDLYD
MADMAD
MDLMDL
MGAMGA
MKDMKD
MMKMMK
MNTMNT
MOPMOP
MROMRO
MRUMRU
MURMUR
MVRMVR
MWKMWK
MXNMX$
MYRMYR
MZNMZN
NADNAD
NGNNGN
NIONIO
NMCNMC
NOKNOK
NPRNPR
NVCNVC
NXTNXT
NZDNZ$
OMROMR
PABPAB
PENPEN
PGKPGK
PHPPHP
PKRPKR
PLNPLN
PPCPPC
PYGPYG
QARQAR
RONRON
RSDRSD
RUBRUB
RWFRWF
SARSAR
SBDSBD
SCRSCR
SDGSDG
SEKSEK
SGDSGD
SHPSHP
SLLSLL
SOSSOS
SRDSRD
SSPSSP
STDSTD
STNSTN
STRSTR
SVCSVC
SYPSYP
SZLSZL
THBTHB
TJSTJS
TMTTMT
TNDTND
TOPTOP
TRYTRY
TTDTTD
TWDNT$
TZSTZS
UAHUAH
UGXUGX
USD$
UYUUYU
UZSUZS
VEFVEF
VEF_BLKMKTVEF_BLKMKT
VEF_DICOMVEF_DICOM
VEF_DIPROVEF_DIPRO
VESVES
VND
VTCVTC
VUVVUV
WSTWST
XAFFCFA
XAGXAG
XAUXAU
XCDEC$
XDRXDR
XMRXMR
XOFCFA
XPDXPD
XPFCFPF
XPMXPM
XPTXPT
XRPXRP
YERYER
ZARZAR
ZMWZMW
ZWLZWL
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free