Build an Invoice Template
Step-by-step guide to creating a professional invoice template with data binding.
What You'll Build
By the end of this guide, you'll have a professional invoice template that can be filled with dynamic data via the API. The invoice will include a header with your company branding, customer details, a line items table, and totals.
This guide assumes you've already created a project and have access to the Studio Editor. If not, follow the Quick Start first.
Step 1: Set Up the Page
- Open your project and click New Template
- Name it "Invoice"
- In Page Settings, select A4 size with Portrait orientation
- Set margins to 40px on all sides to give space for content
Step 2: Add the Company Header
- Add an Image element for your company logo. Position it in the top-left corner.
- Add a Text element with your company name. Use a large font size (24px) and bold weight.
- Below that, add more text elements for your company address, phone, and email.
Since company details stay the same across invoices, you can type them directly rather than using data binding.
Step 3: Add Invoice Details
Now add the dynamic fields that will change per invoice:
- Add a Field element. Set the field key to
invoice_number. Position it near the top-right. - Add another field for
invoice_datebelow it - Add a field for
due_date
Add a label text element next to each field (e.g., "Invoice #", "Date:", "Due:").
Step 4: Add Customer Information
- Add a text element with "Bill To" as a section header
- Add a Field element with key
customer_name - Add fields for
customer_address,customer_email
Step 5: Create the Line Items Table
This is the most important dynamic part of an invoice:
- Add a Table element and position it in the middle of the page
- Set the table's data binding key to
line_items - Configure columns:
- Description — field key:
description, width: 50% - Quantity — field key:
quantity, width: 15%, align: center - Unit Price — field key:
unit_price, width: 15%, align: right - Amount — field key:
amount, width: 20%, align: right
- Description — field key:
- Style the header row with a dark background and white text
- Add alternating row colors for readability
Step 6: Add Totals
- Below the table, add field elements for:
subtotaltaxtotal— make this larger and bold
- Position them right-aligned to match the table's Amount column
Step 7: Add a Footer
Add text elements at the bottom for payment terms or notes:
- A field element with key
notesfor custom per-invoice notes - Static text for standard payment terms (e.g., "Payment due within 30 days")
Step 8: Preview and Save
- Click Preview to see your template with placeholder data
- Adjust spacing, font sizes, and colors until it looks professional
- Save your template
Generate via API
Now you can generate invoices programmatically:
TypeScript
const pdf = await client.generate({
templateId: "tmpl_your_invoice_template",
data: {
invoice_number: "INV-2026-042",
invoice_date: "January 15, 2026",
due_date: "February 14, 2026",
customer_name: "Acme Corporation",
customer_address: "123 Business Ave, NY 10001",
customer_email: "billing@acme.com",
line_items: [
{
description: "Website Design",
quantity: "1",
unit_price: "$3,000.00",
amount: "$3,000.00",
},
{
description: "Development (40 hours)",
quantity: "40",
unit_price: "$150.00",
amount: "$6,000.00",
},
],
subtotal: "$9,000.00",
tax: "$720.00",
total: "$9,720.00",
notes: "Thank you for your business!",
},
});Your invoice template is reusable. Design it once, then generate thousands of unique invoices by passing different data each time.