pdf-generation
PDF generation and manipulation. Puppeteer/Playwright HTML-to-PDF, PDFKit, jsPDF, React-PDF, iText (Java), ReportLab (Python). Invoices, reports, and document generation. USE WHEN: user mentions "PDF", "generate PDF", "HTML to PDF", "invoice PDF", "PDFKit", "jsPDF", "Puppeteer PDF", "React-PDF", "iText", "ReportLab" DO NOT USE FOR: PDF parsing/reading - different concern; image generation - different format
What this skill does
# PDF Generation
## Puppeteer HTML-to-PDF (recommended for complex layouts)
```typescript
import puppeteer from 'puppeteer';
async function generatePdf(html: string): Promise<Buffer> {
const browser = await puppeteer.launch({ headless: true });
const page = await browser.newPage();
await page.setContent(html, { waitUntil: 'networkidle0' });
const pdf = await page.pdf({
format: 'A4',
margin: { top: '20mm', bottom: '20mm', left: '15mm', right: '15mm' },
printBackground: true,
});
await browser.close();
return Buffer.from(pdf);
}
// Express endpoint
app.get('/api/invoice/:id/pdf', async (req, res) => {
const invoice = await getInvoice(req.params.id);
const html = renderInvoiceHtml(invoice);
const pdf = await generatePdf(html);
res.contentType('application/pdf');
res.setHeader('Content-Disposition', `attachment; filename="invoice-${invoice.number}.pdf"`);
res.send(pdf);
});
```
## PDFKit (Node.js — programmatic)
```typescript
import PDFDocument from 'pdfkit';
function createInvoicePdf(invoice: Invoice): Promise<Buffer> {
return new Promise((resolve) => {
const doc = new PDFDocument({ size: 'A4', margin: 50 });
const chunks: Buffer[] = [];
doc.on('data', (chunk) => chunks.push(chunk));
doc.on('end', () => resolve(Buffer.concat(chunks)));
// Header
doc.fontSize(20).text('INVOICE', { align: 'right' });
doc.fontSize(10).text(`#${invoice.number}`, { align: 'right' });
doc.moveDown();
// Table
doc.fontSize(12).text('Item', 50, doc.y);
doc.text('Amount', 400, doc.y - 12, { width: 100, align: 'right' });
doc.moveTo(50, doc.y).lineTo(550, doc.y).stroke();
for (const item of invoice.items) {
doc.text(item.description, 50, doc.y + 5);
doc.text(`$${item.amount.toFixed(2)}`, 400, doc.y - 12, { width: 100, align: 'right' });
}
doc.end();
});
}
```
## @react-pdf/renderer (React components to PDF)
```tsx
import { Document, Page, Text, View, StyleSheet, renderToBuffer } from '@react-pdf/renderer';
const styles = StyleSheet.create({
page: { padding: 30 },
title: { fontSize: 24, marginBottom: 20 },
row: { flexDirection: 'row', justifyContent: 'space-between', marginBottom: 5 },
});
function InvoicePdf({ invoice }: { invoice: Invoice }) {
return (
<Document>
<Page size="A4" style={styles.page}>
<Text style={styles.title}>Invoice #{invoice.number}</Text>
{invoice.items.map((item) => (
<View key={item.id} style={styles.row}>
<Text>{item.description}</Text>
<Text>${item.amount.toFixed(2)}</Text>
</View>
))}
</Page>
</Document>
);
}
// Server-side render
const buffer = await renderToBuffer(<InvoicePdf invoice={invoice} />);
```
## Python (ReportLab)
```python
from reportlab.lib.pagesizes import A4
from reportlab.platypus import SimpleDocTemplate, Table, Paragraph
from reportlab.lib.styles import getSampleStyleSheet
def generate_invoice_pdf(invoice: dict, output_path: str):
doc = SimpleDocTemplate(output_path, pagesize=A4)
styles = getSampleStyleSheet()
elements = []
elements.append(Paragraph(f"Invoice #{invoice['number']}", styles['Title']))
data = [['Item', 'Amount']]
for item in invoice['items']:
data.append([item['description'], f"${item['amount']:.2f}"])
table = Table(data, colWidths=[350, 100])
elements.append(table)
doc.build(elements)
```
## Anti-Patterns
| Anti-Pattern | Fix |
|--------------|-----|
| New browser per PDF request | Reuse browser instance, create new pages |
| No timeout on PDF generation | Set `page.setDefaultTimeout()` and abort |
| Generating PDFs synchronously in request | Use background job queue |
| Inline CSS in HTML templates | Use embedded `<style>` or `printBackground: true` |
| No memory cleanup | Close pages after use, limit concurrent generations |
## Production Checklist
- [ ] Browser instance pooling (Puppeteer/Playwright)
- [ ] PDF generation in background queue
- [ ] Memory limits and timeouts configured
- [ ] Generated PDFs stored in object storage (S3)
- [ ] Content-Disposition header for downloads
- [ ] PDF/A compliance if archiving required
Related in Image & Video
watch
IncludedWatch a video (URL or local path). Downloads with yt-dlp, extracts auto-scaled frames with ffmpeg, pulls the transcript from captions (or Whisper API fallback), and hands the result to Claude so it can answer questions about what's in the video.
physical-ai-defect-image-generation
IncludedUse when the user wants to orchestrate defect image generation, run associated setup, or handle outputs on OSMO. The Day 0 path handles cold-start with USD-to-ROI, image-edit augmentation, and AnomalyGen to create initial PCBA datasets. The Day 1 path performs inference and labeling on real images. This skill helps with first-time asset setup, creation of finetuning checkpoints, and configuring deployment. Trigger keywords: defect image generation, dig workflow, dig pipeline, defect image detection workflow, aoi pipeline, aoi anomalygen, usd2roi anomalygen, day 0 pcba, day 1 pcba, day 1 real-photo alignment, day 1 manual roi, metal surface anomaly, glass defect, anomalygen finetune, setup_pcb, setup_metal, setup_glass, setup_pretrained, dig setup, dig datasets, dig pretrained checkpoint, dig image-edit endpoint.
accelint-react-best-practices
IncludedReact performance optimization and best practices. ALWAYS use this skill when working with any React code - writing components, hooks, JSX; refactoring; optimizing re-renders, memoization, state management; reviewing for performance; fixing hydration mismatches; debugging infinite re-renders, stale closures, input focus loss, animations restarting; preventing remounting; implementing transitions, lazy initialization, effect dependencies. Even simple React tasks benefit from these patterns. Covers React 19+ (useEffectEvent, Activity, ref props). Triggers - useEffect, useState, useMemo, useCallback, memo, inline components, nested components, components inside components, re-render, performance, hydration, SSR, Next.js, useDeferredValue, combined hooks.
elevenlabs-agents
IncludedBuild conversational AI voice agents with ElevenLabs Platform using React, JavaScript, React Native, or Swift SDKs. Configure agents, tools (client/server/MCP), RAG knowledge bases, multi-voice, and Scribe real-time STT. Use when: building voice chat interfaces, implementing AI phone agents with Twilio, configuring agent workflows or tools, adding RAG knowledge bases, testing with CLI "agents as code", or troubleshooting deprecated @11labs packages, Android audio cutoff, CSP violations, dynamic variables, or WebRTC config. Keywords: ElevenLabs Agents, ElevenLabs voice agents, AI voice agents, conversational AI, @elevenlabs/react, @elevenlabs/client, @elevenlabs/react-native, @elevenlabs/elevenlabs-js, @elevenlabs/agents-cli, elevenlabs SDK, voice AI, TTS, text-to-speech, ASR, speech recognition, turn-taking model, WebRTC voice, WebSocket voice, ElevenLabs conversation, agent system prompt, agent tools, agent knowledge base, RAG voice agents, multi-voice agents, pronunciation dictionary, voice speed control, elevenlabs scribe, @11labs deprecated, Android audio cutoff, CSP violation elevenlabs, dynamic variables elevenlabs, case-sensitive tool names, webhook authentication
humanizer
IncludedHumanize AI-generated text by detecting and removing patterns typical of LLM output. Rewrites text to sound natural, specific, and human. Uses 28 pattern detectors, 560+ AI vocabulary terms across 3 tiers, and statistical analysis (burstiness, type-token ratio, readability) for comprehensive detection. Use when asked to humanize text, de-AI writing, make content sound more natural/human, review writing for AI patterns, score text for AI detection, or improve AI-generated drafts. Covers content, language, style, communication, and filler categories.
generating-mermaid-diagrams
IncludedSalesforce architecture diagrams using Mermaid with ASCII fallback. Use this skill when generating text-based diagrams for Salesforce architecture, OAuth flows, ERDs, integration sequences, or Agentforce structure. TRIGGER when: user says "diagram", "visualize", "ERD", or asks for sequence diagrams, flowcharts, class diagrams, or architecture visualizations in Mermaid. DO NOT TRIGGER when: user wants PNG/SVG image output (use generating-visual-diagrams), or asks about non-Salesforce systems.