用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/skeletorflet/opencode-kit --skill pdf-generation命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Web accessibility (a11y). WCAG 2.1, ARIA, keyboard navigation, screen readers, testing tools.
Analytics and event tracking. Product analytics, Mixpanel, PostHog, Segment, GDPR compliance, event taxonomy.
UI animation patterns. CSS transitions, Framer Motion, GSAP, performance, accessibility.
基于 SOC 职业分类
正在显示 SKILL.md
| name | pdf-generation |
| description | PDF generation patterns. Puppeteer, @react-pdf/renderer, PDFKit, invoices, reports. |
Choose approach based on: design complexity vs performance needs.
| Approach | Tool | When |
|---|---|---|
| HTML → PDF | Puppeteer / Playwright | Complex layouts, pixel-perfect |
| Code-first | PDFKit / jsPDF | Simple, programmatic |
| React → PDF | @react-pdf/renderer | Component-based, moderate |
| LaTeX | LaTeX + pandoc | Academic, mathematical |
| Word → PDF | docx + convert | Document-style |
import puppeteer from "puppeteer";
async function generatePDF(html: string): Promise<Buffer> {
const browser = await puppeteer.launch({
headless: "new",
args: ["--no-sandbox", "--disable-setuid-sandbox"],
});
const page = await browser.newPage();
await page.setContent(html, { waitUntil: "networkidle0" });
const pdf = await page.pdf({
format: "A4",
printBackground: true,
margin: { top: "20mm", right: "15mm", bottom: "20mm", left: "15mm" },
});
await browser.close();
return Buffer.from(pdf);
}
// Express route
app.get("/invoices/:id/pdf", async (req, res) => {
const invoice = await db.invoice.findUniqueOrThrow({ where: { id: req.params.id } });
const html = renderInvoiceHtml(invoice);
const pdf = await generatePDF(html);
res.setHeader("Content-Type", "application/pdf");
res.setHeader("Content-Disposition", `attachment; filename="invoice-${invoice.number}.pdf"`);
res.send(pdf);
});
import { Document, Page, View, Text, StyleSheet, pdf } from "@react-pdf/renderer";
const styles = StyleSheet.create({
page: { padding: 40, fontFamily: "Helvetica" },
header: { flexDirection: "row", justifyContent: "space-between", marginBottom: 30 },
title: { fontSize: 24, fontWeight: "bold", color: "#1a1a1a" },
table: { display: "flex", width: "100%" },
row: { flexDirection: "row", borderBottomWidth: 1, borderBottomColor: "#e5e7eb", padding: "8 0" },
cell: { flex: 1, fontSize: 10 },
total: { fontSize: 14, fontWeight: "bold", textAlign: "right", : },
});
() {
(
);
}
pdfBuffer = ().();
// Puppeteer: reuse browser instance
let browser: puppeteer.Browser | null = null;
async function getBrowser() {
if (!browser) {
browser = await puppeteer.launch({ headless: "new", args: ["--no-sandbox"] });
}
return browser;
}
// Queue PDF generation (avoid overwhelming server)
await pdfQueue.add("generate-invoice", { invoiceId }, {
attempts: 3,
removeOnComplete: true,
});
// Cache generated PDFs in S3
const cached = await s3.getObject({ Bucket, Key: `invoices/${id}.pdf` }).catch(() => null);
if (cached) return cached.Body;
const pdf = await generatePDF(html);
await s3.putObject({ Bucket, Key: `invoices/${id}.pdf`, Body: pdf, ContentType: });
| Document | Key Features |
|---|---|
| Invoice | Line items table, totals, payment info |
| Report | Charts (embed as images), data tables |
| Contract | Page numbers, signature fields |
| Label | QR code, barcode, specific dimensions |
| Certificate | Custom fonts, decorative elements |
| ❌ Don't | ✅ Do |
|---|---|
| New Puppeteer browser per request | Reuse browser instance |
| Synchronous generation in request | Queue for heavy docs |
| No caching | Cache in S3/CDN |
| External fonts via @import | Embed fonts directly |
| No timeout | Set navigation timeout |