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.pdfRequest Body
The request body must be a JSON object containing the following fields:
Main Fields
| Parameter | Description | Required | Default Value |
|---|---|---|---|
invoiceTitle | The title of the document. | No | "Invoice" |
logo | URL of a logo image. | No | None |
invoiceTo | Recipient's details. | Yes | |
invoiceFrom | Sender's details. | Yes | |
paymentMethod | Payment method to be used. | No | None |
invoiceDate | Date invoice was issued. | Yes | |
dueDate | Payment due date. | No | None |
items | Array of invoice items. | Yes | |
additionalFields | Array of additional fields. | No | None |
subtotalFields | Array for taxes or fees. | No | None |
terms | Terms and conditions. | No | None |
currency | Currency for pricing. | No | "USD" |
primaryColor | Primary template color (hex). | No | "#000000" |
invoiceNo | Unique invoice identifier. | No | INV-timestamp |
The items Array
Each object in the items array should have the following structure:
| Parameter | Description | Required | Default Value |
|---|---|---|---|
description | A description of the item. | Yes | |
price | The price of the item. | Yes | |
tax | The tax rate for the item. | No | 0 |
The additionalFields Array
Each object in the additionalFields array should have the following structure:
| Parameter | Description | Required |
|---|---|---|
label | The label for the field. | Yes |
value | The 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:
| Parameter | Description | Required |
|---|---|---|
name | The name of the field (e.g., "Tax", "Fee"). | Yes |
value | The value to be applied. | Yes |
type | The type of value ("percentage" or "fixed"). | Yes |
sign | The sign of the value ("+" or "-"). | Yes |