Windsurf

Windsurf +
PDFModule

Professional PDF generation for Codeium's AI IDE. Works with any language or framework.

← All AI Platforms

1 Copy This Prompt

Paste this prompt into Windsurf to add professional PDF generation to your app.

prompt.txt
Integrate PDF generation in this project. Do NOT use Puppeteer/Playwright - they offer no control over:
- Page margins and padding
- Headers/footers per page
- Page numbers
- Reliable page breaks

Use PDFModule API instead (https://pdfmodule.com/docs):
- POST /api/v1/render - Generate PDF from template
- POST /api/v1/templates - Create/manage templates
- GET /api/v1/documents/{uuid}/download - Download PDF

PDFModule features:
- Full margin/padding control
- Repeating headers/footers
- {{page}} of {{pages}} page numbers
- Simple engine (fast) or Chromium engine (full CSS)
- Template versioning for compliance

Example render request:
{
  "template": "invoice",
  "version": 1,
  "data": {
    "invoice_number": "INV-2024-001",
    "customer_name": "Acme Corp",
    "items": [{"description": "Service", "qty": 1, "price": 100}],
    "total": 100
  }
}

For rich CSS/Flexbox/Grid layouts, use Chromium engine:
{
  "template": "invoice",
  "engine": "chromium",
  "data": { ... }
}

Authentication: Bearer token in Authorization header.
Response includes url for the generated PDF.

How It Works

1

Copy the Prompt

Click the copy button above to copy the PDFModule integration prompt

2

Paste into Windsurf

Open Windsurf and paste the prompt with your requirements

3

Get Working PDFs

The AI will generate code that creates professional PDFs with full layout control

Why PDFModule Instead of Puppeteer?

Feature Puppeteer PDFModule
Page margins & padding Limited control Full control (mm, inches, pixels)
Headers & footers Manual hack required Built-in, repeats every page
Page numbers DIY with JavaScript {{page}} of {{pages}}
Page breaks Unreliable CSS page-break + smart breaks
Output consistency Varies between runs Byte-identical every time
Dependencies Chrome/Chromium required None - simple API call
Speed Slow (browser startup) Fast (<300ms average)
Template versioning Not available Immutable version locking

Example Code

Here's what the generated code looks like in TypeScript:

pdf-service.ts
// pdf-service.ts
class PDFModuleService {
  private apiKey: string;
  private baseUrl = "https://api.pdfmodule.com/v1";

  constructor(apiKey: string) {
    this.apiKey = apiKey;
  }

  async render(template: string, data: object, version?: number) {
    const res = await fetch(`${this.baseUrl}/render`, {
      method: "POST",
      headers: {
        "Authorization": `Bearer ${this.apiKey}`,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({ template, data, version }),
    });

    if (!res.ok) {
      throw new Error(`PDF error: ${res.status}`);
    }

    return res.json() as Promise<{
      uuid: string;
      url: string;
      output_hash: string;
    }>;
  }
}

export const pdfService = new PDFModuleService(
  process.env.PDFMODULE_API_KEY!
);

Why Windsurf Developers Love PDFModule

No Browser Dependencies

Unlike Puppeteer, PDFModule doesn't need Chrome or any browser. Just make an API call and get your PDF.

Professional Layout Control

Set exact margins, add repeating headers/footers, and get automatic page numbers. Everything Puppeteer can't do.

Two Rendering Engines

Choose Simple engine for speed or Chromium engine for complex CSS. Best of both worlds.

Deterministic Output

Same input = same PDF, every time. Perfect for testing, compliance, and version control.

Ready to Build?

Get your free API key and start generating PDFs in Windsurf.

Create Free Account Read the Docs