visionvalt-receipt-generator

1.1.7 • Public • Published

Receipt PDF Generator

Overview

The Receipt PDF Generator is a Node.js module that creates a professional PDF receipt based on provided receipt data. This module utilizes the pdfkit library to generate the receipt PDF file.

Usage

To use the Receipt PDF Generator, follow these steps:

  1. Import the Module: Import the generatePDFFile function from the module into your script.

  2. Prepare Receipt Data: Define the receipt data object with all necessary fields.

  3. Call the Function: Call the generatePDFFile function with the receipt data and the desired output file path.

Function Details

generatePDFFile(receiptData, outputFilePath)

Parameters:

receiptData: An object containing all necessary receipt information. outputFilePath: The file path where the PDF will be saved. Returns: The file path where the PDF has been saved.

Receipt Data Object The receiptData object should include the following properties:

date: Date of the receipt (e.g., '2024-08-17'). planName: Name of the plan or service. originalPrice: The original price before GST. logoPath: Path to the logo image. contactEmail: Contact email for support. contactMobile: Contact mobile number for support. invoiceID: Unique invoice identifier. items: Array of items with descriptions and amounts. billingPerson: Object with billing person's details (name, address, city, state, zip, country). paymentMethod: Method used for payment (e.g., 'Credit Card'). transactionID: Transaction identifier. additionalNotes: Additional notes about the transaction. gstRate: GST rate as a decimal (e.g., 0.18 for 18%).

Example Code

Here's a sample usage of the Receipt PDF Generator:

const { generatePDFFile } = require('./path/to/your/module');
const path = require('path');

// Define the receipt data
const receiptData = {
  date: '2024-08-17',
  planName: 'Premium Plan',
  originalPrice: 100.00,
  logoPath: 'assets/logo.png',
  contactEmail: 'support@example.com',
  contactMobile: '+1234567890',
  invoiceID: 'INV-2024-0001',
  items: [
    { description: 'Service Fee', amount: 50.00 },
    { description: 'Additional Charges', amount: 10.00 }
  ],
  billingPerson: {
    name: 'John Doe',
    address: '123 Elm Street',
    city: 'Springfield',
    state: 'IL',
    zip: '62701',
    country: 'USA'
  },
  paymentMethod: 'Credit Card',
  transactionID: 'TRX-2024-123456',
  additionalNotes: 'Payment was processed successfully.',
  gstRate: 0.18 // GST rate as a decimal (18% GST)
};

// Define the path where the PDF will be saved
const outputFilePath = path.join(__dirname, 'custom_receipt_path.pdf');

// Generate the PDF file
generatePDFFile(receiptData, outputFilePath);






License
This project is licensed under the MIT License. See the LICENSE file for details.

Package Sidebar

Install

npm i visionvalt-receipt-generator

Weekly Downloads

3

Version

1.1.7

License

MIT

Unpacked Size

9.44 kB

Total Files

5

Last publish

Collaborators

  • abhijitu18