All Prompts
Document Generation Beginner

Generate Invoice

Create professional invoices with itemized line items, totals, and company branding — multi-page ready with repeating table headers

invoicebillingfinancialbusiness

Overview

This recipe generates professional PDF invoices through the pdf-mcp MCP Server. The workflow is two steps:

  1. Generate HTML — The AI builds a complete HTML document with print-ready CSS
  2. Render to PDF — The AI calls html_to_pdf via the MCP Server to produce the final PDF

The invoice table uses thead { display: table-header-group } so column headers repeat on every page, and rows won’t split across page breaks. For advanced print CSS techniques (margin boxes, page counters, named pages), attach PRINT.md to your prompt or refer to SKILL.md for the full API reference.

The Prompt

Invoice Generator
Generate an invoice as a complete HTML document with embedded CSS, then render it to PDF using pdf-mcp.

The HTML must include these print CSS rules:
- @page { size: A4; margin: 2cm; }
- thead { display: table-header-group; } so headers repeat on every page
- tr { break-inside: avoid; page-break-inside: avoid; }
- Images embedded as base64 data URIs or absolute URLs

Invoice details:

Company: [Company Name]
Logo: [Logo URL or base64]
Invoice #: [Invoice Number]
Date: [Issue Date]
Due Date: [Due Date]

Bill To:
[Customer Name]
[Customer Email]
[Customer Address]

Line Items:
| Description | Quantity | Unit Price | Total |
|-------------|----------|------------|-------|
| [Item 1]    | [Qty]    | [Price]    | [Total] |
| [Item 2]    | [Qty]    | [Price]    | [Total] |

Subtotal: [Subtotal Amount]
Tax ([Tax Rate]%): [Tax Amount]
Total Due: [Total Amount]

Payment Terms: [e.g., "Net 30"]
Payment Methods: [Accepted payment methods]
Notes: [Optional notes]

After generating the HTML, call html_to_pdf to render the invoice as a PDF.

How It Works

When you give this prompt to an AI agent with the pdf-mcp MCP Server connected:

  1. The agent generates a full HTML document with print-optimized CSS
  2. The agent calls the html_to_pdf MCP tool:
html_to_pdf(
  html="<!DOCTYPE html><html>...",
  filename="invoice-2024-001.pdf"
)

Modern MCP clients like Claude Desktop handle the file directly. Otherwise the PDF is temporarily stored with a presigned download URL, or persisted in your S3-compatible cloud storage. See MCP Server docs for setup and Storage Modes for details.

Key CSS Rules

The prompt instructs the AI to include these critical styles for multi-page invoices:

@page { size: A4; margin: 2cm; }

/* Repeat table header on every page */
thead { display: table-header-group; }

/* Never split a row across pages */
tr {
  break-inside: avoid;
  page-break-inside: avoid;
}

/* Keep totals row together */
tfoot {
  break-inside: avoid;
  page-break-inside: avoid;
}

For the full print CSS reference, see PRINT.md.

Tips

  • Provide complete data — The more details you include, the better the output
  • Include branding — Add your logo as a URL or as file
  • Specify layout — Mention a style preference (modern, classic, minimal)
  • Attach PRINT.md — For complex layouts, attach PRINT.md to give the AI the full print CSS reference

Variations

Minimal Invoice

Minimal Invoice
Generate a minimal invoice as HTML with print CSS (@page A4, thead repeating, no row splitting), then render it to PDF using pdf-mcp.

- Invoice #: [Number]
- Date: [Date]
- Bill To: [Customer Name]
- Items: [Simple list of items with prices]
- Total: [Amount]

Call html_to_pdf with the generated HTML.

Detailed Invoice with Payment History

Detailed Invoice
Generate a detailed invoice with payment history as HTML with print CSS (@page A4, thead repeating, no row splitting), then render it to PDF using pdf-mcp.

- [Standard invoice fields: company, invoice #, date, bill to, line items]
- Previous Balance: [Amount]
- Payments Received: [List of payments with dates]
- Outstanding Balance: [Amount]
- Payment Schedule: [If applicable]

Call html_to_pdf with the generated HTML.

Multi-Currency Invoice

Multi-Currency Invoice
Generate an international invoice with multi-currency support as HTML with print CSS (@page A4, thead repeating, no row splitting), then render it to PDF using pdf-mcp.

- [Standard invoice fields: company, invoice #, date, bill to, line items]
- Primary Currency: [Currency]
- Exchange Rate: [Rate] (as of [Date])
- Amount in [Secondary Currency]: [Converted Amount]

Call html_to_pdf with the generated HTML.