react-pdf — react-pdf install react-pdf, speed-pdf, community, react-pdf install, ide skills, react-pdf custom fonts, generating pdfs with react, Claude Code, Cursor, Windsurf

v1.0.0
GitHub

About this Skill

Perfect for Frontend Agents needing dynamic PDF generation with custom fonts and layouts. react-pdf is a library for generating PDFs with React, supporting custom fonts and layouts.

Features

Generates PDFs with custom fonts by registering local font files
Supports async code execution using IIFE (Immediately Invoked Function Expression) pattern
Disables hyphenation for custom fonts to prevent crashes or incorrect word breaks
Registers hyphenation callbacks using Font.registerHyphenationCallback()
Requires local font files, rejecting remote font URLs (http/https)

# Core Topics

ignacioedlp ignacioedlp
[0]
[0]
Updated: 3/8/2026

Agent Capability Analysis

The react-pdf skill by ignacioedlp is an open-source community AI agent skill for Claude Code and other IDE workflows, helping agents execute tasks with better context, repeatability, and domain-specific guidance. Optimized for react-pdf install, react-pdf custom fonts, generating pdfs with react.

Ideal Agent Persona

Perfect for Frontend Agents needing dynamic PDF generation with custom fonts and layouts.

Core Value

Empowers agents to generate custom PDF documents using React, leveraging local font files and async code wrapping with IIFE patterns, while disabling hyphenation for custom fonts to prevent crashes.

Capabilities Granted for react-pdf

Generating custom PDF reports with embedded fonts
Creating dynamic invoices with async data loading
Debugging PDF rendering issues with custom font hyphenation

! Prerequisites & Limits

  • Requires local font files, remote font URLs are not supported
  • Top-level await is not supported, async code must be wrapped in IIFE
  • Custom fonts require hyphenation to be disabled to prevent rendering issues
Labs Demo

Browser Sandbox Environment

⚡️ Ready to unleash?

Experience this Agent in a zero-setup browser environment powered by WebContainers. No installation required.

Boot Container Sandbox

react-pdf

Install react-pdf, an AI agent skill for AI agent workflows and automation. Works with Claude Code, Cursor, and Windsurf with one-command setup.

SKILL.md
Readonly

Generating PDFs with React-PDF

CRITICAL REQUIREMENTS

  1. Fonts MUST be local files - Remote font URLs (http/https) do NOT work. Always download fonts to local files before using them.
  2. Wrap async code in IIFE - Top-level await causes errors. Always use (async () => { ... })() pattern.
  3. Disable hyphenation for custom fonts - Custom fonts lack hyphenation dictionaries and may crash or break words incorrectly. Always call Font.registerHyphenationCallback((word) => [word]); after registering custom fonts.

Files

  • references/google-fonts.txt - Metadata for ~65 popular Google Fonts with TrueType URLs. Each line is a font variant in tab-separated format: font name, style, category, weight, url.
  • references/components.md - Full component API reference and supported CSS properties
  • assets/example-template.tsx - Minimal working example demonstrating fixed footers, page numbers, and unbreakable content. Read this before starting to understand the basic patterns. Note: not all APIs are shown here — always refer to the docs and references/components.md for the full API.

Prerequisites

bash
1npm install react @react-pdf/renderer 2npm install -D tsx @types/react

tsx runs TypeScript + JSX files directly via Node with no config — no tsconfig.json needed. It uses esbuild under the hood and handles JSX transformation automatically.

Core Components

  • Document: Root component (metadata, settings)
  • Page: Individual pages (A4, Letter, or custom dimensions)
  • View: Container component (similar to div)
  • Text: Text content, supports nesting for inline styling
  • Image: Embed images (JPG, PNG, base64)
  • Link: Clickable hyperlinks (external or internal)
  • Note: Annotation notes
  • Canvas: Freeform drawing with pdfkit methods
  • Svg: Vector graphics (Circle, Rect, Path, Line, Polygon, etc.)
  • StyleSheet: Create reusable styles

For full component props and CSS properties, see references/components.md.

Basic Example

