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 🙏

© 2024 – Pkg Stats / Ryan Hefner

invoice-pdfkit

v1.0.11

Published

Generate an invoice, receipt or return PDF file with pdfkit

Downloads

31

Readme

Invoice-pdfkit

Business document generator

  • License: MIT License
  • Author: Matteljay
  • Language: JavaScript with TypeScript definitions
  • IDE: Visual Studio Code
  • Homepage: https://libersystems.com

Table of contents

About

invoice-pdfkit attempts to standardize and internationalize the creation of common business pdf documents. Retail articles and hourly job declarations often require documents such as: invoice, price quotation, packing slip, receipt, return checklist and refund proofs. Those can now be generated from three simple JavaScript objects: company, order and payment, all very flexible with optional fields. Traditional bank transfer and cryptocurrency transactions on all layers are supported. Total amounts and optional tax compliance such as VAT and sales taxes are automatically calculated from your list of prices.

Example

Invoice example page 1 Invoice example page 2

Minimal code usage, install this module in your project folder: npm i invoice-pdfkit

const tradePDF = require("invoice-pdfkit");
const fs = require("fs");

const myCompany = {
  company: "Your Awesome Name",
  email: "[email protected]",
  web: "https://that-buzz.org",
};

const myOrder = {
  id: "S4TIX8GX",
  date: {
    created: 1659372135311,
    due: 1655118412147,
  },
  bill: {
    company: "SomeTarget Inc.",
    email: "[email protected]",
  },
  items: [
    {
      id: "w85",
      desc: "Expensive Watch",
      tax: "21",
      qty: "18",
      price: "2545.25",
    },
    {
      id: "s63",
      desc: "Repair service in hours",
      tax: "9",
      qty: "2",
      price: "32.0",
    },
  ],
  total: {
    discount: 41,
    stateTax: 10,
    fedTax: 5.1,
    ship: 7.24,
  },
};

console.log("Language options: " + tradePDF.getLanguages());
tradePDF.init({
  logo: fs.existsSync("logo.jpg") ? fs.readFileSync("logo.jpg") : undefined,
  company: myCompany,
  currency: "USD",
});
const pdfData = tradePDF.invoice(myOrder);
fs.writeFileSync("simple.pdf", pdfData);
console.log("Generated simple.pdf");

More complete examples with PDF output are available in test/. If you clone this repo, npm run tsstart will regenerate the example files.

Features

  • Integration with the Node Package Manager: invoice-pdfkit
  • Easy to translate for your language, see the locales/ folder.
  • Can be used to declare working hours as well as a list of articles and their prices.
  • Total price is automatically calculated, factoring in several price inputs.
  • Common types of VAT and sales tax fields are supported.
  • Exchange rate specification for final payment in a different currency (such as bitcoin) is supported.
  • QR-code support for both legacy bank transfers and crypto payments, especially useful for the long address payload of bitcoin lightning network invoices.
  • Short-form human readable crypto addresses such as Ethereum's ENS can be specified in either the company or payment object at the same location as the bank account number or IBAN/SEPA number.
  • A list of all supported fields can be found in types/main.d.ts. TypeScript support is optional. Most of the fields are demonstrated by the example files.

Donation

This software is free as in transparent, open source and can be used per MIT license. Not free as in zero cost, 1000 lines of code didn't grow on a tree and no ads are integrated. Buy the writer a coffee or whatever you consider reasonable if you decide to use it in the current or modified state. Further details in CONTACT.md.

Translation

Currently supported languages:

  • English (GB, US, CA, AU, ...)
  • Dutch (NL and Flanders BE)
  • German (DE, AT, CH)

To add your language, go to the locales/ folder and create a folder specific to your language with a translation.json inside. After forking and editing, feel free to create a Git pull request. Don't forget to add your language to this README.md as well.

Notes

Some fields may be missing for your region. For example: most dutch entrepreneurs are forced to register a KvK number. Simply add that text in the company.registration field: "KvK 0441.956.713". Australian banks may require a BSB number for payments. Simply add that text to payment.bankID or company.bankID: "BSB 033-548". All supported fields can be found here: types/main.d.ts. If you still feel some essential fields are missing, a Git pull request is welcome.

The source code includes a reasonably advanced flex-table implementation for pdfkit, see the module src/flex-table.js this may be used in your own projects.