PDF Generation API

A comprehensive guide for developers on using the PDF Generation API to create custom invoices and receipts.

API Endpoint

To generate a PDF, send a POST request to the following endpoint:

POST /api/generate-pdf

The request should include a JSON body with the data required for the invoice or receipt.

Example cURL Request

Here is an example of how to generate a PDF using a cURL request.

bash
curl -X POST https://www.invoicea.in/api/generate-pdf -H \
"Content-Type: application/json" \
-d '{
"invoiceTitle": "Invoice",
"logo": "https://kinetixlabs.s3.us-east-1.amazonaws.com/invoicea.png",
"invoiceTo": "John Doe\n123Main St\nAnytown, USA 12345",
"invoiceFrom": "Jane Smith\n456 Oak Ave\nSomecity, USA 67890",
"paymentMethod": "Credit Card",
"invoiceDate": "2024-07-29",
"dueDate": "2024-08-12",
"items": [
    {
        "description": "Web Development Services",
        "price": 1500,
        "tax": 10
    },
    {
        "description": "Logo Design",
        "price": 500,
        "tax": 10
    }
],
"additionalFields": [
    {
        "label": "Project ID",
        "value": "P-12345"
    }
],
"subtotalFields": [
    {
        "name": "Tax",
        "value": 10,
        "type": "percentage",
        "sign": "+"
    },
    {
        "name": "Fee",
        "value": 50,
        "type": "fixed",
        "sign": "+"
    }
],
"terms": "Payment is due within 15 days.",
"currency": "USD",
"primaryColor": "#ff0000",
"invoiceNo": "INV-2024-001"
}' \
--output invoicea.pdf

Request Body

The request body must be a JSON object containing the following fields:

Main Fields

ParameterDescriptionRequiredDefault Value
invoiceTitleThe title of the document.No"Invoice"
logoURL of a logo image.NoNone
invoiceToRecipient's details.Yes
invoiceFromSender's details.Yes
paymentMethodPayment method to be used.NoNone
invoiceDateDate invoice was issued.Yes
dueDatePayment due date.NoNone
itemsArray of invoice items.Yes
additionalFieldsArray of additional fields.NoNone
subtotalFieldsArray for taxes or fees.NoNone
termsTerms and conditions.NoNone
currencyCurrency for pricing.No"USD"
primaryColorPrimary template color (hex).No"#000000"
invoiceNoUnique invoice identifier.NoINV-timestamp

The items Array

Each object in the items array should have the following structure:

ParameterDescriptionRequiredDefault Value
descriptionA description of the item.Yes
priceThe price of the item.Yes
taxThe tax rate for the item.No0

The additionalFields Array

Each object in the additionalFields array should have the following structure:

ParameterDescriptionRequired
labelThe label for the field.Yes
valueThe value of the field.Yes

The subtotalFields Array

Each object in the subtotalFields array is used to add taxes or fees and should have the following structure:

ParameterDescriptionRequired
nameThe name of the field (e.g., "Tax", "Fee").Yes
valueThe value to be applied.Yes
typeThe type of value ("percentage" or "fixed").Yes
signThe sign of the value ("+" or "-").Yes