react-pdf-pro
React PDF Pro -- PDF Generation for Next.js 16
When to Use
Trigger on any mention of: react-pdf, @react-pdf/renderer, pdf export, pdf template, cv template, pdf download, vietnamese font, renderToBuffer, PDFViewer, PDFDownloadLink, pdf styling.
Reference Files
| File | Description |
|---|---|
references/setup.md |
Version compatibility matrix, next.config.ts setup, installation, import patterns, font registration singleton |
references/vietnamese-fonts.md |
Be Vietnam Pro registration (9 weights + italics), practical 4-weight setup, hyphenation callback, self-hosting |
references/components.md |
Document, Page, View, Text, Image, Link, Note, Canvas, PDFViewer, PDFDownloadLink, BlobProvider, SVG primitives |
references/styling.md |
StyleSheet API, valid units, flexbox, dimensions, spacing, colors, text, borders, transforms, media queries |
references/cv-templates.md |
Classic (single column), Modern (accent bar), Creative (2-column sidebar) layouts with ASCII diagrams |
references/server-rendering.md |
renderToBuffer, renderToStream, renderToFile, renderToString, API route patterns |
references/client-preview.md |
PDFViewer dynamic import, usePDF hook, PDFDownloadLink patterns |
references/errors.md |
18 error entries (PDF-001 through PDF-018) with exact messages, causes, and fixes |
references/performance.md |
Font subsetting, image optimization, memoization, large documents, LRU caching strategy |
references/testing.md |
Vitest mocking, template output tests, font registration tests, API route tests, visual regression |
references/code-examples.md |
Complete font registration, full export API route, CV template with Vietnamese font |
references/advanced-examples.md |
Live preview with template switching, export button, two-column sidebar CV, react-pdf vs Puppeteer, sources |
Error Quick Lookup
| ID | Error | Fix |
|---|---|---|
| PDF-001 | require() of ES Module not supported |
serverExternalPackages: ["@react-pdf/renderer"] |
| PDF-002 | PDFViewer is a web specific API |
dynamic(() => import(...), { ssr: false }) |
| PDF-003 | Font family not registered |
Call registerFonts() before render; match family name |
| PDF-004 | ba.Component is not a constructor |
Upgrade Next.js to 14.1.1+; set serverExternalPackages |
| PDF-005 | Buffer is not assignable to BodyInit |
new Uint8Array(buffer) |
| PDF-006 | renderToBuffer() type mismatch |
Cast: component as any |
| PDF-007 | DOMMatrix is not defined |
Use ssr: false for all client PDF components |
| PDF-008 | document is not defined |
Dynamic import with ssr: false |
| PDF-009 | Vietnamese chars as boxes/? |
Register Unicode font (Be Vietnam Pro) |
| PDF-010 | Variable font wrong weight | Use static TTF files, register each weight |
| PDF-011 | Cannot find module 'zlib' |
serverExternalPackages + dynamic import |
| PDF-012 | usePDF stuck loading |
Check font URLs (CORS, 404, format) |
| PDF-013 | PDFDocument is not a constructor |
serverExternalPackages + dynamic = "force-dynamic" |
| PDF-014 | ESM/CJS conflict in Jest | Migrate to Vitest |
| PDF-015 | Page wrapping cuts content | wrap={true} minPresenceAhead={50} |
| PDF-016 | __dirname is not defined |
Handled by serverExternalPackages |
| PDF-017 | Font weight fallback wrong | Register all weights you use |
| PDF-018 | Minified React error #31 |
Ensure Text children are strings; use v4.1.0+ |
Key Patterns
Vietnamese Font Registration
import { Font } from '@react-pdf/renderer'
Font.register({
family: 'BeVietnamPro',
fonts: [
{ src: 'https://fonts.gstatic.com/s/bevietnampro/v12/...400.ttf' },
{ src: 'https://fonts.gstatic.com/s/bevietnampro/v12/...700.ttf', fontWeight: 700 },
]
})
Font.registerHyphenationCallback((word) => [word]) // Prevent Vietnamese splitting
Export API Route
// app/api/export/[id]/route.ts
import { renderToBuffer } from '@react-pdf/renderer'
export async function GET(req, { params }) {
const { id } = await params
const buffer = await renderToBuffer(<CVTemplate data={cvData} /> as any)
return new Response(new Uint8Array(buffer), {
headers: { 'Content-Type': 'application/pdf' }
})
}
Client Preview (Dynamic Import)
const PDFViewer = dynamic(
() => import("@react-pdf/renderer").then((mod) => mod.PDFViewer),
{ ssr: false }
)
More from clownnvd/claude-code-skills
tailwind-v4-pro
Tailwind CSS v4 for Next.js 16. @theme tokens, v3 migration, dark mode, PostCSS setup, design system patterns, 20 documented errors. Triggers: tailwind, tailwind v4, css, @theme, design tokens, dark mode, postcss, styling, tw classes.
2zustand-pro
Zustand v5 state management for Next.js 16. Store patterns, middleware (persist/immer/devtools), SSR hydration, CV editor multi-step wizard, 20 documented errors. Triggers: zustand, store, state management, useState replacement, global state, persist, immer.
2claude-ui
Full Claude.ai UI clone: Next.js 16 + Tailwind v4. Exact tokens, all 19 flows, sidebar, chat input, messages, settings, login, onboarding, billing, artifacts. PageFlows July 2025.
2ultimateuiux
Ultimate UI/UX design intelligence with real app flow knowledge. 93 styles, 121 palettes, 81 font pairings, 35 charts, 79 components, 62 animations, 65 WCAG criteria, 46 responsive patterns, 46 dark mode rules, 60 design tokens, 13 stacks. PLUS: Claude.ai full UI blueprint (19 flows, all screens), PageFlows app patterns. Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, check, clone, recreate, rebuild. Styles: glassmorphism, brutalism, neumorphism, bento, dark mode, view transitions, scroll-driven, container queries, AI-native, liquid glass, neo-minimalism, mesh gradient, geometric abstraction. Topics: color, accessibility, animation, layout, typography, spacing, shadow, gradient, responsive, dark mode, WCAG 2.2, design tokens, components, spring physics, kinetic typography, container queries, popover API, semantic tokens. Apps: claude.ai, ChatGPT-style, AI chat UI, SaaS dashboard.
2react-doctor
Run after making React changes to catch issues early. Use when reviewing code, finishing a feature, or fixing bugs in a React project.
2cicd-deploy-pro
CI/CD & Deployment for Next.js 16 + Prisma + Neon. Vercel, Docker, GitHub Actions, database migrations, rollback, 20 documented errors. Triggers: deploy, vercel, docker, ci/cd, github actions, pipeline, build, production, staging.
2