tsx
1import React from "react"; 2import { Document, Page, Text, View, StyleSheet, renderToFile } from "@react-pdf/renderer"; 3 4const styles = StyleSheet.create({ 5 page: { flexDirection: "column", backgroundColor: "#ffffff", padding: 40 }, 6 title: { fontSize: 24, marginBottom: 20, fontWeight: "bold" }, 7 text: { fontSize: 12, lineHeight: 1.5 }, 8}); 9 10const MyDocument = () => ( 11 <Document> 12 <Page size="A4" style={styles.page}> 13 <View style={{ margin: 10, padding: 20 }}> 14 <Text style={styles.title}>Document Title</Text> 15 <Text style={styles.text}>Your content here</Text> 16 </View> 17 </Page> 18 </Document> 19); 20 21(async () => { 22 await renderToFile(<MyDocument />, "./output.pdf"); 23 console.log("PDF saved!"); 24})();

Running Scripts

PDF generation scripts use JSX, which Node cannot run directly. Use tsx to execute them:

bash
1npx tsx my-document.tsx

npx tsx works without installing tsx globally — it downloads on demand. If tsx is installed as a dev dependency (npm install -D tsx), it runs instantly without the npx download step.

Always wrap rendering in async IIFE:

tsx
1// Good 2(async () => { 3 await renderToFile(<MyDocument />, "./output.pdf"); 4})(); 5 6// Bad - top-level await may fail 7await renderToFile(<MyDocument />, "./output.pdf");

Previewing PDFs

To visually inspect generated PDFs, convert pages to images. Try pdftoppm first (often pre-installed), fall back to Python's PyMuPDF if unavailable.

Option 1: pdftoppm (poppler-utils) — preferred, no install needed in many environments:

bash
1pdftoppm -png -r 200 document.pdf preview 2# → preview-1.png, preview-2.png, ...

Option 2: PyMuPDF (Python) — fallback if pdftoppm is not available:

bash
1pip install pymupdf
python
1import fitz 2 3doc = fitz.open("document.pdf") 4for i, page in enumerate(doc): 5 pix = page.get_pixmap(dpi=200) 6 pix.save(f"page-{i+1}.png")

Rendering Methods

tsx
1import { renderToFile, renderToBuffer } from "@react-pdf/renderer"; 2 3// To file 4(async () => { 5 await renderToFile(<MyDocument />, "./document.pdf"); 6})(); 7 8// To buffer 9(async () => { 10 const buffer = await renderToBuffer(<MyDocument />); 11})();

Styling

Three methods: StyleSheet.create(), inline objects, or mixed arrays.

tsx
1const styles = StyleSheet.create({ container: { padding: 20 } }); 2 3<View style={styles.container} /> 4<View style={{ padding: 20 }} /> 5<View style={[styles.container, { marginTop: 10 }]} />

Supported Units

pt (default, 72 DPI), in, mm, cm, %, vw, vh

Common Style Properties

