All prompts
Document generation Beginner

Generate an invoice

Create invoices with company branding, itemized charges, totals, and table headers that repeat across pages

invoicebillingfinancialbusiness

What this recipe does

This recipe creates invoice PDFs through the pdf-mcp MCP server. It takes two steps:

  1. The agent builds a complete HTML document with print CSS.
  2. It passes that HTML to html_to_pdf through the MCP server, which renders the PDF.

The invoice table uses thead { display: table-header-group }, which repeats the column headers on every page. Each row avoids splitting across page breaks. For margin boxes, page counters, named pages, and other print CSS techniques, attach PRINT.md to your prompt. The full API reference is in SKILL.md.

The prompt

Invoice generator
Create a complete HTML invoice with embedded CSS, then use pdf-mcp to render it as a PDF.

Include all of 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; }

Use base64 data URIs or absolute URLs for images.

Use these 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]

When the HTML is ready, call html_to_pdf to render the invoice as a PDF.

How it works

With the pdf-mcp MCP server connected, the agent:

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

By default, the tool stores the PDF privately and returns document metadata with a signed browser view link. Set storage_mode="memory" to receive an embedded PDF resource without storing it. Set return_binary=true to store the PDF and include that resource as well. The client decides how to present an EmbeddedResource. See the MCP server docs for setup and storage modes for details.

CSS rules for pagination

These styles repeat the table header and keep rows and totals together in a multi-page invoice:

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

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

/* Avoid splitting 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

  • Include complete invoice data for a better result.
  • Add your logo as a URL or file.
  • Describe the look you want, such as modern, classic, or minimal.
  • For complex layouts, attach PRINT.md so the agent has the full print CSS reference.

Variations

Minimal invoice

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

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

Call html_to_pdf with the completed HTML.

Detailed invoice with payment history

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

- [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 completed HTML.

Multi-currency invoice

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

- [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 completed HTML.