invoicify
v1.0.0
Published
An invoice generator tool to help you generate minimal and clean pdf invoices/reciepts.
Downloads
6
Maintainers
Readme
Invoicify
Table of Contents
Introduction
Invoicify is a Node.js package that creates professional PDF invoices. It uses the pdf-lib
library for PDF generation and includes a basic invoice template.
Example
Installation
To install the invoicify package, run the following command in your project directory:
npm install invoicify
Usage
To generate an invoice using this package:
Import the necessary functions:
import { generateInvoice, basic } from 'invoicify';
Prepare your invoice data:
const invoiceData = { companyName: 'Your Company', companyUrl: 'www.yourcompany.com', logoPath: './path/to/your/logo.png', // ... (other invoice details) };
Generate the PDF:
const pdfBytes = await generateInvoice(basic, invoiceData);
Save the PDF:
import fs from 'fs/promises'; await fs.writeFile('invoice.pdf', pdfBytes);
API Reference
generateInvoice(template, data)
Generates a PDF invoice based on the provided template and data.
Parameters:
template
: The invoice template function (usebasic
for the default template)data
: An object containing invoice information (see Invoice Data Format)
Returns: A Promise that resolves to PDF bytes
basic
The default invoice template function. Pass this to generateInvoice
to use the basic template.
Invoice Data Format
The data
object passed to generateInvoice
should have the following format:
{
companyName: String,
companyUrl: String,
logoPath: String,
companyPhone: String,
companyEmail: String,
companyAddress: String,
invoiceNumber: String,
invoiceDate: String,
customerName: String,
customerAddress: String,
customerEmail: String,
customerPhone: String,
items: [
{ name: String, qty: String, price: String, total: String },
// ... more items
],
subtotal: String,
shipping: String,
tax: String,
total: String,
supportEmail: String,
notes: [String]
}
Troubleshooting
Common issues and solutions:
- Missing dependencies: Ensure all peer dependencies are installed (pdf-lib, qr-image)
- File not found: Check that the
logoPath
in your invoice data points to a valid image file - Incorrect data format: Verify that your invoice data object matches the expected structure
For further assistance, please open an issue on the package's GitHub repository.