Skip to main content
Pdfn supports three styling approaches. Choose based on your needs:

Tailwind CSS

Install @pdfn/tailwind:
Wrap your Page content with the Tailwind component:
Place Tailwind inside Document but it can wrap one or more Page components.

Custom theme

Customize your PDF theme in pdfn-templates/styles.css. This file is auto-detected and isolated from your app’s styles — your app and PDF templates never interfere with each other.
pdfn-templates/styles.css
Use your custom values:

Edge runtime (Vercel Edge, Cloudflare Workers)

Edge runtimes don’t have filesystem access, so Tailwind must be pre-compiled at build time. For Next.js:
next.config.ts
For Vite:
vite.config.ts

CSS prop

Add custom CSS directly via the css prop on Document. No extra packages needed.

Inline styles

Use React’s style prop for styling without extra dependencies:

Combining approaches

You can mix all three approaches. Styles are applied in this order (later wins):
  1. Base pdfn styles
  2. Tailwind CSS classes
  3. Document css prop
  4. Inline style prop

Fonts

Load custom fonts via the fonts prop on Document. Pdfn supports Google Fonts and local font files.

Google Fonts

Pass font names as strings, or configure weights and styles:

Local fonts

Embed custom font files directly. The font is base64-encoded into the PDF.
Local fonts require filesystem access and won’t work on edge runtimes (Vercel Edge, Cloudflare Workers). Use Google Fonts for edge compatibility.

Images

Images must be accessible when the PDF is generated. Since pdfn Cloud renders on remote servers, local filesystem paths won’t work in production.

Next.js public folder

Put images in your public/ folder and reference them with absolute URLs. These deploy with your app and work everywhere.

CDN-hosted images

For large assets or images shared across projects, host them on a CDN (Cloudflare R2, AWS S3, Vercel Blob).

Base64 data URLs

For small images like logos or icons (under 10KB), embed them directly.
Local image paths (like ./images/logo.png) work during development but fail in production. Always use absolute URLs or base64.

PDF-specific CSS notes

Some CSS properties behave differently in PDFs:

Next steps

Components

Document, Page, and layout components

Next.js

API routes, download buttons, and edge runtime