tsx
1{ 2 // Flexbox 3 flexDirection: "row", justifyContent: "space-between", alignItems: "center", 4 flexWrap: "wrap", gap: 10, 5 6 // Box model 7 margin: 10, padding: 20, width: "100%", height: 200, 8 9 // Borders 10 borderWidth: 1, borderColor: "#333", borderRadius: 5, borderStyle: "solid", 11 12 // Colors 13 backgroundColor: "#f0f0f0", color: "#000", opacity: 0.8, 14 15 // Typography 16 fontSize: 12, fontWeight: "bold", fontFamily: "Helvetica", fontStyle: "italic", 17 lineHeight: 1.5, textAlign: "center", textDecoration: "underline", 18 textTransform: "uppercase", letterSpacing: 1, 19 20 // Position 21 position: "absolute", top: 0, left: 0, right: 0, bottom: 0, zIndex: 10, 22 23 // Transforms 24 transform: "rotate(45deg)", transformOrigin: "center", 25}

Images

Local files are most reliable. Remote URLs may fail due to network/CORS issues.

tsx
1import { Image } from '@react-pdf/renderer'; 2 3<Image src="./images/photo.jpg" style={{ width: 200, height: 150 }} /> 4<Image src={{ data: buffer, format: 'png' }} />

SVG files cannot be used as Image sources. Read the SVG source and recreate using react-pdf Svg components.

SVG Graphics

tsx
1import { Svg, Circle, Rect, Path, Line, G, Defs, LinearGradient, Stop } from "@react-pdf/renderer"; 2 3<Svg width="200" height="200" viewBox="0 0 200 200"> 4 <Defs> 5 <LinearGradient id="grad1" x1="0%" y1="0%" x2="100%" y2="0%"> 6 <Stop offset="0%" stopColor="#3498db" /> 7 <Stop offset="100%" stopColor="#9b59b6" /> 8 </LinearGradient> 9 </Defs> 10 <Circle cx="100" cy="100" r="50" fill="url(#grad1)" /> 11 <Rect x="10" y="10" width="50" height="50" fill="#e74c3c" /> 12 <Path d="M10,50 Q50,10 90,50" stroke="#2ecc71" strokeWidth="2" fill="none" /> 13</Svg>;

Using Icons

Read SVG source from icon libraries and convert to react-pdf Svg components:

bash
1npm install lucide-static
tsx
1import { Svg, Path, Rect } from "@react-pdf/renderer"; 2 3// Converted from lucide-static/icons/mail.svg 4const MailIcon = ({ size = 12, color = "#888" }) => ( 5 <Svg width={size} height={size} viewBox="0 0 24 24"> 6 <Path d="m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7" stroke={color} strokeWidth={2} fill="none" /> 7 <Rect x="2" y="4" width="20" height="16" rx="2" stroke={color} strokeWidth={2} fill="none" /> 8 </Svg> 9);
tsx
1<Link src="https://example.com"><Text>Visit website</Text></Link> 2 3<View id="section-1"><Text>Target</Text></View> 4<Link src="#section-1"><Text>Jump to Section 1</Text></Link>

Dynamic Content and Page Numbers

tsx
1<Text render={({ pageNumber, totalPages }) => `Page ${pageNumber} of ${totalPages}`} />

Fixed Headers/Footers

tsx
1<Page size="A4"> 2 <View fixed style={{ position: "absolute", top: 20, left: 30, right: 30 }}> 3 <Text>Header</Text> 4 </View> 5 <View style={{ marginTop: 60, marginBottom: 60 }}> 6 <Text>Content</Text> 7 </View> 8 <Text 9 fixed 10 style={{ position: "absolute", bottom: 20, left: 30, right: 30, textAlign: "center" }} 11 render={({ pageNumber, totalPages }) => `Page ${pageNumber} of ${totalPages}`} 12 /> 13</Page>

Page Breaks and Wrapping

tsx
1<View break /> // Force page break 2<View wrap={false}><Text>Keep together</Text></View> // Prevent breaking inside 3<Text orphans={2} widows={2}>Long text...</Text> // Orphan/widow control 4<View minPresenceAhead={100}><Text>Content</Text></View> // Min space before break

Custom Fonts

CRITICAL: All font sources MUST be local file paths. Remote URLs do not work.

tsx
1import { Font } from "@react-pdf/renderer"; 2 3Font.register({ 4 family: "Roboto", 5 fonts: [ 6 { src: "./fonts/Roboto-Regular.ttf", fontWeight: "normal" }, 7 { src: "./fonts/Roboto-Bold.ttf", fontWeight: "bold" }, 8 { src: "./fonts/Roboto-Italic.ttf", fontStyle: "italic" }, 9 ], 10}); 11 12// Always disable hyphenation when using custom fonts 13Font.registerHyphenationCallback((word) => [word]);

Built-in fonts: Courier, Helvetica, Times-Roman (each with Bold, Italic/Oblique variants)

Font weight values: thin (100), ultralight (200), light (300), normal (400), medium (500), semibold (600), bold (700), ultrabold (800), heavy (900)

Google Fonts

Use references/google-fonts.txt to find font URLs, then download locally:

bash
1# Find the font URL 2grep "^Roboto" skills/react-pdf/references/google-fonts.txt | grep "700" | grep "normal" 3 4# Download 5mkdir -p fonts 6curl -sL "<url-from-grep>" -o fonts/Roboto-Bold.ttf 7 8# Verify - must show "TrueType Font data" 9file fonts/Roboto-Bold.ttf

If file shows "HTML document" or "ASCII text", the download failed. Try a different URL or search GitHub for the font's official repo with TTF files.

Emoji

Emoji won't render in PDFs unless you register an emoji source. Install twemoji-emojis to get local Twemoji PNG assets — no internet needed at render time.

bash
1npm install twemoji-emojis
tsx
1import { Font } from "@react-pdf/renderer"; 2 3Font.registerEmojiSource({ 4 format: "png", 5 url: "node_modules/twemoji-emojis/vendor/72x72/", 6});

Then use emoji directly in Text: <Text>Hello 🚀🎉</Text>

Other Features

tsx
1// Canvas drawing 2<Canvas style={{ width: 200, height: 200 }} 3 paint={(painter, w, h) => { painter.circle(w/2, h/2, 50).fill("#3498db"); }} /> 4 5// Annotation notes 6<Note style={{ color: "yellow" }}>Annotation text</Note> 7 8// Hyphenation 9Font.registerHyphenationCallback((word) => [word]); // disable 10 11// Debug mode - visualize boundaries 12<View debug><Text debug>Debug text</Text></View> 13 14// Document metadata 15<Document title="My Doc" author="Author" subject="Report" language="en-US" pdfVersion="1.5" />

Best Practices

  1. Use StyleSheet.create() — define styles once and reuse
  2. Compress images before embedding, use cache={true} for remote images
  3. Test page breaks — content may flow differently than expected
  4. Prefer flexbox over absolute positioning
  5. Use fixed prop for headers/footers on every page
  6. Use debug={true} to visualize element boundaries
  7. Wrap rendering in try-catch blocks

Common Issues

Text overflow: <Text style={{ width: 200, maxLines: 3, textOverflow: "ellipsis" }}>...</Text>

Missing fonts: Download locally and register with local file paths. Remote URLs will NOT work.

Unexpected page breaks: Use wrap={false} to keep content together, or <View break /> to force breaks.

FAQ & Installation Steps

These questions and steps mirror the structured data on this page for better search understanding.

? Frequently Asked Questions

What is react-pdf?

Perfect for Frontend Agents needing dynamic PDF generation with custom fonts and layouts. react-pdf is a library for generating PDFs with React, supporting custom fonts and layouts.

How do I install react-pdf?

Run the command: npx killer-skills add ignacioedlp/speed-pdf/react-pdf. It works with Cursor, Windsurf, VS Code, Claude Code, and 19+ other IDEs.

What are the use cases for react-pdf?

Key use cases include: Generating custom PDF reports with embedded fonts, Creating dynamic invoices with async data loading, Debugging PDF rendering issues with custom font hyphenation.

Which IDEs are compatible with react-pdf?

This skill is compatible with Cursor, Windsurf, VS Code, Trae, Claude Code, OpenClaw, Aider, Codex, OpenCode, Goose, Cline, Roo Code, Kiro, Augment Code, Continue, GitHub Copilot, Sourcegraph Cody, and Amazon Q Developer. Use the Killer-Skills CLI for universal one-command installation.

Are there any limitations for react-pdf?

Requires local font files, remote font URLs are not supported. Top-level await is not supported, async code must be wrapped in IIFE. Custom fonts require hyphenation to be disabled to prevent rendering issues.

How To Install

  1. 1. Open your terminal

    Open the terminal or command line in your project directory.

  2. 2. Run the install command

    Run: npx killer-skills add ignacioedlp/speed-pdf/react-pdf. The CLI will automatically detect your IDE or AI agent and configure the skill.

  3. 3. Start using the skill

    The skill is now active. Your AI agent can use react-pdf immediately in the current project.

Related Skills

Looking for an alternative to react-pdf or another community skill for your workflow? Explore these related open-source skills.

View All

widget-generator

Logo of f
f

f.k.a. Awesome ChatGPT Prompts. Share, discover, and collect prompts from the community. Free and open source — self-host for your organization with complete privacy.

149.6k
0
AI

flags

Logo of vercel
vercel

flags is a Next.js feature management skill that enables developers to efficiently add or modify framework feature flags, streamlining React application development.

138.4k
0
Browser

zustand

Logo of lobehub
lobehub

The ultimate space for work and life — to find, build, and collaborate with agent teammates that grow with you. We are taking agent harness to the next level — enabling multi-agent collaboration, effortless agent team design, and introducing agents as the unit of work interaction.

72.8k
0
AI

data-fetching

Logo of lobehub
lobehub

The ultimate space for work and life — to find, build, and collaborate with agent teammates that grow with you. We are taking agent harness to the next level — enabling multi-agent collaboration, effortless agent team design, and introducing agents as the unit of work interaction.

72.8k
0
AI